Open donlanp opened 7 years ago
Looks like we need to add Joda DateTime to the horribly and improperly named isPrimativeType
method on the ClassUtil class.
This should prevent Catnap from attempting introspect the object. As far as the @jsonserializer
annotation goes I will need to do some more digging.
The reason for @JsonSerializer was for a possible ability to tweak serialization of types. For example, for java.util.Dates, I noticed that it always is serialized into the millisecond value.
Hi @gregwhitaker , do you have any updates on this issue? I am having the same problem using an OffsetDateTime.
Thanks!!!
Hi @gregwhitaker, As it's been a while ... Any updates / plans on this ?
I'm leery of adding too many types to the list of special case handling (ie. the don't introspect this object list).
I think the best approach going forward is to only add core java types to that list (ie. Date, Instant, etc.) and not custom types like those in JodaTime. This way if you want to return JodaTime dates cool, just serialize it the way you want before sending it out to be rendered by Catnap. This prevents the never-ending arms race of adding more types to that list for each scenario where someone doesn't want the type introspected.
There is also the possibility that we could change how the annotations work and you have to supply an annotation and a serializer that turns whatever that annotated field is into primitive type when Catnap does its rendering thing.
Thoughts?
When trying to use CatNap with Joda DateTimes, we have a couple issues.
Without the "fields" parameter on the request, the DateTime is serialized normally:
"2017-06-02T19:27:06.000Z"
When adding the "fields" parameter, we end up seeing the entire Joda DateTime object exploded:
{ "dayOfYear" : 153, "year" : 2017, "weekyear" : 2017, "chronology" : { "zone" : { "fixed" : true, "ID" : "Etc/UTC" } }, "weekOfWeekyear" : 22, "secondOfMinute" : 6, "millisOfDay" : 70026000, "monthOfYear" : 6, "dayOfWeek" : 5, "minuteOfDay" : 1167, "era" : 1, "zone" : { "fixed" : true, "ID" : "Etc/UTC" }, "yearOfCentury" : 17, "secondOfDay" : 70026, "afterNow" : false, "millisOfSecond" : 0, "equalNow" : false, "beforeNow" : true, "dayOfMonth" : 2, "centuryOfEra" : 20, "hourOfDay" : 19, "millis" : 1496431626000, "yearOfEra" : 2017, "minuteOfHour" : 27 }
At times, we also receive a 500 error from the Servlet with the following exception:
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.github.gregwhitaker.catnap.core.exception.ViewRenderException: Unable to render view - [Exception encountered during view rendering!]] with root cause java.lang.IllegalAccessException: Class com.github.gregwhitaker.catnap.core.query.processor.CatnapProperty can not access a member of class org.joda.time.tz.DateTimeZoneBuilder$PrecalculatedZone with modifiers "public"
Is there a way for CatNap to utilize the \@JsonSerializer annotation?
My project is using Spring-Boot.