Skip to content

Commit

Permalink
source: upgrade jackson to 2.6.5
Browse files Browse the repository at this point in the history
RB_ID=836819
  • Loading branch information
Matthew Bilotti authored and cacoco committed Jun 13, 2016
1 parent d0ae1d9 commit bb1288a
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 18 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ lazy val versions = new {
val guava = "16.0.1"
val guice = "4.0"
val scalaGuice = "4.0.0"
val jackson = "2.4.4"
val jackson = "2.6.5"
val jodaConvert = "1.2"
val jodaTime = "2.5"
val logback = "1.1.7"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class TwitterCloneFeatureTest extends FeatureTest with Mockito {
"location.lat: [9999.0] is not between -85 and 85",
"location.long: field is required",
"message: size [0] is not between 1 and 140",
"nsfw: 'abc' is not a valid boolean"
"nsfw: 'abc' is not a valid Boolean"
]
}
""")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,7 @@ class DoEverythingServerFeatureTest extends FeatureTest {
{
"errors": [
"max: queryParam is required",
"verbose: '5' is not a valid boolean"
"verbose: '5' is not a valid Boolean"
]
}
""")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ case class FinatraObjectMapper(
}

def reader[T: Manifest] = {
objectMapper.reader[T]
objectMapper.readerFor[T]
}

def parse[T: Manifest](message: Message): T = {
Expand All @@ -60,7 +60,7 @@ case class FinatraObjectMapper(
throw new RequestFieldInjectionNotSupportedException()
}
}
FinatraObjectMapper.parseMessageBody(message, objectMapper.reader[T])
FinatraObjectMapper.parseMessageBody(message, objectMapper.readerFor[T])
}

def parse[T: Manifest](byteBuffer: ByteBuffer): T = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.twitter.finatra.json.internal.caseclass.jackson

import com.fasterxml.jackson.databind.JavaType
import com.fasterxml.jackson.databind.`type`.{ArrayType, CollectionLikeType, MapLikeType, TypeFactory}
import com.fasterxml.jackson.databind.`type`.{ArrayType, TypeFactory}
import com.twitter.finatra.json.internal.caseclass.reflection._

object JacksonTypes {
Expand All @@ -14,13 +14,13 @@ object JacksonTypes {
typeFactory.constructType(scalaType.runtimeClass)

else if (scalaType.isMap)
MapLikeType.construct(
typeFactory.constructMapLikeType(
scalaType.runtimeClass,
javaType(typeFactory, scalaType.typeArguments(0)),
javaType(typeFactory, scalaType.typeArguments(1)))

else if (scalaType.isCollection)
CollectionLikeType.construct(
typeFactory.constructCollectionLikeType(
scalaType.runtimeClass,
javaType(typeFactory, scalaType.typeArguments.head))

Expand All @@ -30,7 +30,8 @@ object JacksonTypes {
null, null)

else
typeFactory.constructParametricType(
typeFactory.constructParametrizedType(
scalaType.runtimeClass,
scalaType.runtimeClass,
javaTypes(typeFactory, scalaType.typeArguments): _*)
}
Expand All @@ -49,4 +50,4 @@ object JacksonTypes {
else
javaType(typeFactory, scalaType)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.twitter.finatra.json.internal.serde

import com.fasterxml.jackson.core.util.DefaultIndenter
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter.Lf2SpacesIndenter

object ArrayElementsOnNewLinesPrettyPrinter extends DefaultPrettyPrinter {
_arrayIndenter = Lf2SpacesIndenter.instance
_arrayIndenter = DefaultIndenter.SYSTEM_LINEFEED_INSTANCE
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class FinatraObjectMapperTest extends FeatureSpec with Matchers with Logging {
"nickname" : "ace"
}""",
withErrors = Seq(
"age: 'foo' is not a valid int",
"age: 'foo' is not a valid Integer",
"id: field is required",
"name: field is required"))
}
Expand All @@ -154,7 +154,7 @@ class FinatraObjectMapperTest extends FeatureSpec with Matchers with Logging {
withErrors = Seq(
"make: 'Foo' is not a valid CarMake with valid values: Ford, Honda",
"model: field is required",
"passengers.age: 'blah' is not a valid int",
"passengers.age: 'blah' is not a valid Integer",
"passengers.name: field is required"))
}

Expand Down Expand Up @@ -286,7 +286,7 @@ class FinatraObjectMapperTest extends FeatureSpec with Matchers with Logging {
}""",
withErrors = Seq(
"age3: error parsing ''",
"age: 'old' is not a valid int",
"age: 'old' is not a valid Integer",
"""date_time3: field cannot be negative""",
"""date_time4: field cannot be empty""",
"""date_time: error parsing 'today' into an ISO 8601 datetime"""
Expand Down Expand Up @@ -862,6 +862,17 @@ class FinatraObjectMapperTest extends FeatureSpec with Matchers with Logging {
}
}

feature("a case class with an ArrayList of Integers") {
scenario("ArrayList of Integers") {
val c = parse[CaseClassWithArrayListOfIntegers]("""{"arraylist":[3,1,2]}""")
val l = new java.util.ArrayList[Integer](3)
l.add(3)
l.add(1)
l.add(2)
c.arraylist should equal(l)
}
}

feature("seq of longs") {
scenario("seq of longs") {
val seq = parse[Seq[Long]]("""[3,1,2]""")
Expand Down Expand Up @@ -967,7 +978,7 @@ class FinatraObjectMapperTest extends FeatureSpec with Matchers with Logging {
"foo": "bar"
}""",
withErrors = Seq(
"foo: 'bar' is not a valid boolean"))
"foo: 'bar' is not a valid Boolean"))
}

scenario("case class with boolean number as string") {
Expand All @@ -976,7 +987,7 @@ class FinatraObjectMapperTest extends FeatureSpec with Matchers with Logging {
"foo": "1"
}""",
withErrors = Seq(
"foo: '1' is not a valid boolean"))
"foo: '1' is not a valid Boolean"))
}

val msgHiJsonStr = """{"msg":"hi"}"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ case class CaseClassWithArrays(

case class CaseClassWithArrayLong(array: Array[Long])

case class CaseClassWithArrayListOfIntegers(arraylist: java.util.ArrayList[java.lang.Integer])

case class CaseClassWithArrayBoolean(array: Array[Boolean])

case class CaseClassWithArrayWrappedValueLong(array: Array[WrappedValueLong])
Expand Down Expand Up @@ -363,4 +365,4 @@ package object internal {

case class SimplePersonInPackageObjectWithoutConstructorParams()

}
}

0 comments on commit bb1288a

Please sign in to comment.