@@ -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 }
0 commit comments