[Libreoffice-commits] core.git: qadevOOo/runner
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Fri Oct 18 10:33:03 UTC 2019
qadevOOo/runner/util/DesktopTools.java | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
New commits:
commit effba035c0c04cce6dff3817d546f5c163a1a4f0
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Oct 18 09:14:53 2019 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Oct 18 12:31:40 2019 +0200
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 at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
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();
}
More information about the Libreoffice-commits
mailing list