From 9cefb95a43e79a0b5e0cd611b469c94b191ed7a1 Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Thu, 27 Mar 2025 10:47:54 +0100 Subject: [PATCH] PgCodec tries to fail a command in progress by firing a failure message through the Netty pipeline. This raise issues when there is a read in progress with reentrancy, while this issue should be also addressed in vertx core, proceeding this way means caring about the channel read/readComplete status to eventually emit a readComplete to respect the Netty inbound message protocol. Instead we can simply fail the handler associated with the codec yielding the same result. --- .../main/java/io/vertx/pgclient/impl/codec/PgCodec.java | 8 +++++--- .../java/io/vertx/tests/pgclient/CloseConnectionTest.java | 1 - 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/PgCodec.java b/vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/PgCodec.java index 71d9750507..ec58b604e6 100644 --- a/vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/PgCodec.java +++ b/vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/PgCodec.java @@ -18,6 +18,7 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.channel.CombinedChannelDuplexHandler; +import io.vertx.core.Completable; import io.vertx.sqlclient.ClosedConnectionException; import io.vertx.sqlclient.internal.command.CommandBase; import io.vertx.sqlclient.internal.command.CommandResponse; @@ -82,9 +83,10 @@ private void fail(Throwable cause) { } private void fail(PgCommandCodec codec, Throwable cause) { - CommandResponse failure = CommandResponse.failure(cause); - failure.cmd = (CommandBase) codec.cmd; - chctx.fireChannelRead(failure); + Completable handler = codec.cmd.handler; + if (handler != null) { + handler.complete(null, cause); + } } @Override diff --git a/vertx-pg-client/src/test/java/io/vertx/tests/pgclient/CloseConnectionTest.java b/vertx-pg-client/src/test/java/io/vertx/tests/pgclient/CloseConnectionTest.java index 95deda88e6..b2cad3c166 100644 --- a/vertx-pg-client/src/test/java/io/vertx/tests/pgclient/CloseConnectionTest.java +++ b/vertx-pg-client/src/test/java/io/vertx/tests/pgclient/CloseConnectionTest.java @@ -76,7 +76,6 @@ private void testCloseConnection(TestContext ctx, Runnable test) { } @Test - @Ignore("Ignored due to https://github.com/eclipse-vertx/vertx-sql-client/issues/1506") public void testTransactionInProgressShouldFail(TestContext ctx) { ProxyServer proxy = ProxyServer.create(vertx, options.getPort(), options.getHost()); proxy.proxyHandler(conn -> {