Skip to content

Commit b2165b7

Browse files
committed
Fix FindBUgs.
1 parent 4f43616 commit b2165b7

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,11 @@ public static InputStream toBufferedInputStream(final InputStream input)
146146
* @since 2.5
147147
*/
148148
public static InputStream toBufferedInputStream(final InputStream input, final int size)
149-
throws IOException {
150-
// It does not matter if a ByteArrayOutputStream is not closed as close() is a no-op
151-
@SuppressWarnings("resource")
152-
final ByteArrayOutputStream output = new ByteArrayOutputStream(size);
153-
output.write(input);
154-
return output.toInputStream();
149+
throws IOException {
150+
try (final ByteArrayOutputStream output = new ByteArrayOutputStream(size)) {
151+
output.write(input);
152+
return output.toInputStream();
153+
}
155154
}
156155

157156
@Override

0 commit comments

Comments
 (0)