Skip to content

Commit 1f0fc84

Browse files
committed
post-review: properties loading
1 parent bb74e6e commit 1f0fc84

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

jmx-scraper/src/main/java/io/opentelemetry/contrib/jmxscraper/JmxScraper.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,28 +81,32 @@ static JmxScraperConfig createConfigFromArgs(List<String> args)
8181
throw new ArgumentsParsingException("unexpected first argument must be '" + CONFIG_ARG + "'");
8282
}
8383

84-
Properties loadedProperties = new Properties();
84+
Properties properties;
8585
String path = args.get(1);
8686
if (path.trim().equals("-")) {
87-
loadPropertiesFromStdin(loadedProperties);
87+
properties = loadPropertiesFromStdin();
8888
} else {
89-
loadPropertiesFromPath(loadedProperties, path);
89+
properties = loadPropertiesFromPath(path);
9090
}
91-
return new JmxScraperConfigFactory().createConfig(loadedProperties);
91+
return new JmxScraperConfigFactory().createConfig(properties);
9292
}
9393

94-
private static void loadPropertiesFromStdin(Properties props) throws ConfigurationException {
94+
private static Properties loadPropertiesFromStdin() throws ConfigurationException {
95+
Properties properties = new Properties();
9596
try (InputStream is = new DataInputStream(System.in)) {
96-
props.load(is);
97+
properties.load(is);
98+
return properties;
9799
} catch (IOException e) {
98100
throw new ConfigurationException("Failed to read config properties from stdin", e);
99101
}
100102
}
101103

102-
private static void loadPropertiesFromPath(Properties props, String path)
104+
private static Properties loadPropertiesFromPath(String path)
103105
throws ConfigurationException {
106+
Properties properties = new Properties();
104107
try (InputStream is = Files.newInputStream(Paths.get(path))) {
105-
props.load(is);
108+
properties.load(is);
109+
return properties;
106110
} catch (IOException e) {
107111
throw new ConfigurationException("Failed to read config properties file: '" + path + "'", e);
108112
}

jmx-scraper/src/main/java/io/opentelemetry/contrib/jmxscraper/config/ConfigurationException.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package io.opentelemetry.contrib.jmxscraper.config;
77

88
public class ConfigurationException extends Exception {
9-
private static final long serialVersionUID = 0L;
109

1110
public ConfigurationException(String message, Throwable cause) {
1211
super(message, cause);

0 commit comments

Comments
 (0)