Skip to content

Commit 866a6e8

Browse files
efaracci018sarutak
authored andcommitted
[SPARK-55290][NETWORK][TESTS] Fix testReloadMissingTrustStore cross-device link error with JDK 21
### What changes were proposed in this pull request? Replace hardcoded filename with `File.createTempFile()` in `testReloadMissingTrustStore` to ensure the temporary `trustStore` file is created in the same filesystem as the test working directory. ### Why are the changes needed? This change fixes a unit test bug. JDK 21's `UnixFileSystem.move()` uses atomic rename operations that fail when moving files across different mounted filesystems. The test creates a temporary file in `/tmp` and attempts to move it to the current directory. When these locations are on different partitions, the atomic move fails with a `testmissing.jks: Cross-device link` error because the `rename()` system call cannot move files across different filesystems. The fix ensures both temporary and target files are created in the same filesystem by eliminating the cross-filesystem move operation. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Verified `ReloadingX509TrustManagerSuite` passes with both JDK 21 and JDK 17: `build/mvn -pl common/network-common -Dtest=ReloadingX509TrustManagerSuite test` ### Was this patch authored or co-authored using generative AI tooling? No. Closes #54073 from efaracci018/fix-testReloadMissingTrustStore. Authored-by: Emilie Faracci <efaracci@amazon.com> Signed-off-by: Kousuke Saruta <sarutak@apache.org>
1 parent 65a6a55 commit 866a6e8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

common/network-common/src/test/java/org/apache/spark/network/ssl/ReloadingX509TrustManagerSuite.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ public void testReload() throws Exception {
189189
public void testReloadMissingTrustStore() throws Exception {
190190
KeyPair kp = generateKeyPair("RSA");
191191
X509Certificate cert1 = generateCertificate("CN=Cert1", kp, 30, "SHA1withRSA");
192-
File trustStore = new File("testmissing.jks");
192+
File trustStore = File.createTempFile("testmissing", "jks");
193+
trustStore.delete();
194+
// trustStore is going to be re-created later so delete it on exit.
193195
trustStore.deleteOnExit();
194196
assertFalse(trustStore.exists());
195197
createTrustStore(trustStore, "password", "cert1", cert1);

0 commit comments

Comments
 (0)