Skip to content

Commit

Permalink
Handle wrapped IO exceptions in test cluster distribution syncing (el…
Browse files Browse the repository at this point in the history
…astic#82288)

Third attempt at sorting out this problem after elastic#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.
  • Loading branch information
mark-vieira authored and astefan committed Jan 7, 2022
1 parent 45bed59 commit a95158b
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1208,10 +1208,15 @@ private void sync(Path sourceRoot, Path destinationRoot, BiConsumer<Path, Path>
syncMethod.accept(destination, source);
}
});
} catch (NoSuchFileException e) {
// Ignore these files that are sometimes left behind by the JVM
if (e.getFile() == null || e.getFile().contains(".attach_pid") == false) {
throw new UncheckedIOException(e);
} catch (UncheckedIOException e) {
if (e.getCause() instanceof NoSuchFileException) {
NoSuchFileException cause = (NoSuchFileException) e.getCause();
// Ignore these files that are sometimes left behind by the JVM
if (cause.getFile() == null || cause.getFile().contains(".attach_pid") == false) {
throw new UncheckedIOException(cause);
}
} else {
throw e;
}
} catch (IOException e) {
throw new UncheckedIOException("Can't walk source " + sourceRoot, e);
Expand Down

0 comments on commit a95158b

Please sign in to comment.