summaryrefslogtreecommitdiff
path: root/qadevOOo
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-10-18 09:14:53 +0100
committerCaolán McNamara <caolanm@redhat.com>2019-10-18 12:31:40 +0200
commiteffba035c0c04cce6dff3817d546f5c163a1a4f0 (patch)
tree6a992dc068f69128d96fce280581aeefc244bc5e /qadevOOo
parent9ab51f7aead713516b7e9a30aa64190d80517cbc (diff)
cid#1448528 Resource leak on an exceptional path
Change-Id: I75f6b5529d01d226164f35bf4db81370c27f12a9 Reviewed-on: https://gerrit.libreoffice.org/81021 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'qadevOOo')
-rw-r--r--qadevOOo/runner/util/DesktopTools.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/qadevOOo/runner/util/DesktopTools.java b/qadevOOo/runner/util/DesktopTools.java
index 1bac437a491a..88ea2c897503 100644
--- a/qadevOOo/runner/util/DesktopTools.java
+++ b/qadevOOo/runner/util/DesktopTools.java
@@ -271,14 +271,17 @@ public class DesktopTools
try {
final InputStream inputFile = new BufferedInputStream(
new FileInputStream(filePath));
- final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
- final byte[] byteBuffer = new byte[4096];
- int byteBufferLength = 0;
- while ((byteBufferLength = inputFile.read(byteBuffer)) > 0)
- bytes.write(byteBuffer, 0, byteBufferLength);
- inputFile.close();
- inputStream = new ByteArrayToXInputStreamAdapter(
+ try {
+ final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ final byte[] byteBuffer = new byte[4096];
+ int byteBufferLength = 0;
+ while ((byteBufferLength = inputFile.read(byteBuffer)) > 0)
+ bytes.write(byteBuffer, 0, byteBufferLength);
+ inputStream = new ByteArrayToXInputStreamAdapter(
bytes.toByteArray());
+ } finally {
+ inputFile.close();
+ }
} catch (java.io.IOException e) {
e.printStackTrace();
}