Skip to content

Commit 6d5a0ce

Browse files
committed
[java] Fixing potential NPE and deleting unused imports
1 parent 6e182e5 commit 6d5a0ce

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

java/server/src/org/openqa/selenium/grid/node/UploadFile.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import com.google.common.collect.ImmutableMap;
2424

2525
import org.openqa.selenium.WebDriverException;
26-
import org.openqa.selenium.grid.data.CreateSessionRequest;
27-
import org.openqa.selenium.grid.data.CreateSessionResponse;
2826
import org.openqa.selenium.io.TemporaryFilesystem;
2927
import org.openqa.selenium.io.Zip;
3028
import org.openqa.selenium.json.Json;
@@ -35,7 +33,6 @@
3533
import java.io.File;
3634
import java.io.IOException;
3735
import java.io.UncheckedIOException;
38-
import java.util.HashMap;
3936
import java.util.Map;
4037
import java.util.Objects;
4138

@@ -63,7 +60,11 @@ public HttpResponse execute(HttpRequest req) throws UncheckedIOException {
6360
}
6461
// Select the first file
6562
File[] allFiles = tempDir.listFiles();
66-
if (allFiles == null || allFiles.length != 1) {
63+
if (allFiles == null) {
64+
throw new WebDriverException(
65+
String.format("Cannot access temporary directory for uploaded files %s", tempDir));
66+
}
67+
if (allFiles.length != 1) {
6768
throw new WebDriverException(
6869
String.format("Expected there to be only 1 file. There were: %s", allFiles.length));
6970
}

0 commit comments

Comments
 (0)