Fix FindBUgs.
@@ -147,12 +147,11 @@ public static InputStream toBufferedInputStream(final InputStream input)
*/
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);
+ try (final ByteArrayOutputStream output = new ByteArrayOutputStream(size)) {
output.write(input);
return output.toInputStream();
}
+ }
@Override
public synchronized InputStream toInputStream() {
