Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOLR-17586 Print zkcli.sh deprecation msg to stderr (9x) #2896

Merged
merged 3 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading