Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 7, 2024. It is now read-only.

Commit 8d3fe0c

Browse files
lukasjm0mus
authored andcommitted
fix remaining regressions from 1.0.4 (#85)
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
1 parent 43c85bf commit 8d3fe0c

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

‎impl/src/main/java/org/glassfish/json/JsonParserImpl.java‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ public void skipArray() {
306306
if (currentEvent == Event.START_ARRAY) {
307307
currentContext.skip();
308308
currentContext = stack.pop();
309+
currentEvent = Event.END_ARRAY;
309310
}
310311
}
311312

@@ -314,6 +315,7 @@ public void skipObject() {
314315
if (currentEvent == Event.START_OBJECT) {
315316
currentContext.skip();
316317
currentContext = stack.pop();
318+
currentEvent = Event.END_OBJECT;
317319
}
318320
}
319321

@@ -352,11 +354,16 @@ public JsonLocation getLastCharLocation() {
352354

353355
@Override
354356
public boolean hasNext() {
355-
if (!tokenizer.hasNextToken()) {
356-
if (!stack.isEmpty()) {
357-
currentContext.getNextEvent();
357+
if (stack.isEmpty() && (currentEvent != null && currentEvent.compareTo(Event.KEY_NAME) > 0)) {
358+
JsonToken token = tokenizer.nextToken();
359+
if (token != JsonToken.EOF) {
360+
throw new JsonParsingException(JsonMessages.PARSER_EXPECTED_EOF(token),
361+
getLastCharLocation());
358362
}
359363
return false;
364+
} else if (!stack.isEmpty() && !tokenizer.hasNextToken()) {
365+
currentEvent = currentContext.getNextEvent();
366+
return false;
360367
}
361368
return true;
362369
}
@@ -583,4 +590,4 @@ void skip() {
583590
}
584591
}
585592

586-
}
593+
}

‎tests/src/test/java/org/glassfish/json/tests/JsonParserTest.java‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,13 @@ public void testExceptionsFromHasNext() {
802802
checkExceptionFromHasNext("{\"unique\":true,\"name\":\"jUnitTestIndexNeg005\", \"fields\":[{\"order\":-1,\"path\":\"city.zip\"}");
803803
}
804804

805+
public void testEOFFromHasNext() {
806+
checkExceptionFromHasNext("{ \"d\" : 1 } 2 3 4");
807+
checkExceptionFromHasNext("[ {\"d\" : 1 }] 2 3 4");
808+
checkExceptionFromHasNext("1 2 3 4");
809+
checkExceptionFromHasNext("null 2 3 4");
810+
}
811+
805812
public void testExceptionsFromNext() {
806813
checkExceptionFromNext("{\"name\" : fal");
807814
checkExceptionFromNext("{\"name\" : nu");
@@ -841,4 +848,4 @@ private void checkExceptionFromNext(String input) {
841848
}
842849
fail();
843850
}
844-
}
851+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /