Reuse own API.
MODIFY
src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java
src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java
import java.util.Set;
import org.apache.commons.io.Charsets;
+import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
@@ -178,8 +179,7 @@ private void testCharsetMismatchInfiniteLoop(final String csName) throws IOExcep
final char[] inputChars = { (char) 0xE0, (char) 0xB2, (char) 0xA0 };
final Charset charset = Charset.forName(csName); // infinite loop for US-ASCII, UTF-8 OK
try (InputStream stream = new CharSequenceInputStream(new String(inputChars), charset, 512)) {
- while (stream.read() != -1) {
- }
+ IOUtils.toCharArray(stream, charset);
}
}

MODIFY
src/test/java/org/apache/commons/io/input/ReaderInputStreamTest.java
src/test/java/org/apache/commons/io/input/ReaderInputStreamTest.java
import java.util.Random;
import java.util.concurrent.TimeUnit;
+import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
@@ -59,8 +60,7 @@ public void testCharsetMismatchInfiniteLoop() throws IOException {
// Charset charset = Charset.forName("UTF-8"); // works
final Charset charset = StandardCharsets.US_ASCII; // infinite loop
try (ReaderInputStream stream = new ReaderInputStream(new CharArrayReader(inputChars), charset)) {
- while (stream.read() != -1) {
- }
+ IOUtils.toCharArray(stream, charset);
}
}

Reuse own API.