From aaf5fd72e6262955ff476d294ba6f6124a2baba5 Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Tue, 15 Oct 2019 13:51:30 +0200 Subject: [PATCH] Fix synchronisation regression leading to potential deadlock --- .../vertx/core/http/impl/HttpClientRequestImpl.java | 12 +++++++----- .../io/vertx/core/http/impl/VertxHttp2Stream.java | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/vertx/core/http/impl/HttpClientRequestImpl.java b/src/main/java/io/vertx/core/http/impl/HttpClientRequestImpl.java index 78f70ffd2..90202750d 100644 --- a/src/main/java/io/vertx/core/http/impl/HttpClientRequestImpl.java +++ b/src/main/java/io/vertx/core/http/impl/HttpClientRequestImpl.java @@ -200,12 +200,14 @@ public class HttpClientRequestImpl extends HttpClientRequestBase implements Http @Override public synchronized boolean writeQueueFull() { checkEnded(); - if (stream == null) { - // Should actually check with max queue size and not always blindly return false - return false; - } else { - return stream.isNotWritable(); + synchronized (this) { + checkEnded(); + if (stream == null) { + // Should actually check with max queue size and not always blindly return false + return false; + } } + return stream.isNotWritable(); } private synchronized Handler exceptionHandler() { diff --git a/src/main/java/io/vertx/core/http/impl/VertxHttp2Stream.java b/src/main/java/io/vertx/core/http/impl/VertxHttp2Stream.java index eaad99502..aa37f67e2 100644 --- a/src/main/java/io/vertx/core/http/impl/VertxHttp2Stream.java +++ b/src/main/java/io/vertx/core/http/impl/VertxHttp2Stream.java @@ -92,8 +92,8 @@ abstract class VertxHttp2Stream { void onWritabilityChanged() { synchronized (conn) { writable = !writable; - handleInterestedOpsChanged(); } + handleInterestedOpsChanged(); } void onEnd() {