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) (elastic#82299)

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 Jan 6, 2022
1 parent 2e7e8ff commit e488750
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1216,10 +1216,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 e488750

Please sign in to comment.