You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/01/01 12:42:37 UTC
(commons-io) branch master updated: Keep members sorted
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git
The following commit(s) were added to refs/heads/master by this push:
new 0fbae67f Keep members sorted
0fbae67f is described below
commit 0fbae67fba0a39cf0d96712b71b3afcc713003bd
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Jan 1 07:42:32 2024 -0500
Keep members sorted
---
.../commons/io/input/BoundedInputStream.java | 8 ++++----
.../commons/io/input/ThrottledInputStream.java | 10 +++++-----
.../io/input/CharSequenceInputStreamTest.java | 22 +++++++++++-----------
3 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/src/main/java/org/apache/commons/io/input/BoundedInputStream.java b/src/main/java/org/apache/commons/io/input/BoundedInputStream.java
index 8ea82200..f3d7e6f1 100644
--- a/src/main/java/org/apache/commons/io/input/BoundedInputStream.java
+++ b/src/main/java/org/apache/commons/io/input/BoundedInputStream.java
@@ -164,10 +164,6 @@ public class BoundedInputStream extends ProxyInputStream {
this.propagateClose = propagateClose;
}
- private CountingInputStream getCountingInputStream() {
- return (CountingInputStream) in;
- }
-
/**
* {@inheritDoc}
*/
@@ -203,6 +199,10 @@ public class BoundedInputStream extends ProxyInputStream {
return getCountingInputStream().getByteCount();
}
+ private CountingInputStream getCountingInputStream() {
+ return (CountingInputStream) in;
+ }
+
/**
* Gets the max count of bytes to read.
*
diff --git a/src/main/java/org/apache/commons/io/input/ThrottledInputStream.java b/src/main/java/org/apache/commons/io/input/ThrottledInputStream.java
index a995878a..b6b464ec 100644
--- a/src/main/java/org/apache/commons/io/input/ThrottledInputStream.java
+++ b/src/main/java/org/apache/commons/io/input/ThrottledInputStream.java
@@ -118,6 +118,11 @@ public final class ThrottledInputStream extends CountingInputStream {
this.maxBytesPerSecond = maxBytesPerSecond;
}
+ @Override
+ protected void beforeRead(final int n) throws IOException {
+ throttle();
+ }
+
/**
* Gets the read-rate from this stream, since creation. Calculated as bytesRead/elapsedTimeSinceStart.
*
@@ -144,11 +149,6 @@ public final class ThrottledInputStream extends CountingInputStream {
return totalSleepDuration;
}
- @Override
- protected void beforeRead(final int n) throws IOException {
- throttle();
- }
-
private void throttle() throws InterruptedIOException {
final long sleepMillis = getSleepMillis();
if (sleepMillis > 0) {
diff --git a/src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java b/src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java
index 2c2827d7..7c87f3c2 100644
--- a/src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java
@@ -192,6 +192,17 @@ public class CharSequenceInputStreamTest {
testBufferedRead(TEST_STRING, UTF_8);
}
+ @Test
+ public void testCharacterCodingException() throws IOException {
+ final Charset charset = StandardCharsets.US_ASCII;
+ final CharSequenceInputStream in = CharSequenceInputStream.builder()
+ .setCharsetEncoder(charset.newEncoder().onUnmappableCharacter(CodingErrorAction.REPORT))
+ .setCharSequence("\u0080")
+ .get();
+ assertEquals(0, in.available());
+ assertThrows(UnmappableCharacterException.class, in::read);
+ }
+
private void testCharsetMismatchInfiniteLoop(final String csName) throws IOException {
// Input is UTF-8 bytes: 0xE0 0xB2 0xA0
final char[] inputChars = { (char) 0xE0, (char) 0xB2, (char) 0xA0 };
@@ -527,15 +538,4 @@ public class CharSequenceInputStreamTest {
assertEquals(-1, r.read(), csName);
}
}
-
- @Test
- public void testCharacterCodingException() throws IOException {
- final Charset charset = StandardCharsets.US_ASCII;
- final CharSequenceInputStream in = CharSequenceInputStream.builder()
- .setCharsetEncoder(charset.newEncoder().onUnmappableCharacter(CodingErrorAction.REPORT))
- .setCharSequence("\u0080")
- .get();
- assertEquals(0, in.available());
- assertThrows(UnmappableCharacterException.class, in::read);
- }
}