Skip to content

Commit c51b7e3

Browse files
committed
Merge branch '3.0' into 3.x
2 parents 20a002e + 5b08924 commit c51b7e3

File tree

4 files changed

+26
-19
lines changed

4 files changed

+26
-19
lines changed

release-notes/VERSION-2.x

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ a pure JSON library.
1818

1919
#363: UTF-8 decoding should fail on Surrogate characters (0xD800 - 0xDFFF)
2020
(fix by @cowtowncoder, w/ Claude code)
21-
#1180: `JsonLocation` off for unrecognized tokens
21+
#708: `FilteringParserDelegate` cannot deserialize empty list
22+
(reported by @xiazuojie)
2223
(fix by @cowtowncoder, w/ Claude code)
24+
#1180: `JsonLocation` off for unrecognized tokens
25+
(fix by @cowtowncoder, w/ Claude code)
2326
#1470: Add method `copyCurrentStructureExact()` to `JsonGenerator`
2427
(contributed by Lars H)
2528
#1477: Add `JsonGenerator.has(StreamWriteCapability)` convenience method

src/main/java/tools/jackson/core/filter/FilteringParserDelegate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ protected final JsonToken _nextToken2() throws JacksonException
619619
boolean returnEnd = _headContext.isStartHandled();
620620
f = _headContext.getFilter();
621621
if ((f != null) && (f != TokenFilter.INCLUDE_ALL)) {
622-
boolean includeEmpty = f.includeEmptyArray(_headContext.hasCurrentName());
622+
boolean includeEmpty = f.includeEmptyObject(_headContext.hasCurrentName());
623623
f.filterFinishObject();
624624
if (includeEmpty) {
625625
return _nextBuffered(_headContext);

src/test/java/tools/jackson/core/unittest/tofix/ParserFilterEmpty708Test.java renamed to src/test/java/tools/jackson/core/unittest/filter/ParserFilterEmpty708Test.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package tools.jackson.core.unittest.tofix;
1+
package tools.jackson.core.unittest.filter;
22

33
import org.junit.jupiter.api.Test;
44

@@ -10,7 +10,6 @@
1010
import tools.jackson.core.filter.TokenFilter;
1111
import tools.jackson.core.filter.TokenFilter.Inclusion;
1212
import tools.jackson.core.json.JsonFactory;
13-
import tools.jackson.core.testutil.failure.JacksonTestFailureExpected;
1413
import tools.jackson.core.unittest.*;
1514

1615
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -22,7 +21,17 @@ class ParserFilterEmpty708Test extends JacksonCoreTestBase
2221
static class IncludeAllFilter extends TokenFilter {
2322
@Override
2423
public TokenFilter includeProperty(String name) {
25-
return this;
24+
return TokenFilter.INCLUDE_ALL;
25+
}
26+
27+
@Override
28+
public boolean includeEmptyArray(boolean contentsFiltered) {
29+
return true;
30+
}
31+
32+
@Override
33+
public boolean includeEmptyObject(boolean contentsFiltered) {
34+
return true;
2635
}
2736
}
2837

@@ -35,12 +44,10 @@ public TokenFilter includeProperty(String name) {
3544
private final JsonFactory JSON_F = newStreamFactory();
3645

3746
// [core#708]
38-
@JacksonTestFailureExpected
3947
@Test
4048
void emptyArray() throws Exception
4149
{
4250
final String json = "[ ]";
43-
// should become: {"value":12}
4451
JsonParser p0 = _createParser(JSON_F, json);
4552
JsonParser p = new FilteringParserDelegate(p0,
4653
new IncludeAllFilter(),
@@ -55,12 +62,10 @@ void emptyArray() throws Exception
5562
}
5663

5764
// [core#708]
58-
@JacksonTestFailureExpected
5965
@Test
6066
void emptyObject() throws Exception
6167
{
6268
final String json = "{ }";
63-
// should become: {"value":12}
6469
JsonParser p0 = _createParser(JSON_F, json);
6570
JsonParser p = new FilteringParserDelegate(p0,
6671
new IncludeAllFilter(),

src/test/java/tools/jackson/core/unittest/tofix/async/AsyncTokenErrorTest.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class AsyncTokenErrorTest extends AsyncTestBase
1616
private final JsonFactory JSON_F = newStreamFactory();
1717

1818
@Test
19-
void invalidKeywordsStartOk() throws Exception
19+
void invalidKeywordsAfterMatching1st() throws Exception
2020
{
2121
_doTestInvalidKeyword("nul");
2222
_doTestInvalidKeyword("nulla");
@@ -29,28 +29,28 @@ void invalidKeywordsStartOk() throws Exception
2929
_doTestInvalidKeyword("trueenough");
3030
}
3131

32-
@JacksonTestFailureExpected
3332
@Test
34-
void invalidKeywordsStartFail() throws Exception
33+
void invalidKeywordsAfterNonMatching1st() throws Exception
3534
{
3635
_doTestInvalidKeyword("Null");
3736
_doTestInvalidKeyword("False");
3837
_doTestInvalidKeyword("C");
38+
_doTestInvalidKeyword("xy");
3939
}
4040

4141
private void _doTestInvalidKeyword(String value)
4242
{
43+
final String EXP_MAIN = "Unrecognized token '"+value+"'";
44+
final String EXP_ALT = "Unexpected character ('"+value.charAt(0)+"' (code";
45+
4346
String doc = "{ \"key1\" : "+value+" }";
44-
// Note that depending on parser impl, we may
45-
// get the exception early or late...
4647
try (AsyncReaderWrapper p = _createParser(doc)) {
4748
assertToken(JsonToken.START_OBJECT, p.nextToken());
4849
assertToken(JsonToken.PROPERTY_NAME, p.nextToken());
4950
p.nextToken();
5051
fail("Expected an exception for malformed value keyword");
5152
} catch (StreamReadException jex) {
52-
verifyException(jex, "Unrecognized token");
53-
verifyException(jex, value);
53+
verifyException(jex, EXP_MAIN, EXP_ALT);
5454
}
5555

5656
// Try as root-level value as well:
@@ -59,11 +59,10 @@ private void _doTestInvalidKeyword(String value)
5959
p.nextToken();
6060
fail("Expected an exception for malformed value keyword");
6161
} catch (StreamReadException jex) {
62-
verifyException(jex, "Unrecognized token");
63-
verifyException(jex, value);
62+
verifyException(jex, EXP_MAIN, EXP_ALT);
6463
}
6564
}
66-
65+
6766
@JacksonTestFailureExpected
6867
@Test
6968
void mangledRootInts() throws Exception

0 commit comments

Comments
 (0)