Properly close() the FileReader for Config
MODIFY
agent-bootstrap/src/main/java/io/opentelemetry/auto/config/Config.java
agent-bootstrap/src/main/java/io/opentelemetry/auto/config/Config.java
@@ -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;

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

Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>