Only create wrapper set once.
MODIFY
src/main/java/org/apache/commons/io/input/AbstractCharacterFilterReader.java
src/main/java/org/apache/commons/io/input/AbstractCharacterFilterReader.java
*/
public abstract class AbstractCharacterFilterReader extends FilterReader {
- private static final IntPredicate SKIP_NONE = ch -> false;
+ protected static final IntPredicate SKIP_NONE = ch -> false;
private final IntPredicate skip;

MODIFY
src/main/java/org/apache/commons/io/input/CharacterSetFilterReader.java
src/main/java/org/apache/commons/io/input/CharacterSetFilterReader.java
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
+import java.util.function.IntPredicate;
/**
* A filter reader that removes a given set of characters represented as {@code int} code points, handy to remove known
*/
public class CharacterSetFilterReader extends AbstractCharacterFilterReader {
+ private static IntPredicate toIntPredicate(final Set<Integer> skip) {
+ if (skip == null) {
+ return SKIP_NONE;
+ }
+ final Set<Integer> unmodifiableSet = Collections.unmodifiableSet(skip);
+ return c -> unmodifiableSet.contains(Integer.valueOf(c));
+ }
+
/**
* Constructs a new reader.
*
@@ -50,7 +59,7 @@ public CharacterSetFilterReader(final Reader reader, final Integer... skip) {
* @param skip the set of characters to filter out.
*/
public CharacterSetFilterReader(final Reader reader, final Set<Integer> skip) {
- super(reader, c -> skip == null ? null : Collections.unmodifiableSet(skip).contains(Integer.valueOf(c)));
+ super(reader, toIntPredicate(skip));
}
}

Only create wrapper set once.