Properly close() the FileReader for Config (#210)
Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
This commit is contained in:
parent
2f1b802aad
commit
7370202340
|
@ -622,14 +622,23 @@ public class Config {
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FileReader fileReader = null;
|
||||||
try {
|
try {
|
||||||
final FileReader fileReader = new FileReader(configurationFile);
|
fileReader = new FileReader(configurationFile);
|
||||||
properties.load(fileReader);
|
properties.load(fileReader);
|
||||||
} catch (final FileNotFoundException fnf) {
|
} catch (final FileNotFoundException fnf) {
|
||||||
log.error("Configuration file '{}' not found.", configurationFilePath);
|
log.error("Configuration file '{}' not found.", configurationFilePath);
|
||||||
} catch (final IOException ioe) {
|
} catch (final IOException ioe) {
|
||||||
log.error(
|
log.error(
|
||||||
"Configuration file '{}' cannot be accessed or correctly parsed.", configurationFilePath);
|
"Configuration file '{}' cannot be accessed or correctly parsed.", configurationFilePath);
|
||||||
|
} finally {
|
||||||
|
if (fileReader != null) {
|
||||||
|
try {
|
||||||
|
fileReader.close();
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
log.error("Configuration file '{}' was not closed correctly.", configurationFilePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return properties;
|
return properties;
|
||||||
|
|
Loading…
Reference in New Issue