Skip to content

Commit 71afb4a

Browse files
committed
Removed references to deprecated Commons CLI APIs
1 parent f2e7ad0 commit 71afb4a

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/CommandLineUtils.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@
2727
package org.apache.hc.core5.benchmark;
2828

2929
import java.io.File;
30+
import java.io.IOException;
3031
import java.net.URI;
3132
import java.net.URISyntaxException;
3233

3334
import org.apache.commons.cli.CommandLine;
34-
import org.apache.commons.cli.HelpFormatter;
3535
import org.apache.commons.cli.Option;
3636
import org.apache.commons.cli.Options;
37+
import org.apache.commons.cli.help.HelpFormatter;
3738
import org.apache.hc.core5.http.ContentType;
3839
import org.apache.hc.core5.http.Method;
3940
import org.apache.hc.core5.util.TimeValue;
@@ -246,14 +247,23 @@ public static BenchmarkConfig parseCommandLine(final CommandLine cmd) {
246247
return builder.build();
247248
}
248249

249-
static void showUsage(final Options options) {
250-
final HelpFormatter formatter = new HelpFormatter();
251-
formatter.printHelp("HttpBenchmark [options] [http://]hostname[:port]/path?query", options);
250+
static void showUsage(final Options options) throws IOException {
251+
final HelpFormatter formatter = HelpFormatter.builder().get();
252+
formatter.printHelp(
253+
"HttpBenchmark [http://]hostname[:port]/path?query",
254+
null,
255+
options,
256+
null,
257+
true);
252258
}
253259

254260
static void printError(final String msg) {
255261
System.err.println(msg);
256-
showUsage(getOptions());
262+
try {
263+
showUsage(getOptions());
264+
} catch (final IOException ex) {
265+
System.err.println(ex.getMessage());
266+
}
257267
System.exit(-1);
258268
}
259269
}

0 commit comments

Comments
 (0)