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 2021/01/21 16:20:37 UTC
[commons-io] branch master updated: Add @SuppressWarnings and
rename private var.
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 883b5c8 Add @SuppressWarnings and rename private var.
883b5c8 is described below
commit 883b5c88458b0aa5afae811b8409bc1ba90f0637
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Jan 21 11:20:31 2021 -0500
Add @SuppressWarnings and rename private var.
---
.../org/apache/commons/io/input/DemuxInputStream.java | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/apache/commons/io/input/DemuxInputStream.java b/src/main/java/org/apache/commons/io/input/DemuxInputStream.java
index f3bf092..c92471d 100644
--- a/src/main/java/org/apache/commons/io/input/DemuxInputStream.java
+++ b/src/main/java/org/apache/commons/io/input/DemuxInputStream.java
@@ -27,7 +27,7 @@ import org.apache.commons.io.IOUtils;
* Data written to this stream is forwarded to a stream that has been associated with this thread.
*/
public class DemuxInputStream extends InputStream {
- private final InheritableThreadLocal<InputStream> inputStream = new InheritableThreadLocal<>();
+ private final InheritableThreadLocal<InputStream> inputStreamLocal = new InheritableThreadLocal<>();
/**
* Binds the specified stream to the current thread.
@@ -36,8 +36,8 @@ public class DemuxInputStream extends InputStream {
* @return the InputStream that was previously active
*/
public InputStream bindStream(final InputStream input) {
- final InputStream oldValue = inputStream.get();
- inputStream.set(input);
+ final InputStream oldValue = inputStreamLocal.get();
+ inputStreamLocal.set(input);
return oldValue;
}
@@ -46,9 +46,10 @@ public class DemuxInputStream extends InputStream {
*
* @throws IOException if an error occurs
*/
+ @SuppressWarnings("resource") // we actually close the stream here
@Override
public void close() throws IOException {
- IOUtils.close(inputStream.get());
+ IOUtils.close(inputStreamLocal.get());
}
/**
@@ -57,11 +58,12 @@ public class DemuxInputStream extends InputStream {
* @return the byte read from stream
* @throws IOException if an error occurs
*/
+ @SuppressWarnings("resource")
@Override
public int read() throws IOException {
- final InputStream input = inputStream.get();
- if (null != input) {
- return input.read();
+ final InputStream inputStream = inputStreamLocal.get();
+ if (null != inputStream) {
+ return inputStream.read();
}
return EOF;
}