-
-
Notifications
You must be signed in to change notification settings - Fork 816
Closed
Description
There seems to be a bug in FilteringParserDelegate
that specifically manifests when trying to filter out arrays. Here's a test that reproduces the behavior (can be added to BasicParserFilteringTest
):
public void testExcludeArrays() throws Exception
{
class NoArraysFilter extends TokenFilter
{
@Override
public TokenFilter filterStartArray() {
return null;
}
}
String jsonString = aposToQuotes("{'a':123,'array':[1,2]}");
JsonParser p0 = JSON_F.createParser(jsonString);
FilteringParserDelegate p = new FilteringParserDelegate(p0,
new NoArraysFilter(),
true, // includePath
true // multipleMatches
);
String result = readAndWrite(JSON_F, p);
assertEquals(aposToQuotes("{'a':123}"), result);
assertEquals(1, p.getMatchCount());
}
This test fails with:
junit.framework.ComparisonFailure:
Expected :{"a":123}
Actual :{"a"}
I discovered this bug while adding test coverage for #573. However, I confirmed that the bug exists in jackson-core versions 2.8.9, 2.9.10, 2.10.5, and 2.11.3 (and therefore wasn't introduced in #573).
No one has complained yet, and a quick GitHub search suggests there isn't much code in the wild (if any) doing filterStartArray() { return null; }
so I don't think it's a high priority to fix this. I mainly just wanted to log this issue so that I can link to it (above the commented out unit test)
Metadata
Metadata
Assignees
Labels
No labels