Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static JsonCreator method does not work when using DefaultScalaModule #229

Closed
mbknor opened this issue Nov 2, 2015 · 11 comments
Closed

Comments

@mbknor
Copy link
Member

mbknor commented Nov 2, 2015

This bug makes it impossible to use DefaultScalaModule together with Dropwizards.

DefaultScalaModule fails while processing https://github.com/dropwizard/dropwizard/blob/master/dropwizard-util/src/main/java/io/dropwizard/util/Duration.java

Relates to #221

I will supply PR with test that shows this issue

@jarreds
Copy link

jarreds commented Jan 15, 2016

This is still a huge problem for us. Has anyone taken a look at this?

@cowtowncoder
Copy link
Member

@jarreds It may make sense to ask on jackson-dev list -- not many developers follow github issue updates. I don't work on Scala module myself, and I think Christopher C hasn't had time to spend on it either. So I doubt anyone has looked into this at all. But finding someone with time and itch would be easiest to do via mailing list.

nbauernfeind added a commit that referenced this issue Feb 22, 2016
…ic-creator-method

Adds test that asserts that Static @JsonCreator method does work - refs #229
@nbauernfeind
Copy link
Member

A bug fix for this (hopefully works) is going to be released in v2.6.5, and v2.7.2 (note: 2.7.0/2.7.1 are not going to be released since they won't work). Can you please upgrade and check if #236 fixes your issue?

@kelnos
Copy link

kelnos commented Mar 8, 2016

Hi, I'm experiencing this problem as well, and can confirm that 2.6.5 does not fix this issue.

@nbauernfeind
Copy link
Member

For me to reproduce I should be able to create a dropwizard project where the configuration contains a single Duration? Or do you think there is something more involved than that?

@cowtowncoder
Copy link
Member

Ideally of course wouldn't require dep to dropwizard. But I think it has some custom deserializers of its own, for Duration specifically?

@kelnos
Copy link

kelnos commented Mar 8, 2016

Don't even need that; there's Duration in the default builtin config, so just a skeleton is fine. Let me see if I can throw something on GH...

DW doesn't use custom deserializers for Duration, it just has the @JsonCreator and @JsonValue annotations.

@kelnos
Copy link

kelnos commented Mar 8, 2016

Ok, here's a test case: https://github.com/kelnos/dw9-jackson-scala-failure-repro -- instructions are in the README.

For reference, here is the specific version of Duration.java that gets pulled in: https://github.com/dropwizard/dropwizard/blob/v0.9.2/dropwizard-util/src/main/java/io/dropwizard/util/Duration.java

Also perhaps of note, if you create a custom jackson deserializer for Duration (that just calls Duration.parse(), and then register that with the ObjectMapper, it does work (of course, then it fails with the same issue with io.dropwizard.util.Size).

@kelnos
Copy link

kelnos commented Mar 9, 2016

Can also confirm that disabling ParanamerAnnotationIntrospector as described in #221 (comment) works around the issue and allows DW9 to start properly.

@nbauernfeind
Copy link
Member

Thank you, @kelnos, for providing a test case.

I've discovered that this issue has nothing at all to do with the Scala Module, except that we use / register a ParanamerAnnotationIntrospector (as somewhat alluded to in #221). If you create a module that only registers Paranamer it has this issue. I will still see what I can do to follow up and/or fix since it is a scala module dependency.

This is the minimal failing test I've found so far (and the serialization half is fine):

object Test extends App {
  val mapper = new ObjectMapper with ScalaObjectMapper
  mapper.registerModule(new JacksonModule {
    this += (_.appendAnnotationIntrospector(new ParanamerAnnotationIntrospector()))
  })
  val ser = mapper.writeValueAsString(Duration.minutes(1))
  val x = mapper.readValue[Duration](ser)
}

@pjfanning
Copy link
Member

closing this - probably fixed with FasterXML/jackson-databind#1001 -- please reopen if it is still an issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants