Skip to content

Commit 48fd48b

Browse files
authored
Handle wrapped IO exceptions in test cluster distribution syncing (#82288) (#82300)
Third attempt at sorting out this problem after #82154 didn't do the trick. The issue is that `FileTreeIterator` wraps the root cause exception in an `UncheckedIOException` so to detect this scenario properly we actually have to inspect the cause.
1 parent 7f9895d commit 48fd48b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java

+9-4
Original file line numberDiff line numberDiff line change
@@ -1216,10 +1216,15 @@ private void sync(Path sourceRoot, Path destinationRoot, BiConsumer<Path, Path>
12161216
syncMethod.accept(destination, source);
12171217
}
12181218
});
1219-
} catch (NoSuchFileException e) {
1220-
// Ignore these files that are sometimes left behind by the JVM
1221-
if (e.getFile() == null || e.getFile().contains(".attach_pid") == false) {
1222-
throw new UncheckedIOException(e);
1219+
} catch (UncheckedIOException e) {
1220+
if (e.getCause() instanceof NoSuchFileException) {
1221+
NoSuchFileException cause = (NoSuchFileException) e.getCause();
1222+
// Ignore these files that are sometimes left behind by the JVM
1223+
if (cause.getFile() == null || cause.getFile().contains(".attach_pid") == false) {
1224+
throw new UncheckedIOException(cause);
1225+
}
1226+
} else {
1227+
throw e;
12231228
}
12241229
} catch (IOException e) {
12251230
throw new UncheckedIOException("Can't walk source " + sourceRoot, e);

0 commit comments

Comments
 (0)