From d9a9f7f35e663896995625a44dc80d6c6c37cf9a Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 22 Mar 2021 10:39:04 +0000 Subject: cid#1474333 Resource leak on an exceptional path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I84ae0f078fade95f6219b2e949e60fb1d6b60f75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112877 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- qadevOOo/runner/helper/CfgParser.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'qadevOOo') diff --git a/qadevOOo/runner/helper/CfgParser.java b/qadevOOo/runner/helper/CfgParser.java index b65697e9b6c8..a93e725fd99b 100644 --- a/qadevOOo/runner/helper/CfgParser.java +++ b/qadevOOo/runner/helper/CfgParser.java @@ -91,9 +91,12 @@ public class CfgParser try { FileInputStream propFile = new FileInputStream(name); - prop.load(propFile); - System.out.println("Parsing properties from " + name); - propFile.close(); + try { + prop.load(propFile); + System.out.println("Parsing properties from " + name); + } finally { + propFile.close(); + } } catch (Exception e) { @@ -105,7 +108,11 @@ public class CfgParser System.out.println("Parsing properties from " + name); java.net.URLConnection connection = url.openConnection(); java.io.InputStream in = connection.getInputStream(); - prop.load(in); + try { + prop.load(in); + } finally { + in.close(); + } } } catch (Exception ex) -- cgit