timols / java-gitlab-api

A wrapper for the Gitlab API written in Java
Apache License 2.0
387 stars 316 forks source link

LocalDate deserialization in issues #350

Open durm opened 5 years ago

durm commented 5 years ago
java.lang.RuntimeException: org.gitlab.api.GitlabAPIException
    at org.gitlab.api.http.GitlabHTTPRequestor$1.fetch(GitlabHTTPRequestor.java:243) ~[java-gitlab-api-4.1.0.jar:na]
    at org.gitlab.api.http.GitlabHTTPRequestor$1.hasNext(GitlabHTTPRequestor.java:197) ~[java-gitlab-api-4.1.0.jar:na]
    at org.gitlab.api.http.GitlabHTTPRequestor.getAll(GitlabHTTPRequestor.java:165) ~[java-gitlab-api-4.1.0.jar:na]
    at org.gitlab.api.GitlabAPI.getIssues(GitlabAPI.java:2433) ~[java-gitlab-api-4.1.0.jar:na]
    at com.incasec.tg.bounty.bot.IssuesCommand.getIssues(IssuesCommand.java:22) ~[classes/:na]
    at com.incasec.tg.bounty.bot.IssuesCommand.createMessage(IssuesCommand.java:32) ~[classes/:na]
    at com.incasec.tg.bounty.bot.BountyBot.onUpdateReceived(BountyBot.java:24) ~[classes/:na]
    at java.util.ArrayList.forEach(ArrayList.java:1257) ~[na:1.8.0_201]
    at org.telegram.telegrambots.meta.generics.LongPollingBot.onUpdatesReceived(LongPollingBot.java:27) ~[telegrambots-meta-4.1.2.jar:na]
    at org.telegram.telegrambots.updatesreceivers.DefaultBotSession$HandlerThread.run(DefaultBotSession.java:305) ~[telegrambots-4.1.2.jar:na]
Caused by: org.gitlab.api.GitlabAPIException: null
    at org.gitlab.api.http.GitlabHTTPRequestor.handleAPIError(GitlabHTTPRequestor.java:408) ~[java-gitlab-api-4.1.0.jar:na]
    at org.gitlab.api.http.GitlabHTTPRequestor.access$300(GitlabHTTPRequestor.java:38) ~[java-gitlab-api-4.1.0.jar:na]
    at org.gitlab.api.http.GitlabHTTPRequestor$1.fetch(GitlabHTTPRequestor.java:240) ~[java-gitlab-api-4.1.0.jar:na]
    ... 9 common frames omitted
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not instantiate value of type [simple type, class java.time.LocalDate] from String value ('2019-06-14'); no single-String constructor/factory method
 at [Source: java.io.StringReader@18c33041; line: 1, column: 61362] (through reference chain: Object[][13]->org.gitlab.api.models.GitlabIssue["due_date"])
    at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:148) ~[jackson-databind-2.5.3.jar:2.5.3]
    at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:843) ~[jackson-databind-2.5.3.jar:2.5.3]
    at com.fasterxml.jackson.databind.deser.ValueInstantiator._createFromStringFallbacks(ValueInstantiator.java:277) ~[jackson-databind-2.5.3.jar:2.5.3]
    at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.createFromString(StdValueInstantiator.java:284) ~[jackson-databind-2.5.3.jar:2.5.3]
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromString(BeanDeserializerBase.java:1150) ~[jackson-databind-2.5.3.jar:2.5.3]
    at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:153) ~[jackson-databind-2.5.3.jar:2.5.3]
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:144) ~[jackson-databind-2.5.3.jar:2.5.3]
    at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:523) ~[jackson-databind-2.5.3.jar:2.5.3]
    at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:95) ~[jackson-databind-2.5.3.jar:2.5.3]
    at com.fasterxml.jackson.databind.deser.impl.BeanPropertyMap.findDeserializeAndSet(BeanPropertyMap.java:285) ~[jackson-databind-2.5.3.jar:2.5.3]
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:248) ~[jackson-databind-2.5.3.jar:2.5.3]
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:136) ~[jackson-databind-2.5.3.jar:2.5.3]
    at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(ObjectArrayDeserializer.java:156) ~[jackson-databind-2.5.3.jar:2.5.3]
    at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(ObjectArrayDeserializer.java:17) ~[jackson-databind-2.5.3.jar:2.5.3]
    at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3562) ~[jackson-databind-2.5.3.jar:2.5.3]
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2578) ~[jackson-databind-2.5.3.jar:2.5.3]
    at org.gitlab.api.http.GitlabHTTPRequestor.parse(GitlabHTTPRequestor.java:369) ~[java-gitlab-api-4.1.0.jar:na]
    at org.gitlab.api.http.GitlabHTTPRequestor.access$200(GitlabHTTPRequestor.java:38) ~[java-gitlab-api-4.1.0.jar:na]
    at org.gitlab.api.http.GitlabHTTPRequestor$1.fetch(GitlabHTTPRequestor.java:236) ~[java-gitlab-api-4.1.0.jar:na]
    ... 9 common frames omitted
asiletto commented 5 years ago

subscribing

cowtowncoder commented 5 years ago

This is now broken due to incompatible definition of "due_date" property in GitlabIssue POJO. It should NOT mix java.util.Date with java.time.LocalDate: one or the other should be used; and if LocalDate, then suitable deserializer AND serializer must be registered either through annotations on POJO definition, or by registering JavaTimeModule from jackson-datatype-jsr310 (which is already depended on via Maven and/or Gradle definitions).

Also keep in mind that changing definition of property types of GitlabIssue WILL break any code that is using it already (possibly via transitive dependencies) -- this is breaking change from API perspective.