Skip to content

Commit f902268

Browse files
committed
Add ProxyInputStream.unwrap()
1 parent 46cef6b commit f902268

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ The <action> type attribute can be add,update,fix,remove.
129129
<action dev="ggregory" type="add" due-to="Gary Gregory">Add ChecksumInputStream and test #548.</action>
130130
<action dev="ggregory" type="add" due-to="Gary Gregory">Add AbstractStreamBuilder.getReader().</action>
131131
<action dev="ggregory" type="add" due-to="Gary Gregory">Add Maven property project.build.outputTimestamp for build reproducibility.</action>
132+
<action dev="ggregory" type="add" due-to="Gary Gregory">Add ProxyInputStream.unwrap().</action>
132133
<!-- UPDATE -->
133134
<action dev="ggregory" type="update" due-to="Gary Gregory">Bump commons.bytebuddy.version from 1.14.10 to 1.14.11 #534.</action>
134135
<action dev="ggregory" type="update" due-to="Gary Gregory">Bump org.apache.commons:commons-parent from 65 to 66.</action>

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,4 +252,15 @@ public long skip(final long n) throws IOException {
252252
}
253253
}
254254

255+
/**
256+
* Unwraps this instance by returning the underlying InputStream.
257+
* <p>
258+
* Use with caution; useful to query the underlying InputStream.
259+
* </p>
260+
* @return the underlying InputStream.
261+
* @since 2.16.0
262+
*/
263+
public InputStream unwrap() {
264+
return in;
265+
}
255266
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
2121
import static org.junit.jupiter.api.Assertions.assertEquals;
22+
import static org.junit.jupiter.api.Assertions.assertSame;
2223

2324
import java.io.ByteArrayInputStream;
2425
import java.io.IOException;
@@ -147,6 +148,7 @@ public void testReadArrayPartial() throws IOException {
147148
public void testReadEof() throws Exception {
148149
final ByteArrayInputStream proxy = new ByteArrayInputStream(new byte[2]);
149150
try (ProxyInputStream inputStream = new ProxyInputStreamFixture(proxy)) {
151+
assertSame(proxy, inputStream.unwrap());
150152
int found = inputStream.read();
151153
assertEquals(0, found);
152154
found = inputStream.read();

0 commit comments

Comments
 (0)