Skip to content

Commit cd9c0fe

Browse files
authored
[java] Add null check when setting response in JDK 11 HttpClient (#11460)
Related to #11450
1 parent 4ad6726 commit cd9c0fe

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

java/src/org/openqa/selenium/remote/http/jdk/JdkHttpMessages.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,10 @@ public HttpResponse createResponse(java.net.http.HttpResponse<byte[]> response)
151151
res.setStatus(response.statusCode());
152152
response.headers().map()
153153
.forEach((name, values) -> values.stream().filter(Objects::nonNull).forEach(value -> res.addHeader(name, value)));
154-
res.setContent(() -> new ByteArrayInputStream(response.body()));
154+
byte[] responseBody = response.body();
155+
if (responseBody != null) {
156+
res.setContent(() -> new ByteArrayInputStream(responseBody));
157+
}
155158

156159
return res;
157160
}

0 commit comments

Comments
 (0)