From ed7bafb217a15f12f4bd1048424335f16dc65d6f Mon Sep 17 00:00:00 2001 From: Mark Vieira Date: Thu, 30 Dec 2021 09:15:35 -0800 Subject: [PATCH] Ignore errors syncing ephemeral files in test clusters --- .../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 15424f45830c1..f4a1c91857f54 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 @@ -61,6 +61,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; @@ -1169,11 +1170,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) { @@ -1182,6 +1178,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); }