[java] Add null check when setting response in JDK 11 HttpClient
Related to
@@ -151,7 +151,10 @@ public HttpResponse createResponse(java.net.http.HttpResponse<byte[]> response)
res.setStatus(response.statusCode());
response.headers().map()
.forEach((name, values) -> values.stream().filter(Objects::nonNull).forEach(value -> res.addHeader(name, value)));
- res.setContent(() -> new ByteArrayInputStream(response.body()));
+ byte[] responseBody = response.body();
+ if (responseBody != null) {
+ res.setContent(() -> new ByteArrayInputStream(responseBody));
+ }
return res;
}
