Skip to content

Commit 8b25fd6

Browse files
authored
Fix #1553 (#1554)
1 parent ad93650 commit 8b25fd6

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

release-notes/VERSION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ JSON library.
1919

2020
#1548: `StreamReadConstraints.maxDocumentLength` not checked when
2121
creating parser with fixed buffer
22+
#1553: Max Depth validation not working for `DataInput`-backed `JsonParser`s
23+
in 3.0
2224

2325
3.1.0-rc1 (27-Jan-2026)
2426

src/main/java/tools/jackson/core/json/ReaderBasedJsonParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,9 +1262,9 @@ public final long nextLongValue(long defaultValue) throws JacksonException
12621262
return getLongValue();
12631263
}
12641264
if (t == JsonToken.START_ARRAY) {
1265-
_streamReadContext = _streamReadContext.createChildArrayContext(_tokenInputRow, _tokenInputCol);
1265+
createChildArrayContext(_tokenInputRow, _tokenInputCol);
12661266
} else if (t == JsonToken.START_OBJECT) {
1267-
_streamReadContext = _streamReadContext.createChildObjectContext(_tokenInputRow, _tokenInputCol);
1267+
createChildObjectContext(_tokenInputRow, _tokenInputCol);
12681268
}
12691269
return defaultValue;
12701270
}

src/main/java/tools/jackson/core/json/UTF8DataInputJsonParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,10 +686,10 @@ private final JsonToken _nextTokenNotInObject(int i) throws IOException
686686
}
687687
switch (i) {
688688
case '[':
689-
_streamReadContext = _streamReadContext.createChildArrayContext(_tokenInputRow, _tokenInputCol);
689+
createChildArrayContext(_tokenInputRow, _tokenInputCol);
690690
return _updateToken(JsonToken.START_ARRAY);
691691
case '{':
692-
_streamReadContext = _streamReadContext.createChildObjectContext(_tokenInputRow, _tokenInputCol);
692+
createChildObjectContext(_tokenInputRow, _tokenInputCol);
693693
return _updateToken(JsonToken.START_OBJECT);
694694
case 't':
695695
_matchToken("true", 1);

src/test/java/tools/jackson/core/unittest/constraints/DeeplyNestedContentViaDataInputTest.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,23 @@
88
import tools.jackson.core.*;
99
import tools.jackson.core.exc.StreamConstraintsException;
1010
import tools.jackson.core.json.JsonFactory;
11-
import tools.jackson.core.unittest.testutil.failure.JacksonTestFailureExpected;
1211

1312
import static org.junit.jupiter.api.Assertions.*;
1413

1514
/**
1615
* Nesting Depth Constraint Bypass in UTF8DataInputJsonParser
1716
*/
18-
class DeeplyNestedContentViaDataInputTest {
19-
17+
class DeeplyNestedContentViaDataInputTest
18+
{
2019
private static final int TEST_NESTING_DEPTH = 5000;
2120

2221
private final JsonFactory factory = new JsonFactory();
2322

24-
// 19-Feb-2026, tatu: Regression; works in 2.x
25-
@JacksonTestFailureExpected
23+
// [core#1553] Regression; works in 2.x
2624
@Test
2725
void dataInputParserBypassesNestingDepth() throws Exception {
2826
byte[] data = buildNestedArrays(TEST_NESTING_DEPTH);
2927
DataInput di = new DataInputStream(new ByteArrayInputStream(data));
30-
3128
int maxDepth = 0;
3229
try (JsonParser p = factory.createParser(ObjectReadContext.empty(), di)) {
3330
while (p.nextToken() != null) {

0 commit comments

Comments
 (0)