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

Deserializaition of an Option[] not failing on bad input, returning weird data instead. #459

Closed
mdespriee opened this issue Jul 30, 2020 · 3 comments

Comments

@mdespriee
Copy link

Tested with version 2.11.1

case class Foo(value: Option[Long])

val mapper = new ObjectMapper() with ScalaObjectMapper
mapper.registerModule(DefaultScalaModule)
val json = """{ "value": "xx" }"""
val result = mapper.readValue[Foo](json) 
println(result.value) 

Instead of failing to deserialize the json (as it would occur without the option), it actually deserialize it and produces a weird object.
The println() outputs Some(xx) which does not make much sense for an Option[Long] ;-)
Using the debugger, I can see the actual runtime object in the Option is in fact a string.

@mdespriee
Copy link
Author

Looks at bit like #382 but I'm not sure it's the exact same problem.

@pjfanning
Copy link
Member

It is the same problem

@mdespriee mdespriee changed the title Bad (and weird) deserialization of Option[] Deserializaition of an Option[] not failing on bad input, returning weird data instead. Jul 31, 2020
pjfanning added a commit that referenced this issue Sep 21, 2021
pjfanning added a commit that referenced this issue Sep 21, 2021
@pjfanning
Copy link
Member

closing due to 1a1391b -- this test seems to indicate that the upcoming 2.13.0 release handles this ok (with an InvalidFormatException)

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

2 participants