Skip to content

Commit

Permalink
Complete #609 fix for 2.11(.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Apr 16, 2020
1 parent 12d03af commit 95cb57c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
4 changes: 2 additions & 2 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ JSON library.
#587: Add JsonGenerator#writeNumber(char[], int, int) method
(contributed by Volkan Y)
#606: Do not clear aggregated contents of `TextBuffer` when `releaseBuffers()` called
#609: `FilteringGeneratorDelegate` does not handle `writeString(Reader, int)`
(reported by Volkan Y)

2.10.4 (not yet released)

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

2.10.3 (03-Mar-2020)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,11 +500,9 @@ public void writeString(Reader reader, int len) throws IOException {
if (state != TokenFilter.INCLUDE_ALL) {
// [core#609]: do need to implement, but with 2.10.x TokenFilter no
// useful method to call so will be mostly unfiltered
/*
if (!state.includeString("")) {
if (!state.includeString(reader, len)) {
return;
}
*/
}
_checkParentPath();
}
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/fasterxml/jackson/core/filter/TokenFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,21 @@ public boolean includeString(String value) {
return _includeScalar();
}

/**
* Call made to verify whether leaf-level
* "streaming" String value
* should be included in output or not.
*<p>
* NOTE: note that any reads from passed in {@code Reader} may lead
* to actual loss of content to write; typically method should not
* access content passed via this method.
*
* @since 2.11
*/
public boolean includeString(java.io.Reader r, int maxLen) {
return _includeScalar();
}

/**
* Call made to verify whether leaf-level
* <code>int</code> value
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.fasterxml.jackson.failing;
package com.fasterxml.jackson.core.filter;

import java.io.*;

Expand All @@ -8,7 +8,7 @@
import com.fasterxml.jackson.core.util.JsonGeneratorDelegate;

// for [core#609]
public class TokenFilter609Test
public class GeneratorFiltering609Test
extends com.fasterxml.jackson.core.BaseTest
{
static class NullExcludingTokenFilter extends TokenFilter {
Expand Down Expand Up @@ -41,7 +41,6 @@ public void writeString(String text) throws IOException {
} else if (maxStringLength <= 0 || maxStringLength >= text.length()) {
super.writeString(text);
} else {
// super.writeString(text.substring(0, maxStringLength));
StringReader textReader = new StringReader(text);
super.writeString(textReader, maxStringLength);
}
Expand Down

0 comments on commit 95cb57c

Please sign in to comment.