@@ -83,7 +83,7 @@ public static void main(String[] args) {
8383 } catch (ConfigurationException e ) {
8484 logger .log (Level .SEVERE , "invalid configuration " , e );
8585 System .exit (1 );
86- } catch (ArgumentsParsingException e ) {
86+ } catch (InvalidArgumentException e ) {
8787 logger .log (Level .SEVERE , "invalid configuration provided through arguments" , e );
8888 logger .info (
8989 "Usage: java -jar <path_to_jmxscraper.jar> "
@@ -116,18 +116,18 @@ static void propagateToSystemProperties(Properties properties) {
116116 *
117117 * @param args application commandline arguments
118118 */
119- static Properties parseArgs (List <String > args ) throws ArgumentsParsingException {
119+ static Properties parseArgs (List <String > args ) throws InvalidArgumentException {
120120
121121 if (args .isEmpty ()) {
122122 // empty properties from stdin or external file
123123 // config could still be provided through JVM system properties
124124 return new Properties ();
125125 }
126126 if (args .size () != 2 ) {
127- throw new ArgumentsParsingException ("Exactly two arguments expected, got " + args .size ());
127+ throw new InvalidArgumentException ("Exactly two arguments expected, got " + args .size ());
128128 }
129129 if (!args .get (0 ).equalsIgnoreCase (CONFIG_ARG )) {
130- throw new ArgumentsParsingException ("Unexpected first argument must be '" + CONFIG_ARG + "'" );
130+ throw new InvalidArgumentException ("Unexpected first argument must be '" + CONFIG_ARG + "'" );
131131 }
132132
133133 String path = args .get (1 );
@@ -138,28 +138,30 @@ static Properties parseArgs(List<String> args) throws ArgumentsParsingException
138138 }
139139 }
140140
141- private static Properties loadPropertiesFromStdin () throws ArgumentsParsingException {
141+ private static Properties loadPropertiesFromStdin () throws InvalidArgumentException {
142142 Properties properties = new Properties ();
143143 try (InputStream is = new DataInputStream (System .in )) {
144144 properties .load (is );
145145 return properties ;
146146 } catch (IOException e ) {
147- throw new ArgumentsParsingException ("Failed to read config properties from stdin" , e );
147+ // an IO error is very unlikely here
148+ throw new InvalidArgumentException ("Failed to read config properties from stdin" , e );
148149 }
149150 }
150151
151- private static Properties loadPropertiesFromPath (String path ) throws ArgumentsParsingException {
152+ private static Properties loadPropertiesFromPath (String path ) throws InvalidArgumentException {
152153 Properties properties = new Properties ();
153154 try (InputStream is = Files .newInputStream (Paths .get (path ))) {
154155 properties .load (is );
155156 return properties ;
156157 } catch (IOException e ) {
157- throw new ArgumentsParsingException (
158+ throw new InvalidArgumentException (
158159 "Failed to read config properties file: '" + path + "'" , e );
159160 }
160161 }
161162
162- JmxScraper (JmxConnectorBuilder client , JmxMetricInsight service , JmxScraperConfig config ) {
163+ private JmxScraper (
164+ JmxConnectorBuilder client , JmxMetricInsight service , JmxScraperConfig config ) {
163165 this .client = client ;
164166 this .service = service ;
165167 this .config = config ;
0 commit comments