From 822b956d46ed0b9546bdd554d548241be2fbbdd0 Mon Sep 17 00:00:00 2001 From: Mark Vieira Date: Tue, 4 Jan 2022 09:55:35 -0800 Subject: [PATCH] Ignore errors syncing ephemeral files in test clusters (#82154) --- .../gradle/testclusters/ElasticsearchNode.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java b/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java index f2b20cdf00274..ff8930ed42c84 100644 --- a/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java +++ b/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java @@ -62,6 +62,7 @@ import java.io.UncheckedIOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; +import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.nio.file.StandardCopyOption; import java.nio.file.StandardOpenOption; @@ -1207,11 +1208,6 @@ private void sync(Path sourceRoot, Path destinationRoot, BiConsumer throw new UncheckedIOException("Can't create directory " + destination.getParent(), e); } } else { - // Ignore these files that are sometimes let behind by the JVM - if (relativeDestination.toFile().getName().startsWith(".attach_pid")) { - return; - } - try { Files.createDirectories(destination.getParent()); } catch (IOException e) { @@ -1220,6 +1216,11 @@ private void sync(Path sourceRoot, Path destinationRoot, BiConsumer 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 (IOException e) { throw new UncheckedIOException("Can't walk source " + sourceRoot, e); }