You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "AndreyBozhko (via GitHub)" <gi...@apache.org> on 2025/02/21 18:08:51 UTC
[PR] SOLR-8282: Switch CoreContainer#getSolrHome to return Path instead of String [solr]
AndreyBozhko opened a new pull request, #3204:
URL: https://github.com/apache/solr/pull/3204
https://issues.apache.org/jira/browse/SOLR-8282
<!--
_(If you are a project committer then you may remove some/all of the following template.)_
Before creating a pull request, please file an issue in the ASF Jira system for Solr:
* https://issues.apache.org/jira/projects/SOLR
For something minor (i.e. that wouldn't be worth putting in release notes), you can skip JIRA.
To create a Jira issue, you will need to create an account there first.
The title of the PR should reference the Jira issue number in the form:
* SOLR-####: <short description of problem or changes>
SOLR must be fully capitalized. A short description helps people scanning pull requests for items they can work on.
Properly referencing the issue in the title ensures that Jira is correctly updated with code review comments and commits. -->
# Description
This is only a part of SOLR-8282, prompted by the comment here: https://github.com/apache/solr/pull/3146#discussion_r1935722062
Please provide a short description of the changes you're making with this pull request.
# Solution
Updated public getter to return Path.
Suggested review order commit-by-commit.
# Tests
Existing tests.
# Checklist
Please review the following and check all that apply:
- [x] I have reviewed the guidelines for [How to Contribute](https://github.com/apache/solr/blob/main/CONTRIBUTING.md) and my code conforms to the standards described there to the best of my ability.
- [ ] I have created a Jira issue and added the issue ID to my pull request title.
- [x] I have given Solr maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended, not available for branches on forks living under an organisation)
- [x] I have developed this patch against the `main` branch.
- [x] I have run `./gradlew check`.
- [ ] I have added tests for my changes.
- [ ] I have added documentation for the [Reference Guide](https://github.com/apache/solr/tree/main/solr/solr-ref-guide)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-8282: Switch CoreContainer#getSolrHome to return Path instead of String [solr]
Posted by "AndreyBozhko (via GitHub)" <gi...@apache.org>.
AndreyBozhko commented on code in PR #3204:
URL: https://github.com/apache/solr/pull/3204#discussion_r1966067522
##########
solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java:
##########
@@ -80,7 +80,7 @@ public void testCustomUlogDir() throws Exception {
cores.getAllowPaths().add(dataDir.toPath()); // Allow the test dir
cores.getAllowPaths().add(newCoreInstanceDir.toPath()); // Allow the test dir
- File instanceDir = new File(cores.getSolrHome());
+ File instanceDir = cores.getSolrHome().toFile();
Review Comment:
Yes, it's possible to replace FileUtils here with `org.apache.commons.io.file.PathUtils`. For now I changed just the callsites for CoreContainer#getSolrHome, to simplify the review.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-8282: Switch CoreContainer#getSolrHome to return Path instead of String [solr]
Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #3204:
URL: https://github.com/apache/solr/pull/3204#discussion_r1966069823
##########
solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java:
##########
@@ -145,7 +145,7 @@ public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throw
rsp.add("zkHost", getCoreContainer(req).getZkController().getZkServerAddress());
}
if (cc != null) {
- rsp.add("solr_home", cc.getSolrHome());
+ rsp.add("solr_home", cc.getSolrHome().toString());
Review Comment:
;-)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-16903: Switch CoreContainer#getSolrHome to return Path instead of String [solr]
Posted by "AndreyBozhko (via GitHub)" <gi...@apache.org>.
AndreyBozhko commented on code in PR #3204:
URL: https://github.com/apache/solr/pull/3204#discussion_r1967834442
##########
solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java:
##########
@@ -145,7 +145,7 @@ public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throw
rsp.add("zkHost", getCoreContainer(req).getZkController().getZkServerAddress());
}
if (cc != null) {
- rsp.add("solr_home", cc.getSolrHome());
+ rsp.add("solr_home", cc.getSolrHome().toString());
Review Comment:
Makes sense - the JavaBinCodec looks to be doing the same thing. https://github.com/apache/solr/blob/76c09a35dba42913a6bcb281b52b00f87564624a/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java#L411-L413
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-8282: Switch CoreContainer#getSolrHome to return Path instead of String [solr]
Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #3204:
URL: https://github.com/apache/solr/pull/3204#discussion_r1965995115
##########
solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java:
##########
@@ -80,7 +80,7 @@ public void testCustomUlogDir() throws Exception {
cores.getAllowPaths().add(dataDir.toPath()); // Allow the test dir
cores.getAllowPaths().add(newCoreInstanceDir.toPath()); // Allow the test dir
- File instanceDir = new File(cores.getSolrHome());
+ File instanceDir = cores.getSolrHome().toFile();
Review Comment:
Could we stay in path land if we change FileUtils?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-16903: Switch CoreContainer#getSolrHome to return Path instead of String [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley merged PR #3204:
URL: https://github.com/apache/solr/pull/3204
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-16903: Switch CoreContainer#getSolrHome to return Path instead of String [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #3204:
URL: https://github.com/apache/solr/pull/3204#issuecomment-2678884231
I plan to merge this tonight; it's very straightforward
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-8282: Switch CoreContainer#getSolrHome to return Path instead of String [solr]
Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on code in PR #3204:
URL: https://github.com/apache/solr/pull/3204#discussion_r1966047995
##########
solr/core/src/java/org/apache/solr/core/ZkContainer.java:
##########
@@ -87,7 +87,7 @@ public void initZooKeeper(final CoreContainer cc, CloudConfig config) {
// TODO: remove after updating to an slf4j based zookeeper
System.setProperty("zookeeper.jmx.log4j.disable", "true");
- String solrHome = cc.getSolrHome();
+ String solrHome = cc.getSolrHome().toString();
Review Comment:
If I am reading this right, this can be removed and the call below doesn't need `Paths.get()` but can just be `cc.getSolrHome().resolve(zoo_data).toString()`
##########
solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java:
##########
@@ -145,7 +145,7 @@ public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throw
rsp.add("zkHost", getCoreContainer(req).getZkController().getZkServerAddress());
}
if (cc != null) {
- rsp.add("solr_home", cc.getSolrHome());
+ rsp.add("solr_home", cc.getSolrHome().toString());
Review Comment:
`toString()` might not be necessary here because of this [textWriter](https://github.com/apache/solr/blob/d2fdb16a78195e5eb40caf48761afeb1bce041ee/solr/solrj/src/java/org/apache/solr/common/util/TextWriter.java#L78) I think but this probably needs to be confirmed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-8282: Switch CoreContainer#getSolrHome to return Path instead of String [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #3204:
URL: https://github.com/apache/solr/pull/3204#issuecomment-2676562570
Excellent! I love how focused this PR is.
Can you please edit the JIRA association to be [SOLR-16903](https://issues.apache.org/jira/browse/SOLR-16903) -- PR title & CHANGES.txt. There's already a CHANGES.txt entries for 16903. Needn't specify every single API endpoint / category since by 10.0, I think we hope we can basically say, "Changed all Java APIs using File to NIO Path" and not get into further details.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-8282: Switch CoreContainer#getSolrHome to return Path instead of String [solr]
Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on code in PR #3204:
URL: https://github.com/apache/solr/pull/3204#discussion_r1966062008
##########
solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java:
##########
@@ -145,7 +145,7 @@ public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throw
rsp.add("zkHost", getCoreContainer(req).getZkController().getZkServerAddress());
}
if (cc != null) {
- rsp.add("solr_home", cc.getSolrHome());
+ rsp.add("solr_home", cc.getSolrHome().toString());
Review Comment:
But also that TextWriter is doing a `.toAbsolutePath()` which doesn't seem right to me. If SolrHome is always absolute this wouldn't matter, if it's relative, then possible the response would change. Maybe ignoring what I said above is the safest option.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-8282: Switch CoreContainer#getSolrHome to return Path instead of String [solr]
Posted by "AndreyBozhko (via GitHub)" <gi...@apache.org>.
AndreyBozhko commented on code in PR #3204:
URL: https://github.com/apache/solr/pull/3204#discussion_r1966064254
##########
solr/core/src/java/org/apache/solr/core/ZkContainer.java:
##########
@@ -87,7 +87,7 @@ public void initZooKeeper(final CoreContainer cc, CloudConfig config) {
// TODO: remove after updating to an slf4j based zookeeper
System.setProperty("zookeeper.jmx.log4j.disable", "true");
- String solrHome = cc.getSolrHome();
+ String solrHome = cc.getSolrHome().toString();
Review Comment:
Thanks, updated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-16903: Switch CoreContainer#getSolrHome to return Path instead of String [solr]
Posted by "AndreyBozhko (via GitHub)" <gi...@apache.org>.
AndreyBozhko commented on PR #3204:
URL: https://github.com/apache/solr/pull/3204#issuecomment-2676985912
Sounds good, I updated the PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-16903: Switch CoreContainer#getSolrHome to return Path instead of String [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #3204:
URL: https://github.com/apache/solr/pull/3204#discussion_r1966904872
##########
solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java:
##########
@@ -145,7 +145,7 @@ public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throw
rsp.add("zkHost", getCoreContainer(req).getZkController().getZkServerAddress());
}
if (cc != null) {
- rsp.add("solr_home", cc.getSolrHome());
+ rsp.add("solr_home", cc.getSolrHome().toString());
Review Comment:
Good eye! I agree with removing toString here. Whether toAbsolutePath should be called or not is another question from this PR; I'm ambivalent.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-8282: Switch CoreContainer#getSolrHome to return Path instead of String [solr]
Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #3204:
URL: https://github.com/apache/solr/pull/3204#discussion_r1965992291
##########
solr/core/src/java/org/apache/solr/core/ZkContainer.java:
##########
@@ -87,7 +87,7 @@ public void initZooKeeper(final CoreContainer cc, CloudConfig config) {
// TODO: remove after updating to an slf4j based zookeeper
System.setProperty("zookeeper.jmx.log4j.disable", "true");
- String solrHome = cc.getSolrHome();
+ String solrHome = cc.getSolrHome().toString();
Review Comment:
Just want to confirm that we are still stuck with String here? I see below the `Paths.get`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org