Skip to content

Commit

Permalink
Backport #220 fix for 2.5(.5)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Oct 1, 2015
1 parent bdc1833 commit 98df182
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
4 changes: 4 additions & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ JSON library.
=== Releases ===
------------------------------------------------------------------------

2.5.5 (not yet released)

#220: Problem with `JsonParser.nextFieldName(SerializableString)` for byte-backed parser

2.5.4 (09-Jun-2015)

No changes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,8 @@ private final int _skipColonFast(int ptr) throws IOException
}
}
}
_inputPtr = ptr-1;
return _skipColon2(true);
}
_inputPtr = ptr-1;
return _skipColon2(false);
Expand Down
35 changes: 30 additions & 5 deletions src/test/java/com/fasterxml/jackson/core/json/TestNextXxx.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ public class TestNextXxx
/* Wrappers to test InputStream vs Reader
/********************************************************
*/

// [JACKSON-653]

public void testIsNextTokenName() throws Exception
{
_testIsNextTokenName1(false);
Expand All @@ -30,14 +29,21 @@ public void testIsNextTokenName() throws Exception
_testIsNextTokenName3(true);
}

// [Issue#34]
// for [core#220]: problem with `nextFieldName(str)`, indented content
public void testNextNameWithIndentation() throws Exception
{
_testNextFieldNameIndent(false);
_testNextFieldNameIndent(true);
}

// [core#34]
public void testIssue34() throws Exception
{
_testIssue34(false);
_testIssue34(true);
}

// [Issue#38] with nextFieldName
// [core#38] with nextFieldName
public void testIssue38() throws Exception
{
_testIssue38(false);
Expand All @@ -51,7 +57,7 @@ public void testNextNameWithLongContent() throws Exception
_testLong(jf, false);
_testLong(jf, true);
}

/*
/********************************************************
/* Actual test code
Expand Down Expand Up @@ -206,6 +212,25 @@ private void _testIsNextTokenName3(boolean useStream) throws Exception
jp.close();
}

private void _testNextFieldNameIndent(boolean useStream) throws Exception
{
final String DOC = "{\n \"name\" : \n [\n ]\n }";
JsonFactory f = new JsonFactory();
JsonParser p = useStream ?
f.createParser(new ByteArrayInputStream(DOC.getBytes("UTF-8")))
: f.createParser(new StringReader(DOC));
assertToken(JsonToken.START_OBJECT, p.nextToken());
assertTrue(p.nextFieldName(new SerializedString("name")));

assertToken(JsonToken.START_ARRAY, p.nextToken());
assertToken(JsonToken.END_ARRAY, p.nextToken());
assertToken(JsonToken.END_OBJECT, p.nextToken());

assertNull(p.nextToken());

p.close();
}

private void _testIssue34(boolean useStream) throws Exception
{
final int TESTROUNDS = 223;
Expand Down

0 comments on commit 98df182

Please sign in to comment.