Skip to content

Commit 6b57b33

Browse files
committed
Minor post #943 changes
1 parent 54f78a9 commit 6b57b33

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

src/main/java/com/fasterxml/jackson/core/JsonStreamContext.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public abstract class JsonStreamContext
5555
/**
5656
* The nesting depth is a count of objects and arrays that have not
5757
* been closed, `{` and `[` respectively.
58+
*
59+
* @since 2.15
5860
*/
5961
protected int _nestingDepth;
6062

@@ -127,6 +129,8 @@ protected JsonStreamContext(int type, int index) {
127129
/**
128130
* The nesting depth is a count of objects and arrays that have not
129131
* been closed, `{` and `[` respectively.
132+
*
133+
* @since 2.15
130134
*/
131135
public final int getNestingDepth() {
132136
return _nestingDepth;

src/main/java/com/fasterxml/jackson/core/base/ParserBase.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,6 +1300,24 @@ protected float _getNumberFloat() throws JsonParseException {
13001300
return _numberFloat;
13011301
}
13021302

1303+
/*
1304+
/**********************************************************
1305+
/* Internal/package methods: Context handling (2.15)
1306+
/**********************************************************
1307+
*/
1308+
1309+
// @since 2.15
1310+
protected void createChildArrayContext(final int lineNr, final int colNr) throws IOException {
1311+
_parsingContext = _parsingContext.createChildArrayContext(lineNr, colNr);
1312+
_streamReadConstraints.validateNestingDepth(_parsingContext.getNestingDepth());
1313+
}
1314+
1315+
// @since 2.15
1316+
protected void createChildObjectContext(final int lineNr, final int colNr) throws IOException {
1317+
_parsingContext = _parsingContext.createChildObjectContext(lineNr, colNr);
1318+
_streamReadConstraints.validateNestingDepth(_parsingContext.getNestingDepth());
1319+
}
1320+
13031321
/*
13041322
/**********************************************************
13051323
/* Internal/package methods: Error reporting
@@ -1536,14 +1554,4 @@ protected void loadMoreGuaranteed() throws IOException {
15361554

15371555
// Can't declare as deprecated, for now, but shouldn't be needed
15381556
protected void _finishString() throws IOException { }
1539-
1540-
protected final void createChildArrayContext(final int lineNr, final int colNr) throws IOException {
1541-
_parsingContext = _parsingContext.createChildArrayContext(lineNr, colNr);
1542-
_streamReadConstraints.validateNestingDepth(_parsingContext.getNestingDepth());
1543-
}
1544-
1545-
protected final void createChildObjectContext(final int lineNr, final int colNr) throws IOException {
1546-
_parsingContext = _parsingContext.createChildObjectContext(lineNr, colNr);
1547-
_streamReadConstraints.validateNestingDepth(_parsingContext.getNestingDepth());
1548-
}
15491557
}

src/test/java/com/fasterxml/jackson/core/read/ArrayParsingTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,7 @@ public void testDeepNesting() throws Exception
111111
{
112112
final String DOC = createDeepNestedDoc(1050);
113113
try (JsonParser jp = createParserUsingStream(new JsonFactory(), DOC, "UTF-8")) {
114-
JsonToken jt;
115-
while ((jt = jp.nextToken()) != null) {
116-
117-
}
114+
while (jp.nextToken() != null) { }
118115
fail("expected StreamConstraintsException");
119116
} catch (StreamConstraintsException e) {
120117
assertEquals("Depth (1001) exceeds the maximum allowed nesting depth (1000)", e.getMessage());

0 commit comments

Comments
 (0)