Skip to content

Commit

Permalink
SOLR-17586 Print zkcli.sh deprecation msg to stderr (9x) (#2896)
Browse files Browse the repository at this point in the history
  • Loading branch information
janhoy authored Dec 7, 2024
1 parent f492e24 commit 0a6eac4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ Bug Fixes

* SOLR-17574: Fix AllowListUrlChecker when liveNodes changes. Remove ClusterState.getHostAllowList (Bruno Roustant, David Smiley)

* SOLR-17586: Print zkcli.sh deprecation msg to stderr, which fixes Solr Operator upload of security.json to zookeeper (Jan Høydahl)

Dependency Upgrades
---------------------
(No changes)
Expand Down
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
8 changes: 6 additions & 2 deletions solr/core/src/java/org/apache/solr/cloud/ZkCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
import javax.xml.parsers.ParserConfigurationException;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.DeprecatedAttributes;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
import org.apache.solr.cli.CLIO;
import org.apache.solr.cli.SolrCLI;
import org.apache.solr.client.solrj.impl.SolrZkClientTimeout;
Expand Down Expand Up @@ -159,7 +159,11 @@ public static void main(String[] args)
SAXException,
KeeperException {

CommandLineParser parser = new PosixParser();
CommandLineParser parser =
DefaultParser.builder()
// Override deprecation handler since the default one prints to stdout, we want stderr
.setDeprecatedHandler(SolrCLI::deprecatedHandlerStdErr)
.build();
Options options = new Options();

Option cmdOption =
Expand Down
2 changes: 1 addition & 1 deletion solr/server/scripts/cloud-scripts/zkcli.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

echo "WARNING: The zkcli.sh script has been deprecated in favour of the bin/solr equivalent commands."
>&2 echo "WARNING: The zkcli.sh script has been deprecated in favour of the bin/solr equivalent commands."

# You can override pass the following parameters to this script:
#
Expand Down

0 comments on commit 0a6eac4

Please sign in to comment.