diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 1073e4ca13..1dcc7df241 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -21,6 +21,8 @@ JSON library. (reported by Chris R) #1003: Add FastDoubleParser section to `NOTICE` #1014: Increase default max allowed String value length from 5 megs to 20 megs +#1023: Problem with `FilteringGeneratorDelegate` wrt `TokenFilter.Inclusion.INCLUDE_NON_NULL` + (reported by @honhimW) 2.15.0 (23-Apr-2023) diff --git a/src/main/java/com/fasterxml/jackson/core/filter/FilteringGeneratorDelegate.java b/src/main/java/com/fasterxml/jackson/core/filter/FilteringGeneratorDelegate.java index 6e19705bd4..4b49596e63 100644 --- a/src/main/java/com/fasterxml/jackson/core/filter/FilteringGeneratorDelegate.java +++ b/src/main/java/com/fasterxml/jackson/core/filter/FilteringGeneratorDelegate.java @@ -254,6 +254,10 @@ public void writeStartArray(Object forValue) throws IOException _checkParentPath(); _filterContext = _filterContext.createChildArrayContext(_itemFilter, true); delegate.writeStartArray(forValue); + } else if (_itemFilter != null && _inclusion == Inclusion.INCLUDE_NON_NULL) { + _checkParentPath(false /* isMatch */); + _filterContext = _filterContext.createChildArrayContext(_itemFilter, true); + delegate.writeStartArray(forValue); } else { _filterContext = _filterContext.createChildArrayContext(_itemFilter, false); } @@ -283,6 +287,10 @@ public void writeStartArray(Object forValue, int size) throws IOException _checkParentPath(); _filterContext = _filterContext.createChildArrayContext(_itemFilter, true); delegate.writeStartArray(forValue, size); + } else if (_itemFilter != null && _inclusion == Inclusion.INCLUDE_NON_NULL) { + _checkParentPath(false /* isMatch */); + _filterContext = _filterContext.createChildArrayContext(_itemFilter, true); + delegate.writeStartArray(forValue, size); } else { _filterContext = _filterContext.createChildArrayContext(_itemFilter, false); }