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

version 2.2.3 can't deserialize some class that verision 2.2.2 can #101

Closed
yuchangyuan opened this issue Oct 6, 2013 · 5 comments
Closed

Comments

@yuchangyuan
Copy link

Some simple class can successful deserialize with jackson-module-scala v2.2.2, throw com.fasterxml.jackson.databind.JsonMappingException with v2.2.3.

Test code:
https://github.com/yuchangyuan/jackson-test1
https://github.com/yuchangyuan/jackson-test1/blob/master/src/main/scala/test.scala

package me.ycy.jackson.test1

import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.scala.DefaultScalaModule

import java.io.File

class MyObj(val a: String, var b: String) {
  override def toString = s"{a: ${a}, b: ${b}}"
}

object Test {
  def main(args: Array[String]) = {
    val mapper = new ObjectMapper()
    mapper.registerModule(DefaultScalaModule)

    val obj = new MyObj("abc", "efg")
    val str = mapper.writeValueAsString(obj)
    println(s"str = ${str}")
    val obj1 = mapper.readValue(str, classOf[MyObj])
    println("obj = " + obj1.toString)
  }
}

and build.sbt

// -*- mode: scala -*
import AssemblyKeys._

organization := "me.ycy"

name := "jackson-test1"

scalaVersion := "2.10.2"

version := "0.1"

net.virtualvoid.sbt.graph.Plugin.graphSettings

scalacOptions ++= Seq("-unchecked", "-deprecation", "-Xcheckinit", "-Xfatal-warnings")

assemblySettings

libraryDependencies ++= Seq(
  "com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.2.3",
  "com.fasterxml.jackson.core" % "jackson-databind" % "2.2.3"
)

The output is here:
https://gist.github.com/yuchangyuan/1acd667cec29ce9b6a35

But if I change jackson-module-scala version to 2.2.2, while keep jackson-databind version unchanged(v2.2.3), everything is ok(that's why I think this is a jackson-module-scala issue, not jackson-databind):
https://gist.github.com/yuchangyuan/06ceebf8087b53df4c9b

@christophercurrie
Copy link
Member

This was caused by my attempts at a fix for #83, which in turn is caused by FasterXML/jackson-databind#318.

For 2.3 (and 2.2.4, if there ever is one), I'll revert the fix for #83, as it's a bit of an esoteric use case, and hopefully be able to get a fix into databind for that use case.

@yuchangyuan
Copy link
Author

Just find out that I try v2.2.3 for #73 (and then find this issue), and just confirm that v2.2.3 actually fix my problem(#73) happened with v2.2.2, so I have to wait v2.3(or v2.2.4) for both to be fixed.

@christophercurrie
Copy link
Member

Version 2.3.0-rc1 has been released with this fix. It'd be a big help if you could try out the release candidate and let us know if you have any issues.

@yuchangyuan
Copy link
Author

Thank you, the problem disappear after switch to 2.3.0-rc1, test with both jackson-test1 test code and my real code.

@christophercurrie
Copy link
Member

Great, thanks for your feedback!

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