Update org.apache.solr.cli classes to not use deprecated methods.#4142
Open
epugh wants to merge 7 commits intoapache:mainfrom
Open
Update org.apache.solr.cli classes to not use deprecated methods.#4142epugh wants to merge 7 commits intoapache:mainfrom
epugh wants to merge 7 commits intoapache:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request updates the org.apache.solr.cli classes to eliminate the use of deprecated methods from Commons CLI and Commons Exec libraries. As part of this modernization effort, the PR also addresses various lint warnings and performs code cleanup including:
- Updating
Option.builder().build()toOption.builder().get()across all CLI tool classes - Replacing
DefaultExecutorconstructor withDefaultExecutor.Builder<>().get() - Removing deprecated
cloudSolrClient.connect()calls - Converting a class to a record (
SolrProcessManager.SolrProcess) - Modernizing string operations (
length() > 0→isEmpty()) - Improving thread interruption handling (
Thread.interrupted()→Thread.currentThread().interrupt()) - Converting string concatenation to text blocks
- Various test cleanup and simplifications
Changes:
- Commons CLI deprecated method replacements (
.build()→.get()for Option builders) - Commons Exec deprecated method replacements (DefaultExecutor constructor → builder pattern)
- Code modernization (records, text blocks, improved interrupt handling)
- Test cleanup (removed unused variables, simplified code, fixed typos)
Reviewed changes
Copilot reviewed 40 out of 40 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| ZkSubcommandsTest.java | Test cleanup: removed unused variables and imports, updated ACL provider setup |
| TestSolrCLIRunExample.java | Updated to use RandomizingCloudHttp2SolrClientBuilder, modernized thread handling, fixed variable initialization |
| TestExportTool.java | Removed unnecessary string concatenation in assertions |
| StreamToolTest.java | Added IOException to method signature |
| SolrProcessManagerTest.java | Updated method calls to use record accessors (getPort() → port()), improved comment grammar |
| PostToolTest.java | Added try-with-resources for BufferedWriter, converted to text block |
| CLITestHelper.java | Added assert statements for null checks |
| ApiToolTest.java | Removed unused Exception from method signature |
| Multiple Tool classes | Updated Option.builder().build() to .get() throughout |
| SolrCLI.java | Updated HelpFormatter API usage, modernized DefaultParser usage |
| RunExampleTool.java | Converted JSON strings to text blocks, improved interrupt handling, fixed executor instantiation |
| SolrProcessManager.java | Converted SolrProcess class to record, modernized stream operations |
| StatusTool.java | Updated Option builders, simplified return statement |
| AuthTool.java | Added block scope to switch cases, converted strings to text blocks |
| AssertTool.java | Renamed and inverted logic of isSolrRunningOn → isSolrStoppedOn for clarity |
| Various tools | Removed deprecated cloudSolrClient.connect() calls, improved thread sleep patterns |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
|
Here is what the formatting of the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The org.apache.solr.cli.* classes are using various deprecated methods from Commons CLI and Commons Exec libraries.
This PR updates them. In the process I also took what I've learned in Java coding, and went through and cleaned up various lint warnings.
I also got a NICE clean up in
ZkSubcommandsTest, there was a bunch of cruft in it.Nothing here is user facing.
One thing I did not tackle, is we need to flip our
assertsEquals... We doassertEquals(actual,expected)but we should be doingassertEquals(expected,actuals).Solution
Make edits, rerun the tests.
Tests
Just existing tests.