Skip to content

Commit bc8634d

Browse files
committed
Improve eager command failure in MySQL and SQL Server
Follows up on onhttps://github.com/eclipse-vertx/pull/1507 Signed-off-by: Thomas Segismont <[email protected]>
1 parent a7e2b61 commit bc8634d

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

vertx-mssql-client/src/main/java/io/vertx/mssqlclient/impl/codec/TdsMessageCodec.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
import io.netty.buffer.ByteBufAllocator;
1515
import io.netty.channel.ChannelHandlerContext;
1616
import io.netty.channel.CombinedChannelDuplexHandler;
17+
import io.vertx.core.Completable;
1718
import io.vertx.sqlclient.ClosedConnectionException;
18-
import io.vertx.sqlclient.internal.command.CommandBase;
19-
import io.vertx.sqlclient.internal.command.CommandResponse;
2019

2120
import java.util.ArrayDeque;
2221
import java.util.HashMap;
@@ -66,9 +65,10 @@ private void fail(Throwable cause) {
6665
}
6766

6867
private void fail(MSSQLCommandCodec<?, ?> codec, Throwable cause) {
69-
CommandResponse<Object> failure = CommandResponse.failure(cause);
70-
failure.cmd = (CommandBase) codec.cmd;
71-
chctx.fireChannelRead(failure);
68+
Completable<?> handler = codec.cmd.handler;
69+
if (handler != null) {
70+
handler.complete(null, cause);
71+
}
7272
}
7373

7474
@Override

vertx-mysql-client/src/main/java/io/vertx/mysqlclient/impl/codec/MySQLCodec.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import io.netty.channel.ChannelHandlerContext;
2020
import io.netty.channel.CombinedChannelDuplexHandler;
21+
import io.vertx.core.Completable;
2122
import io.vertx.mysqlclient.impl.MySQLSocketConnection;
2223
import io.vertx.sqlclient.ClosedConnectionException;
2324
import io.vertx.sqlclient.internal.command.CommandBase;
@@ -80,9 +81,10 @@ private void clearInflightCommands(Throwable cause) {
8081
private void fail(CommandCodec<?, ?> codec, Throwable cause) {
8182
if (failure == null) {
8283
failure = cause;
83-
CommandResponse<Object> failure = CommandResponse.failure(cause);
84-
failure.cmd = (CommandBase) codec.cmd;
85-
chctx.fireChannelRead(failure);
84+
Completable<?> handler = codec.cmd.handler;
85+
if (handler != null) {
86+
handler.complete(null, cause);
87+
}
8688
}
8789
}
8890

0 commit comments

Comments
 (0)