finally block to close input stream

This commit is contained in:
Tebbe Ubben 2019-05-01 16:25:41 +02:00
parent de64b1ecf7
commit a2d108b4c4

View file

@ -165,15 +165,18 @@ public class SignatureVerifier extends PluginBase implements ConstraintsInterfac
} }
private String readInputStream(InputStream inputStream) throws IOException { private String readInputStream(InputStream inputStream) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream(); try {
byte[] buffer = new byte[1024]; ByteArrayOutputStream baos = new ByteArrayOutputStream();
int read; byte[] buffer = new byte[1024];
while ((read = inputStream.read(buffer)) != -1) { int read;
baos.write(buffer, 0, read); while ((read = inputStream.read(buffer)) != -1) {
baos.write(buffer, 0, read);
}
baos.flush();
return new String(baos.toByteArray(), StandardCharsets.UTF_8);
} finally {
inputStream.close();
} }
baos.flush();
inputStream.close();
return new String(baos.toByteArray(), StandardCharsets.UTF_8);
} }
private String readRevokedCertsInAssets() throws IOException { private String readRevokedCertsInAssets() throws IOException {