Skip to content

Commit b703512

Browse files
authored
#16720 avoid failing because of temporary Chrome internal files (#16722)
... that Chrome downloads and immediately deletes.
1 parent 50418b8 commit b703512

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

java/src/org/openqa/selenium/grid/node/local/LocalNode.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import java.io.UncheckedIOException;
5454
import java.net.URI;
5555
import java.net.URISyntaxException;
56+
import java.nio.file.NoSuchFileException;
5657
import java.nio.file.attribute.BasicFileAttributes;
5758
import java.nio.file.attribute.FileTime;
5859
import java.time.Clock;
@@ -792,7 +793,10 @@ private HttpResponse listDownloadedFiles(File downloadsDirectory) {
792793
File[] files = Optional.ofNullable(downloadsDirectory.listFiles()).orElse(new File[] {});
793794
List<String> fileNames = Arrays.stream(files).map(File::getName).collect(Collectors.toList());
794795
List<DownloadedFile> fileInfos =
795-
Arrays.stream(files).map(this::getFileInfo).collect(Collectors.toList());
796+
Arrays.stream(files)
797+
.map(this::getFileInfo)
798+
.filter(file -> file.getLastModifiedTime() > 0)
799+
.collect(Collectors.toList());
796800

797801
Map<String, Object> data =
798802
Map.of(
@@ -810,6 +814,8 @@ private DownloadedFile getFileInfo(File file) {
810814
attributes.creationTime().toMillis(),
811815
attributes.lastModifiedTime().toMillis(),
812816
attributes.size());
817+
} catch (NoSuchFileException e) {
818+
return new DownloadedFile(file.getName(), -1, -1, -1);
813819
} catch (IOException e) {
814820
throw new UncheckedIOException("Failed to get file attributes: " + file.getAbsolutePath(), e);
815821
}

0 commit comments

Comments
 (0)