Skip to content

Commit 95cb57c

Browse files
committed
Complete #609 fix for 2.11(.0)
1 parent 12d03af commit 95cb57c

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

release-notes/VERSION-2.x

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ JSON library.
2323
#587: Add JsonGenerator#writeNumber(char[], int, int) method
2424
(contributed by Volkan Y)
2525
#606: Do not clear aggregated contents of `TextBuffer` when `releaseBuffers()` called
26+
#609: `FilteringGeneratorDelegate` does not handle `writeString(Reader, int)`
27+
(reported by Volkan Y)
2628

2729
2.10.4 (not yet released)
2830

2931
#605: Handle case when system property access is restricted
3032
(reported by rhernandez35@github)
31-
#609: (partial fix) `FilteringGeneratorDelegate` does not handle `writeString(Reader, int)`
32-
(reported by Volkan Y)
3333

3434
2.10.3 (03-Mar-2020)
3535

src/main/java/com/fasterxml/jackson/core/filter/FilteringGeneratorDelegate.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -500,11 +500,9 @@ public void writeString(Reader reader, int len) throws IOException {
500500
if (state != TokenFilter.INCLUDE_ALL) {
501501
// [core#609]: do need to implement, but with 2.10.x TokenFilter no
502502
// useful method to call so will be mostly unfiltered
503-
/*
504-
if (!state.includeString("")) {
503+
if (!state.includeString(reader, len)) {
505504
return;
506505
}
507-
*/
508506
}
509507
_checkParentPath();
510508
}

src/main/java/com/fasterxml/jackson/core/filter/TokenFilter.java

+15
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,21 @@ public boolean includeString(String value) {
243243
return _includeScalar();
244244
}
245245

246+
/**
247+
* Call made to verify whether leaf-level
248+
* "streaming" String value
249+
* should be included in output or not.
250+
*<p>
251+
* NOTE: note that any reads from passed in {@code Reader} may lead
252+
* to actual loss of content to write; typically method should not
253+
* access content passed via this method.
254+
*
255+
* @since 2.11
256+
*/
257+
public boolean includeString(java.io.Reader r, int maxLen) {
258+
return _includeScalar();
259+
}
260+
246261
/**
247262
* Call made to verify whether leaf-level
248263
* <code>int</code> value

src/test/java/com/fasterxml/jackson/failing/TokenFilter609Test.java renamed to src/test/java/com/fasterxml/jackson/core/filter/GeneratorFiltering609Test.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.fasterxml.jackson.failing;
1+
package com.fasterxml.jackson.core.filter;
22

33
import java.io.*;
44

@@ -8,7 +8,7 @@
88
import com.fasterxml.jackson.core.util.JsonGeneratorDelegate;
99

1010
// for [core#609]
11-
public class TokenFilter609Test
11+
public class GeneratorFiltering609Test
1212
extends com.fasterxml.jackson.core.BaseTest
1313
{
1414
static class NullExcludingTokenFilter extends TokenFilter {
@@ -41,7 +41,6 @@ public void writeString(String text) throws IOException {
4141
} else if (maxStringLength <= 0 || maxStringLength >= text.length()) {
4242
super.writeString(text);
4343
} else {
44-
// super.writeString(text.substring(0, maxStringLength));
4544
StringReader textReader = new StringReader(text);
4645
super.writeString(textReader, maxStringLength);
4746
}

0 commit comments

Comments
 (0)