Skip to content

Commit

Permalink
Use deprecated handler from SolrCLI
Browse files Browse the repository at this point in the history
  • Loading branch information
janhoy committed Dec 6, 2024
1 parent 1b7b183 commit e273913
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
2 changes: 1 addition & 1 deletion solr/core/src/java/org/apache/solr/cli/SolrCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ public static String getOptionWithDeprecatedAndDefault(

// TODO: SOLR-17429 - remove the custom logic when Commons CLI is upgraded and
// makes stderr the default, or makes Option.toDeprecatedString() public.
private static void deprecatedHandlerStdErr(Option o) {
public static void deprecatedHandlerStdErr(Option o) {
// Deprecated options without a description act as "stealth" options
if (o.isDeprecated() && !o.getDeprecated().getDescription().isBlank()) {
final StringBuilder buf =
Expand Down
11 changes: 1 addition & 10 deletions solr/core/src/java/org/apache/solr/cloud/ZkCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
Expand Down Expand Up @@ -163,7 +162,7 @@ public static void main(String[] args)
CommandLineParser parser =
DefaultParser.builder()
// Override deprecation handler since the default one prints to stdout, we want stderr
.setDeprecatedHandler(o -> System.err.println(toDeprecatedString(o)))
.setDeprecatedHandler(SolrCLI::deprecatedHandlerStdErr)
.build();
Options options = new Options();

Expand Down Expand Up @@ -722,14 +721,6 @@ public static void main(String[] args)
}
}

// TODO: Override toDeprecatedString since Option.toDeprecatedString has private visibility in
// Commons-CLI
private static String toDeprecatedString(Option o) {
return o.isDeprecated()
? String.format(Locale.ROOT, "Option '%s': %s", o.getArgName(), o.getDeprecated())
: "";
}

private static boolean shouldCompressData(
byte[] data, String path, int minStateByteLenForCompression) {
if (path.endsWith("state.json")
Expand Down

0 comments on commit e273913

Please sign in to comment.