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 2020/05/24 17:58:24 UTC

[commons-io] branch master updated: Fix FindBUgs.

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 b2165b7  Fix FindBUgs.
b2165b7 is described below

commit b2165b7b8888be8500768b6e27e090f89a621510
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun May 24 13:58:20 2020 -0400

    Fix FindBUgs.
---
 .../org/apache/commons/io/output/ByteArrayOutputStream.java   | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java b/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java
index 8c3ff8d..33ea5a4 100644
--- a/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java
+++ b/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java
@@ -146,12 +146,11 @@ public class ByteArrayOutputStream extends AbstractByteArrayOutputStream {
      * @since 2.5
      */
     public static InputStream toBufferedInputStream(final InputStream input, final int size)
-            throws IOException {
-        // It does not matter if a ByteArrayOutputStream is not closed as close() is a no-op
-        @SuppressWarnings("resource")
-        final ByteArrayOutputStream output = new ByteArrayOutputStream(size);
-        output.write(input);
-        return output.toInputStream();
+        throws IOException {
+        try (final ByteArrayOutputStream output = new ByteArrayOutputStream(size)) {
+            output.write(input);
+            return output.toInputStream();
+        }
     }
 
     @Override