From b79b4333cd73b1ecf3f858cabb884809be8f94bf Mon Sep 17 00:00:00 2001 From: Andrei Solntsev Date: Fri, 12 Dec 2025 17:08:25 +0200 Subject: [PATCH] #16720 avoid failing because of temporary Chrome internal files ... that Chrome downloads and immediately deletes. --- .../org/openqa/selenium/grid/node/local/LocalNode.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/java/src/org/openqa/selenium/grid/node/local/LocalNode.java b/java/src/org/openqa/selenium/grid/node/local/LocalNode.java index de0ae01760e9e..e56586b2f49d1 100644 --- a/java/src/org/openqa/selenium/grid/node/local/LocalNode.java +++ b/java/src/org/openqa/selenium/grid/node/local/LocalNode.java @@ -53,6 +53,7 @@ import java.io.UncheckedIOException; import java.net.URI; import java.net.URISyntaxException; +import java.nio.file.NoSuchFileException; import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.FileTime; import java.time.Clock; @@ -792,7 +793,10 @@ private HttpResponse listDownloadedFiles(File downloadsDirectory) { File[] files = Optional.ofNullable(downloadsDirectory.listFiles()).orElse(new File[] {}); List fileNames = Arrays.stream(files).map(File::getName).collect(Collectors.toList()); List fileInfos = - Arrays.stream(files).map(this::getFileInfo).collect(Collectors.toList()); + Arrays.stream(files) + .map(this::getFileInfo) + .filter(file -> file.getLastModifiedTime() > 0) + .collect(Collectors.toList()); Map data = Map.of( @@ -810,6 +814,8 @@ private DownloadedFile getFileInfo(File file) { attributes.creationTime().toMillis(), attributes.lastModifiedTime().toMillis(), attributes.size()); + } catch (NoSuchFileException e) { + return new DownloadedFile(file.getName(), -1, -1, -1); } catch (IOException e) { throw new UncheckedIOException("Failed to get file attributes: " + file.getAbsolutePath(), e); }