Skip to content

Commit f78f7a2

Browse files
committed
Add ProxyInputStream.setReference(InputStream), was package-private
setIn(InputStream)
1 parent 2077753 commit f78f7a2

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ The <action> type attribute can be add,update,fix,remove.
5858
<action dev="ggregory" type="add" due-to="Gary Gregory">Add AbstractByteArrayOutputStream.write(CharSequence, Charset).</action>
5959
<action dev="ggregory" type="add" due-to="Gary Gregory">Add AbstractByteArrayOutputStream.write(byte[]).</action>
6060
<action dev="ggregory" type="add" due-to="Gary Gregory">Add RandomAccessFileOutputStream.getRandomAccessFile().</action>
61+
<action dev="ggregory" type="add" due-to="Gary Gregory">Add ProxyInputStream.setReference(InputStream), was package-private setIn(InputStream).</action>
6162
<!-- UPDATE -->
6263
<action dev="ggregory" type="update" due-to="Dependabot, Gary Gregory">Bump commons.bytebuddy.version from 1.15.10 to 1.15.11 #710.</action>
6364
</release>

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,15 @@ public synchronized void reset() throws IOException {
367367
}
368368

369369
/**
370-
* Package-private for testing.
370+
* Sets the underlying input stream.
371371
*
372372
* @param in The input stream to set in {@link java.io.FilterInputStream#in}.
373+
* @return this instance.
374+
* @since 2.19.0
373375
*/
374-
void setIn(final InputStream in) {
376+
public ProxyInputStream setReference(final InputStream in) {
375377
this.in = in;
378+
return this;
376379
}
377380

378381
/**

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ public void testAvailableAll() throws IOException {
145145
public void testAvailableNull() throws IOException {
146146
try (T inputStream = createFixture(null)) {
147147
assertEquals(0, inputStream.available());
148-
inputStream.setIn(createFixture());
148+
inputStream.setReference(createFixture());
149149
assertEquals(3, inputStream.available());
150150
IOUtils.toByteArray(inputStream);
151151
assertEquals(0, inputStream.available());
152-
inputStream.setIn(null);
152+
inputStream.setReference(null);
153153
assertEquals(0, inputStream.available());
154154
}
155155
}
@@ -162,11 +162,11 @@ protected void testEos(final T inputStream) {
162162
public void testMarkOnNull() throws IOException {
163163
try (T inputStream = createFixture(null)) {
164164
inputStream.mark(1);
165-
inputStream.setIn(createFixture());
165+
inputStream.setReference(createFixture());
166166
inputStream.mark(1);
167167
IOUtils.toByteArray(inputStream);
168168
inputStream.mark(1);
169-
inputStream.setIn(null);
169+
inputStream.setReference(null);
170170
inputStream.mark(1);
171171
}
172172
}
@@ -192,7 +192,7 @@ public void testMarkSupportedAfterClose() throws IOException {
192192
public void testMarkSupportedOnNull() throws IOException {
193193
try (ProxyInputStream fixture = createFixture()) {
194194
assertMarkSupportedEquals(fixture);
195-
fixture.setIn(null);
195+
fixture.setReference(null);
196196
assertFalse(fixture.markSupported());
197197
}
198198
}

0 commit comments

Comments
 (0)