Skip to content

Commit bc393b9

Browse files
authored
Handle createLink post security manager in StoreRecoveryTests (#129964)
When running under security manager an assumptionw as made that failing to create a hard link due to security exception implied hard links were supported. Now that security manager is gone, the code to create a hard link in StoreRecoveryTests executes. But in the case of windows, BasicFileAttributes.fileKey does not return a unique object that can be used to verify a link exists. Yet the fact createLink returned is enough to trust the jdk was able to create a link. closes #124104
1 parent 53a41db commit bc393b9

File tree

2 files changed

+1
-10
lines changed

2 files changed

+1
-10
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,6 @@ tests:
236236
- class: org.elasticsearch.packaging.test.DockerTests
237237
method: test012SecurityCanBeDisabled
238238
issue: https://github.com/elastic/elasticsearch/issues/116636
239-
- class: org.elasticsearch.index.shard.StoreRecoveryTests
240-
method: testAddIndices
241-
issue: https://github.com/elastic/elasticsearch/issues/124104
242239
- class: org.elasticsearch.smoketest.MlWithSecurityIT
243240
method: test {yaml=ml/data_frame_analytics_crud/Test get stats on newly created config}
244241
issue: https://github.com/elastic/elasticsearch/issues/121726

server/src/test/java/org/elasticsearch/index/shard/StoreRecoveryTests.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import java.io.IOException;
4545
import java.nio.file.Files;
4646
import java.nio.file.Path;
47-
import java.nio.file.attribute.BasicFileAttributes;
4847
import java.util.Arrays;
4948
import java.util.Map;
5049
import java.util.function.Predicate;
@@ -254,12 +253,7 @@ public boolean hardLinksSupported(Path path) throws IOException {
254253
try {
255254
Files.createFile(path.resolve("foo.bar"));
256255
Files.createLink(path.resolve("test"), path.resolve("foo.bar"));
257-
BasicFileAttributes destAttr = Files.readAttributes(path.resolve("test"), BasicFileAttributes.class);
258-
BasicFileAttributes sourceAttr = Files.readAttributes(path.resolve("foo.bar"), BasicFileAttributes.class);
259-
// we won't get here - no permission ;)
260-
return destAttr.fileKey() != null && destAttr.fileKey().equals(sourceAttr.fileKey());
261-
} catch (SecurityException ex) {
262-
return true; // if we run into that situation we know it's supported.
256+
return true; // createLink returning without exception means hard links are supported
263257
} catch (UnsupportedOperationException ex) {
264258
return false;
265259
}

0 commit comments

Comments
 (0)