Skip to content

Commit c20ac86

Browse files
committed
Addendum to #1438: unit test
1 parent 971773d commit c20ac86

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,27 @@
1616
class ParserClosingTest
1717
extends JUnit5TestBase
1818
{
19+
// [core#1438]: clear _currToken on parser.close()
20+
@Test
21+
void clearTokenOnClose() throws Exception
22+
{
23+
_clearTokenOnClose(MODE_INPUT_STREAM);
24+
_clearTokenOnClose(MODE_INPUT_STREAM_THROTTLED);
25+
_clearTokenOnClose(MODE_READER);
26+
_clearTokenOnClose(MODE_DATA_INPUT);
27+
28+
}
29+
30+
private void _clearTokenOnClose(int mode) throws Exception
31+
{
32+
try (JsonParser p = createParser(mode, "[1, 2]")) {
33+
assertNull(p.currentToken());
34+
assertToken(JsonToken.START_ARRAY, p.nextToken());
35+
p.close();
36+
assertNull(p.currentToken());
37+
}
38+
}
39+
1940
/**
2041
* This unit test checks the default behaviour; with no auto-close, no
2142
* automatic closing should occur, nor explicit one unless specific

0 commit comments

Comments
 (0)