Skip to content

Commit

Permalink
fix: ensure httpClientRequest is not null when there is request content
Browse files Browse the repository at this point in the history
  • Loading branch information
wbabyte committed May 21, 2024
1 parent 14313ae commit 5a4a586
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/main/java/io/gravitee/connector/http/HttpConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,14 @@ private Handler<Throwable> timeoutHandler() {
public HttpConnection<T> 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;
}

Expand All @@ -293,7 +294,11 @@ public WriteStream<Buffer> drainHandler(Handler<Void> 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() {
Expand Down

0 comments on commit 5a4a586

Please sign in to comment.