Tidy up java code in o.a.s.filestore package - #4657
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors parts of org.apache.solr.filestore to align better with Java style expectations and to remove code that appears unused, primarily in DistribFileStore.
Changes:
- Removed unused/disconnected code paths and variables in
DistribFileStore(including an unused in-memory map and related code). - Simplified
CryptoKeysvariable initialization in validation paths (removing redundant= null). - Cleaned up some minor formatting/comment issues while adjusting the file distribution logic.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
solr/core/src/java/org/apache/solr/filestore/FileStoreUtils.java |
Minor cleanup in signature validation setup (CryptoKeys initialization). |
solr/core/src/java/org/apache/solr/filestore/DistribFileStore.java |
Removes dead/unused code and refactors parts of distribution/fetch logic; some leftover logic needs follow-up. |
solr/core/src/java/org/apache/solr/filestore/ClusterFileStore.java |
Minor cleanup in signature validation setup (CryptoKeys initialization). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .submit( | ||
| () -> { | ||
| try { | ||
| Thread.sleep(10 * 1000); | ||
| } finally { | ||
| tmpFiles.remove(info.path); | ||
| } | ||
| Thread.sleep(10 * 1000); | ||
| return null; | ||
| }); |
There was a problem hiding this comment.
Okay, I looked at this, and yeah, it turns out we had an extra try/catch loop as well...
| if (i == FETCHFROM_SRC) { | ||
| // This is just an optimization | ||
| // at this point a bunch of nodes are already downloading from me | ||
| // at this point a bunch of nodes are already downloading from me. |
There was a problem hiding this comment.
humm... I don't totally feel comfortable changing these comments up, as the code isn't super clear to me in the first place.
| this.path = path; | ||
| } | ||
|
|
There was a problem hiding this comment.
That's correct. The two buffers are now unused and can be removed.
| int FETCHFROM_SRC = 50; | ||
| String myNodeName = coreContainer.getZkController().getNodeName(); | ||
| String getFrom = ""; | ||
| try { |
There was a problem hiding this comment.
@psalagnac can you eyeball one more cahnge? So I looked at what copilot said, and then I eneded up removing the entire outer try loop, and then the:
coreContainer
.getUpdateShardHandler()
.getUpdateExecutor()
.submit(
because at this point, there isn't anything left. Does this all make sense? I'm always nervous around threds ;-)
There was a problem hiding this comment.
This looks good to me.
Now that tmpFiles is removed, this async task does nothing else than sleeping.
I'm good with this removal.
| this.path = path; | ||
| } | ||
|
|
There was a problem hiding this comment.
That's correct. The two buffers are now unused and can be removed.
| int FETCHFROM_SRC = 50; | ||
| String myNodeName = coreContainer.getZkController().getNodeName(); | ||
| String getFrom = ""; | ||
| try { |
There was a problem hiding this comment.
This looks good to me.
Now that tmpFiles is removed, this async task does nothing else than sleeping.
I'm good with this removal.
…java Co-authored-by: Pierre Salagnac <pierre.salagnac@gmail.com>
Description
Reviewing code in the org.apache.solr.filestore package for potential improvements.
Solution
Mostly driven by what IntelliJ is suggesting are weaknesses. Specifically, found what looks like dead code in the DistribFileStore.
Tests
Same tests. And Claude review.