-
Notifications
You must be signed in to change notification settings - Fork 711
SOLR-16903: Make java.io.File a forbidden API #3321
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this!
I see you also got in some needless getAbsolutePath removals as well.
tmpConfigDir.toFile().deleteOnExit(); | ||
PathUtils.deleteOnExit(tmpConfigDir); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createTempDir self cleans up per test. It's javadocs say so.
@@ -1565,7 +1565,7 @@ public void testDeleteErrors() throws Exception { | |||
final SolrClient solrClient = getHttpSolrClient(baseUrl); | |||
final Path configDir = getFile("solr").resolve("configsets/configset-2/conf"); | |||
final Path tmpConfigDir = createTempDir(); | |||
tmpConfigDir.toFile().deleteOnExit(); | |||
PathUtils.deleteOnExit(tmpConfigDir); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createTempDir self cleans up per test. It's javadocs say so.
@@ -205,7 +205,7 @@ private void setupBaseConfigSet(String baseConfigSetName, Map<String, String> ol | |||
throws Exception { | |||
final Path configDir = getFile("solr").resolve("configsets/configset-2/conf"); | |||
final Path tmpConfigDir = createTempDir(); | |||
tmpConfigDir.toFile().deleteOnExit(); | |||
PathUtils.deleteOnExit(tmpConfigDir); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createTempDir self cleans up per test. It's javadocs say so.
@@ -105,8 +106,7 @@ public static void beforeClass() throws Exception { | |||
wrongPemFilePath = JWT_TEST_PATH().resolve("security").resolve("jwt_plugin_idp_wrongcert.pem"); | |||
|
|||
Path tempDir = Files.createTempDirectory(JWTAuthPluginIntegrationTest.class.getSimpleName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we call createTempDir instead?
@@ -60,9 +60,8 @@ protected static void setupTest( | |||
protected static void initFolders(boolean isPersistent) throws Exception { | |||
tmpSolrHome = createTempDir(); | |||
tmpConfDir = tmpSolrHome.resolve(CONF_DIR); | |||
tmpConfDir.toFile().deleteOnExit(); | |||
PathUtils.deleteOnExit(tmpConfDir); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createTempDir self cleans up per test. It's javadocs say so.
@@ -136,7 +136,7 @@ protected static void setupTestInit(String solrconfig, String schema, boolean is | |||
throws Exception { | |||
tmpSolrHome = createTempDir(); | |||
tmpConfDir = tmpSolrHome.resolve(CONF_DIR); | |||
tmpConfDir.toFile().deleteOnExit(); | |||
PathUtils.deleteOnExit(tmpConfDir); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createTempDir self cleans up per test. It's javadocs say so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this suite, can we just use createTempDir?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
Moved to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I think this closes out SOLR-16903. Looking in CHANGES.txt, there are 2 mentions. The first is:
* SOLR-16903: Update CLI tools and Solr Core to use java.nio.file.Path instead of java.io.File (Andrey Bozhko, Matthew Biscocho)
I propose updating this one to simply be "Replace all java.io.File usages to java.nio.file.Path (NIO)" listing you & @AndreyBozhko
I also see:
* SOLR-17548: Switch all public Java APIs from File to Path. (Matthew Biscocho via Eric Pugh)
which is implied by the total switch from File -> Path. At least move this to be adjacent but you could also simply combine to the same bullet, listing both JIRAs (this happens sometimes).
Thanks to you both!
Looks like we might be running into that filterPath issue I ran into previously. Also looks like there is precommit issues I am not seeing locally.... I'll need to fix this before merging. Will update the CHANGES.txt combining the change log and list @AndreyBozhko |
Path tempDir = Files.createTempDirectory(JWTAuthPluginIntegrationTest.class.getSimpleName()); | ||
tempDir.toFile().deleteOnExit(); | ||
|
||
Path tempDir = createTempDir(JWTAuthPluginIntegrationTest.class.getSimpleName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createTempDir already incorporates the test class name
tempDir.toFile().deleteOnExit(); | ||
|
||
Path tempDir = FilterPath.unwrap(createTempDir()); | ||
Path modifiedP12Cert = tempDir.resolve(p12Cert.getFileName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to unwrap to resolve the path
* SOLR-17548: Switch all public Java APIs from File to Path. (Matthew Biscocho via Eric Pugh) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to just remove this because its implied from the change above anyways.
https://issues.apache.org/jira/browse/SOLR-16903
Description
Add java.io.File as a default forbidden API
Solution
Remove all usages of File, either toFile() or old classes
Tests
Updated tests using File
Checklist
Please review the following and check all that apply:
main
branch../gradlew check
.