Skip to content

Commit 0fbae67

Browse files
committed
Keep members sorted
1 parent a229f90 commit 0fbae67

3 files changed

Lines changed: 20 additions & 20 deletions

File tree

src/main/java/org/apache/commons/io/input/BoundedInputStream.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,6 @@ private BoundedInputStream(final InputStream inputStream, final long maxCount, f
164164
this.propagateClose = propagateClose;
165165
}
166166

167-
private CountingInputStream getCountingInputStream() {
168-
return (CountingInputStream) in;
169-
}
170-
171167
/**
172168
* {@inheritDoc}
173169
*/
@@ -203,6 +199,10 @@ public long getCount() {
203199
return getCountingInputStream().getByteCount();
204200
}
205201

202+
private CountingInputStream getCountingInputStream() {
203+
return (CountingInputStream) in;
204+
}
205+
206206
/**
207207
* Gets the max count of bytes to read.
208208
*

src/main/java/org/apache/commons/io/input/ThrottledInputStream.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ private ThrottledInputStream(final InputStream proxy, final long maxBytesPerSeco
118118
this.maxBytesPerSecond = maxBytesPerSecond;
119119
}
120120

121+
@Override
122+
protected void beforeRead(final int n) throws IOException {
123+
throttle();
124+
}
125+
121126
/**
122127
* Gets the read-rate from this stream, since creation. Calculated as bytesRead/elapsedTimeSinceStart.
123128
*
@@ -144,11 +149,6 @@ Duration getTotalSleepDuration() {
144149
return totalSleepDuration;
145150
}
146151

147-
@Override
148-
protected void beforeRead(final int n) throws IOException {
149-
throttle();
150-
}
151-
152152
private void throttle() throws InterruptedIOException {
153153
final long sleepMillis = getSleepMillis();
154154
if (sleepMillis > 0) {

src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,17 @@ public void testBufferedRead_UTF8() throws IOException {
192192
testBufferedRead(TEST_STRING, UTF_8);
193193
}
194194

195+
@Test
196+
public void testCharacterCodingException() throws IOException {
197+
final Charset charset = StandardCharsets.US_ASCII;
198+
final CharSequenceInputStream in = CharSequenceInputStream.builder()
199+
.setCharsetEncoder(charset.newEncoder().onUnmappableCharacter(CodingErrorAction.REPORT))
200+
.setCharSequence("\u0080")
201+
.get();
202+
assertEquals(0, in.available());
203+
assertThrows(UnmappableCharacterException.class, in::read);
204+
}
205+
195206
private void testCharsetMismatchInfiniteLoop(final String csName) throws IOException {
196207
// Input is UTF-8 bytes: 0xE0 0xB2 0xA0
197208
final char[] inputChars = { (char) 0xE0, (char) 0xB2, (char) 0xA0 };
@@ -527,15 +538,4 @@ public void testSkip_RequiredCharsets(final String csName) throws Exception {
527538
assertEquals(-1, r.read(), csName);
528539
}
529540
}
530-
531-
@Test
532-
public void testCharacterCodingException() throws IOException {
533-
final Charset charset = StandardCharsets.US_ASCII;
534-
final CharSequenceInputStream in = CharSequenceInputStream.builder()
535-
.setCharsetEncoder(charset.newEncoder().onUnmappableCharacter(CodingErrorAction.REPORT))
536-
.setCharSequence("\u0080")
537-
.get();
538-
assertEquals(0, in.available());
539-
assertThrows(UnmappableCharacterException.class, in::read);
540-
}
541541
}

0 commit comments

Comments
 (0)