From 5a4a586aafbb744acfdd25530b2374f51bc66863 Mon Sep 17 00:00:00 2001 From: Wojciech Baszczyk Date: Fri, 17 May 2024 15:27:10 +0200 Subject: [PATCH] fix: ensure httpClientRequest is not null when there is request content --- .../gravitee/connector/http/HttpConnection.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/gravitee/connector/http/HttpConnection.java b/src/main/java/io/gravitee/connector/http/HttpConnection.java index 8b896693..4a4ea6b0 100644 --- a/src/main/java/io/gravitee/connector/http/HttpConnection.java +++ b/src/main/java/io/gravitee/connector/http/HttpConnection.java @@ -275,13 +275,14 @@ private Handler timeoutHandler() { public HttpConnection write(Buffer chunk) { // There is some request content, set the flag to true content = true; + // Request can be null in case of connectivity issue with the upstream + if (httpClientRequest != null) { + if (!headersWritten) { + this.writeHeaders(); + } - if (!headersWritten) { - this.writeHeaders(); + httpClientRequest.write(io.vertx.core.buffer.Buffer.buffer(chunk.getNativeBuffer())); } - - httpClientRequest.write(io.vertx.core.buffer.Buffer.buffer(chunk.getNativeBuffer())); - return this; } @@ -293,7 +294,11 @@ public WriteStream drainHandler(Handler drainHandler) { @Override public boolean writeQueueFull() { - return httpClientRequest.writeQueueFull(); + // Request can be null in case of connectivity issue with the upstream + if (httpClientRequest != null) { + return httpClientRequest.writeQueueFull(); + } + return false; } private void writeHeaders() {