Skip to content

Commit

Permalink
Fix JacksonDecoder depth handling (#559)
Browse files Browse the repository at this point in the history
Fixes #557
  • Loading branch information
yawkat authored Sep 1, 2023
1 parent bbf614a commit 4eb5a7f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public void finishStructure() throws IOException {
if (token != JsonToken.END_ARRAY && token != JsonToken.END_OBJECT) {
throw new IllegalStateException("Not all elements have been consumed yet");
}
decreaseDepth();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,18 @@ class JacksonDecoderSpec extends Specification {
then:
thrown SerdeException
}

def "long array"() {
when:
def len = 5000
def json = '[' + "{},".repeat(len - 1) + '{}]'
def decoder = createDecoder(json)
def arrayDecoder = decoder.decodeArray()
then:
for (int i = 0; i < len; i++) {
arrayDecoder.decodeObject().finishStructure()
}
!arrayDecoder.hasNextArrayValue()
arrayDecoder.finishStructure()
}
}

0 comments on commit 4eb5a7f

Please sign in to comment.