Conversation
epugh
left a comment
There was a problem hiding this comment.
I love that this removes more lines than it adds!
LGTM.
| // there. | ||
| if (!configSetPath.endsWith("/conf")) { | ||
| configSetPath = Paths.get(configSetPath.toString(), "conf"); | ||
| configSetPath = configSetPath.resolve("conf"); |
|
|
||
| public static Path getConfigSetsDir(Path solrInstallDir) { | ||
| Path configSetsPath = Paths.get("server/solr/configsets/"); | ||
| Path configSetsPath = Path.of("server/solr/configsets/"); |
There was a problem hiding this comment.
Don't need "Path.of" here at all; pass this slashy string to resolve
|
|
||
| Path managedSchemaPath = | ||
| Paths.get(loader.getConfigPath().toString(), managedSchemaResourceName); | ||
| Path managedSchemaPath = loader.getConfigPath().resolve(managedSchemaResourceName); |
| // Ensure that empty files don't become directories (SOLR-11198) | ||
|
|
||
| Path emptyFile = Paths.get(tmp.toAbsolutePath().toString(), "conf", "stopwords", "emptyfile"); | ||
| Path emptyFile = tmp.resolve("conf").resolve("stopwords").resolve("emptyfile").toAbsolutePath(); |
There was a problem hiding this comment.
please also drop the toAbsolutePath calls on temp dir resolution, as the path is already absolute. Just touch the lines you modify.
| final String standardOutput2 = runtime.getOutput(); | ||
| assertTrue(standardOutput2.startsWith("Copying from 'zk:/getNode'")); | ||
| byte[] fileBytes = Files.readAllBytes(Paths.get(localFile.getAbsolutePath())); | ||
| byte[] fileBytes = Files.readAllBytes(Path.of(localFile.getAbsolutePath())); |
There was a problem hiding this comment.
no point in getAbsolutePath
| // reconsistutes the path from string so we have to go the string route here as well... | ||
| final Path workDir = Paths.get(createTempDir().toAbsolutePath().toString()); | ||
| // reconstitutes the path from string so we have to go the string route here as well... | ||
| final Path workDir = Path.of(createTempDir().toAbsolutePath().toString()); |
There was a problem hiding this comment.
no need to go to from Path to String then Path
There was a problem hiding this comment.
I tried that initially and that led to broken tests, so I suppose the warning in the comment above still holds...
There was a problem hiding this comment.
Oh right (and "duh" on me for not reading the comment :shame:).
In the other PR, I like the different approach we're taking of unwrapping the custom Path, which is more plainly apparent and also searchable.
| @Test | ||
| public void testReloadFromPersistentStorage() throws IOException { | ||
| SolrResourceLoader loader = new SolrResourceLoader(Paths.get("./")); | ||
| SolrResourceLoader loader = new SolrResourceLoader(Path.of("./")); |
There was a problem hiding this comment.
Any place we use "." or "./", it's the same as the empty string, which I think is more canonical. Maybe a separate PR.
|
Cool! Yeah we are going to be stepping on each other toes here... My PR just had a merge conflict which I need to fix. Going to fix it today or tomorrow and hopefully we can merge it soon. Happy to help with merge conflicts on this PR when it arises. Or anything else in here. |
|
Thanks - I agree that it makes total sense to wait with this PR. |
* add Paths.get to forbidden apis * replace Paths.get with Path.of Co-authored-by: Andrey Bozhko <abozhko@apple.com>
There was a problem hiding this comment.
The use of Path.of in uploadToZK file is an absolute tragedy. There are lots of nice utility methods in this class that take a Path argument (yay), then convert to a String (boo), then pass to Path.of (nausea), thus assuming it's a file system path. So much for uploading a configSet from a ZIP/JAR.
Not introduced by you of course, but I thought you might care. @AndreyBozhko
Description
Replace Paths#get with Path#of, and add Paths#get to forbidden apis.
Also cleaned up some of the Path -> String -> Path conversions that seemed unnecessary.
Prompted by the comment here: #3146 (comment)
Checklist
Please review the following and check all that apply:
mainbranch../gradlew check.