From 7f29bc7956b98b9bb3cc0db9fbfd9f8f8f4ff268 Mon Sep 17 00:00:00 2001 From: Marek Posolda Date: Mon, 23 Mar 2026 23:16:40 +0100 Subject: [PATCH] Make sure to close FileInputStream in Util.readProperties(File) in SSSD code closes #40753 Signed-off-by: mposolda --- .../src/main/java/org/freedesktop/dbus/utils/Util.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/federation/sssd/src/main/java/org/freedesktop/dbus/utils/Util.java b/federation/sssd/src/main/java/org/freedesktop/dbus/utils/Util.java index 8251a379156..089cb1043d1 100644 --- a/federation/sssd/src/main/java/org/freedesktop/dbus/utils/Util.java +++ b/federation/sssd/src/main/java/org/freedesktop/dbus/utils/Util.java @@ -70,10 +70,12 @@ public final class Util { */ public static Properties readProperties(File _file) { if (_file.exists()) { - try { - return readProperties(new FileInputStream(_file)); + try (FileInputStream fle = new FileInputStream(_file)) { + return readProperties(fle); } catch (FileNotFoundException _ex) { LOGGER.info("Could not load properties file: " + _file, _ex); + } catch (IOException e) { + LOGGER.warn("Could not read properties: ", e); } } return null; @@ -84,7 +86,7 @@ public final class Util { * @param _stream input stream providing property file content * @return properties object/null */ - public static Properties readProperties(InputStream _stream) { + private static Properties readProperties(InputStream _stream) { Properties props = new Properties(); if (_stream == null) { return null; @@ -94,7 +96,7 @@ public final class Util { props.load(_stream); return props; } catch (IOException | NumberFormatException _ex) { - LOGGER.warn("Could not properties: ", _ex); + LOGGER.warn("Could not read properties: ", _ex); } return null; }