mirror of
https://github.com/keycloak/keycloak.git
synced 2026-06-08 16:42:13 -04:00
Make sure to close FileInputStream in Util.readProperties(File) in SSSD code
closes #40753 Signed-off-by: mposolda <mposolda@gmail.com>
This commit is contained in:
parent
ba7f7cee24
commit
7f29bc7956
1 changed files with 6 additions and 4 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue