intercom-java icon indicating copy to clipboard operation
intercom-java copied to clipboard

InvalidDefinitionException: Joda date/time type `org.joda.time.DateTime` not supported by default

Open froque opened this issue 3 years ago • 1 comments

Please use the following template to submit your issue. Following this template will allow us to quickly investigate and help you with your issue. Please be aware that issues which do not conform to this template may be closed.

For feature requests please contact us at [email protected]

Version info

  • intercom-java version: 2.8.1
  • Java version: 8

Expected behavior

Events with java.time or org.joda.time classes should not fail to send events.

Actual behavior

Jackson 2.12 refuses to serialize java.time or org.joda.time classes.

A workaround is to configure the Intercom ObjectMapper:

MapperSupport.objectMapper().registerModule(new JodaModule());

See: https://github.com/FasterXML/jackson-databind/issues/2683, https://github.com/FasterXML/jackson-databind/issues/2776

Steps to reproduce

  1. Use Jackson 2.12
  2. Use a Event with a org.joda.time.DateTime metadata
  3. send event to intercom

Logs

server_1  | Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Joda date/time type `org.joda.time.DateTime` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-joda" to enable handling (through reference chain: io.intercom.api.Event["metadata"]->java.util.HashMap["Valid from"])
server_1  | 	at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:77)
server_1  | 	at com.fasterxml.jackson.databind.SerializerProvider.reportBadDefinition(SerializerProvider.java:1276)
server_1  | 	at com.fasterxml.jackson.databind.ser.impl.UnsupportedTypeSerializer.serialize(UnsupportedTypeSerializer.java:35)
server_1  | 	at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeFields(MapSerializer.java:808)
server_1  | 	at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeWithoutTypeInfo(MapSerializer.java:764)
server_1  | 	at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:720)
server_1  | 	at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:35)
server_1  | 	at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728)
server_1  | 	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770)
server_1  | 	at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
server_1  | 	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
server_1  | 	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319)
server_1  | 	at com.fasterxml.jackson.databind.ObjectMapper._writeValueAndClose(ObjectMapper.java:4487)
server_1  | 	at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:3701)
server_1  | 	at io.intercom.api.HttpClient.prepareRequestEntity(HttpClient.java:135)
server_1  | 	at io.intercom.api.HttpClient.executeHttpMethod(HttpClient.java:108)
server_1  | 	... 8 common frames omitted

froque avatar Apr 27 '21 11:04 froque

Maybe intercom-java should allow (in addition to the default) one to pass your own Jackson dataMapper. This may also have allowed us to fix #311 ourselves instead of waiting for Intercom devs to work on these issues.

cies avatar Jun 06 '24 09:06 cies