Skip to content

Commit 98df182

Browse files
committed
Backport #220 fix for 2.5(.5)
1 parent bdc1833 commit 98df182

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

release-notes/VERSION

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ JSON library.
1414
=== Releases ===
1515
------------------------------------------------------------------------
1616

17+
2.5.5 (not yet released)
18+
19+
#220: Problem with `JsonParser.nextFieldName(SerializableString)` for byte-backed parser
20+
1721
2.5.4 (09-Jun-2015)
1822

1923
No changes.

src/main/java/com/fasterxml/jackson/core/json/UTF8StreamJsonParser.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,8 @@ private final int _skipColonFast(int ptr) throws IOException
10651065
}
10661066
}
10671067
}
1068+
_inputPtr = ptr-1;
1069+
return _skipColon2(true);
10681070
}
10691071
_inputPtr = ptr-1;
10701072
return _skipColon2(false);

src/test/java/com/fasterxml/jackson/core/json/TestNextXxx.java

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ public class TestNextXxx
1818
/* Wrappers to test InputStream vs Reader
1919
/********************************************************
2020
*/
21-
22-
// [JACKSON-653]
21+
2322
public void testIsNextTokenName() throws Exception
2423
{
2524
_testIsNextTokenName1(false);
@@ -30,14 +29,21 @@ public void testIsNextTokenName() throws Exception
3029
_testIsNextTokenName3(true);
3130
}
3231

33-
// [Issue#34]
32+
// for [core#220]: problem with `nextFieldName(str)`, indented content
33+
public void testNextNameWithIndentation() throws Exception
34+
{
35+
_testNextFieldNameIndent(false);
36+
_testNextFieldNameIndent(true);
37+
}
38+
39+
// [core#34]
3440
public void testIssue34() throws Exception
3541
{
3642
_testIssue34(false);
3743
_testIssue34(true);
3844
}
3945

40-
// [Issue#38] with nextFieldName
46+
// [core#38] with nextFieldName
4147
public void testIssue38() throws Exception
4248
{
4349
_testIssue38(false);
@@ -51,7 +57,7 @@ public void testNextNameWithLongContent() throws Exception
5157
_testLong(jf, false);
5258
_testLong(jf, true);
5359
}
54-
60+
5561
/*
5662
/********************************************************
5763
/* Actual test code
@@ -206,6 +212,25 @@ private void _testIsNextTokenName3(boolean useStream) throws Exception
206212
jp.close();
207213
}
208214

215+
private void _testNextFieldNameIndent(boolean useStream) throws Exception
216+
{
217+
final String DOC = "{\n \"name\" : \n [\n ]\n }";
218+
JsonFactory f = new JsonFactory();
219+
JsonParser p = useStream ?
220+
f.createParser(new ByteArrayInputStream(DOC.getBytes("UTF-8")))
221+
: f.createParser(new StringReader(DOC));
222+
assertToken(JsonToken.START_OBJECT, p.nextToken());
223+
assertTrue(p.nextFieldName(new SerializedString("name")));
224+
225+
assertToken(JsonToken.START_ARRAY, p.nextToken());
226+
assertToken(JsonToken.END_ARRAY, p.nextToken());
227+
assertToken(JsonToken.END_OBJECT, p.nextToken());
228+
229+
assertNull(p.nextToken());
230+
231+
p.close();
232+
}
233+
209234
private void _testIssue34(boolean useStream) throws Exception
210235
{
211236
final int TESTROUNDS = 223;

0 commit comments

Comments
 (0)