Properly close() the FileReader for Config (#210)

Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
This commit is contained in:
Trask Stalnaker 2020-03-05 16:03:43 -08:00 committed by GitHub
parent 2f1b802aad
commit 7370202340
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -622,14 +622,23 @@ public class Config {
return properties;
}
FileReader fileReader = null;
try {
final FileReader fileReader = new FileReader(configurationFile);
fileReader = new FileReader(configurationFile);
properties.load(fileReader);
} catch (final FileNotFoundException fnf) {
log.error("Configuration file '{}' not found.", configurationFilePath);
} catch (final IOException ioe) {
log.error(
"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;