Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update Jackson to 2.9.9
Problem
In order to make util cross building with scala 2.13, we need to move to Jackson
2.9.9 for 2.13 support.

Solution
Upgrade it.

Result
As a bonus, Jackson fixes a bug
FasterXML/jackson-core#531 when feeding async json
parser, remove the `slicedOffset` as now parser records the right position.

Differential Revision: https://phabricator.twitter.biz/D345969
  • Loading branch information
yufangong authored and jenkins committed Jul 25, 2019
1 parent b139159 commit f050be4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -25,6 +25,8 @@ Changed
`c.t.finatra.http.response.ResponseBuilder.streaming` to construct a
`c.t.finatra.http.streaming.StreamingResponse` instead. ``PHAB_ID=D342703``

* finatra: Upgrade to Jackson 2.9.9. ``PHAB_ID=D345969``

19.7.0
------

Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Expand Up @@ -58,7 +58,7 @@ lazy val versions = new {
val commonsLang = "2.6"
val fastutil = "8.1.1"
val guice = "4.0"
val jackson = "2.9.8"
val jackson = "2.9.9"
val jodaConvert = "1.2"
val jodaTime = "2.5"
val junit = "4.12"
Expand Down
Expand Up @@ -29,8 +29,6 @@ private[finatra] class AsyncJsonParser {
private[this] var position: Int = 0
// offset that records the length of parsed bytes in parser, accumulated every chunk
private[this] var offset: Int = 0
// offset of a sliced buf, this offset should not be accumulated
private[this] var slicedBufOffset = 0
private[this] var depth: Int = 0

/**
Expand All @@ -43,7 +41,6 @@ private[finatra] class AsyncJsonParser {
buf match {
case Buf.ByteArray.Owned((bytes, begin, end)) =>
feeder.feedInput(bytes, begin, end)
slicedBufOffset = begin
case Buf.ByteArray.Shared(bytes) =>
feeder.feedInput(bytes, 0, bytes.length)
case b =>
Expand All @@ -59,10 +56,10 @@ private[finatra] class AsyncJsonParser {
updateOpenBrace()
if (startInitialArray) {
// exclude the initial `[`
position = parser.getCurrentLocation.getByteOffset.toInt - slicedBufOffset - offset
position = parser.getCurrentLocation.getByteOffset.toInt - offset
} else if (startObjectArray) {
// include the starting token of the object or array
position = parser.getCurrentLocation.getByteOffset.toInt - slicedBufOffset - offset - 1
position = parser.getCurrentLocation.getByteOffset.toInt - offset - 1
} else if (endObjectArray) {
result += getSlicedBuf()
} else if (endInitialArray) {
Expand All @@ -80,7 +77,7 @@ private[finatra] class AsyncJsonParser {
private def getSlicedBuf(): Buf = {

remaining.position(position)
val newPosition = parser.getCurrentLocation.getByteOffset.toInt - slicedBufOffset - offset
val newPosition = parser.getCurrentLocation.getByteOffset.toInt - offset
val buf = remaining.slice()
buf.limit(newPosition - position)

Expand Down

0 comments on commit f050be4

Please sign in to comment.