twitter / finatra

Fast, testable, Scala services built on TwitterServer and Finagle
https://twitter.github.io/finatra/
Apache License 2.0
2.27k stars 408 forks source link

Depending on the version of jackson-core, it can not be converted to request parameter class. #454

Closed giiita closed 6 years ago

giiita commented 6 years ago

Depending on the version of jackson-core, it can not be converted to request parameter class.

Expected behavior

For example, finatra-http_18.4.0 depends on jackson-core_2.8.4. At this time, FinatraCaseClassDeserializer.deserializeNonWrapperClass 's val jsonNode = jp.readValueAsTree[JsonNode] returns null.

However, when unintentionally defined "com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.9.4" , val jsonNode = jp.readValueAsTree[JsonNode] returns {}.

The Deserializer will now accept the empty request and misunderstand it.

Steps to reproduce the behavior

  1. Create an API to receive QueryParam in any case class.
  2. Add the following to the dependency. "com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.9.4"
  3. Specifying the requested QueryParam will not deserialize to the case class.
cacoco commented 6 years ago

@giiita thanks for the issue.

I think this is covered in https://github.com/twitter/finatra/issues/442. Finatra is not expected to work with any Jackson version other what is specified in the Finatra build.sbt (as of this writing, 2.8.4). Using a different Jackson version with Finatra will cause failures or undefined behavior.

The solution? Please specify the necessary version of Jackson.

Thanks!