aboutsummaryrefslogtreecommitdiffstats
path: root/http-client
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2022-04-29 13:10:11 +0200
committerjonmv <venstad@gmail.com>2022-04-29 13:10:11 +0200
commit5d5f5b5996d5acd10490692e1faa65c2b180008a (patch)
tree769846d5146160ada93f8992a81e93a0b163e40d /http-client
parentca053bdad4a42903f760579e7f0038b8fcac602f (diff)
Check for null entity
Diffstat (limited to 'http-client')
-rw-r--r--http-client/src/main/java/ai/vespa/hosted/client/MockHttpClient.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/http-client/src/main/java/ai/vespa/hosted/client/MockHttpClient.java b/http-client/src/main/java/ai/vespa/hosted/client/MockHttpClient.java
index 6c2a882f990..97ef58ea76d 100644
--- a/http-client/src/main/java/ai/vespa/hosted/client/MockHttpClient.java
+++ b/http-client/src/main/java/ai/vespa/hosted/client/MockHttpClient.java
@@ -57,9 +57,11 @@ public class MockHttpClient extends AbstractHttpClient {
public void expect(BiFunction<HttpURL, String, String> mapper, int status) {
expect(request -> {
try {
- BasicClassicHttpResponse response = new BasicClassicHttpResponse(status);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- request.getEntity().writeTo(buffer);
+ if (request.getEntity() != null)
+ request.getEntity().writeTo(buffer);
+
+ BasicClassicHttpResponse response = new BasicClassicHttpResponse(status);
response.setEntity(HttpEntities.create(mapper.apply(HttpURL.from(request.getUri()), buffer.toString(UTF_8)),
ContentType.APPLICATION_JSON));
return response;