Skip to content

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

@mdespriee

Description

@mdespriee

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions