Skip to content

Commit 0aa4093

Browse files
committed
Replace usage of CommandBase#handler by CommandMessage#handler
Motivation: In the quest of removing CommandBase#handler, we are replacing its usage by CommandMessage#handler. Hopefully we will remove it also for the Oracle implementation.
1 parent 90e29f5 commit 0aa4093

File tree

20 files changed

+118
-55
lines changed

20 files changed

+118
-55
lines changed

vertx-db2-client/src/main/java/io/vertx/db2client/impl/DB2SocketConnection.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ protected <R> void doSchedule(CommandBase<R> cmd, Completable<R> handler) {
9393
if (txCmd.kind == TxCommand.Kind.BEGIN) {
9494
// DB2 always implicitly starts a transaction with each query, and does
9595
// not support the 'BEGIN' keyword. Instead we can no-op BEGIN commands
96-
cmd.handler = handler;
97-
cmd.complete(CommandResponse.success(txCmd.result).toAsyncResult());
96+
handler.succeed(txCmd.result);
9897
} else {
9998
SimpleQueryCommand<Void> cmd2 = new SimpleQueryCommand<>(txCmd.kind.sql, false, false,
10099
QueryCommandBase.NULL_COLLECTOR, QueryResultHandler.NOOP_HANDLER);

vertx-db2-client/src/main/java/io/vertx/db2client/impl/codec/CommandCodec.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ public abstract class CommandCodec<R, C extends CommandBase<R>> extends CommandM
3434
Handler<? super CommandResponse<R>> completionHandler;
3535
public Throwable failure;
3636
public R result;
37-
final C cmd;
3837
DB2Encoder encoder;
3938

4039
CommandCodec(C cmd) {
41-
this.cmd = cmd;
40+
super(cmd);
4241
}
4342

4443
@SuppressWarnings({ "rawtypes", "unchecked" })

vertx-db2-client/src/main/java/io/vertx/db2client/impl/codec/DB2Codec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void channelInactive(ChannelHandlerContext ctx) throws Exception {
4343

4444
private void clearInflightCommands(Throwable failure) {
4545
for (CommandCodec<?, ?> commandCodec : inflight) {
46-
commandCodec.cmd.fail(failure);
46+
commandCodec.fail(failure);
4747
}
4848
}
4949
}

vertx-db2-client/src/main/java/io/vertx/db2client/impl/codec/DB2Encoder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import io.netty.channel.ChannelHandlerContext;
2121
import io.netty.channel.ChannelOutboundHandlerAdapter;
2222
import io.netty.channel.ChannelPromise;
23+
import io.vertx.core.Completable;
2324
import io.vertx.core.internal.logging.Logger;
2425
import io.vertx.core.internal.logging.LoggerFactory;
2526
import io.vertx.db2client.impl.DB2SocketConnection;
@@ -59,7 +60,7 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
5960
void write(CommandCodec<?, ?> msg) {
6061
msg.completionHandler = resp -> {
6162
CommandCodec<?, ?> c = inflight.poll();
62-
resp.cmd = (CommandBase) c.cmd;
63+
resp.handler = (Completable) c.handler;
6364
chctx.fireChannelRead(resp);
6465
};
6566
inflight.add(msg);

vertx-db2-client/src/main/java/io/vertx/db2client/impl/codec/InitialHandshakeCommandCodec.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void encode(DB2Encoder encoder) {
5959
// -4499 = A fatal error occurred that resulted in a disconnect from the data
6060
// source.
6161
// 08001 = "The connection was unable to be established"
62-
cmd.fail(new DB2Exception("The connection was closed by the database server.", SqlCode.CONNECTION_REFUSED,
62+
fail(new DB2Exception("The connection was closed by the database server.", SqlCode.CONNECTION_REFUSED,
6363
SQLState.AUTH_DATABASE_CONNECTION_REFUSED));
6464
}
6565
});
@@ -130,7 +130,7 @@ void decodePayload(ByteBuf payload, int payloadLength) {
130130
break;
131131

132132
default:
133-
cmd.fail(new DB2Exception("The connection was unable to be established. Invalid connection state.", SqlCode.CONNECTION_REFUSED,
133+
fail(new DB2Exception("The connection was unable to be established. Invalid connection state.", SqlCode.CONNECTION_REFUSED,
134134
SQLState.AUTH_DATABASE_CONNECTION_REFUSED));
135135
break;
136136

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,11 @@ public abstract class MSSQLCommandCodec<R, C extends CommandBase<R>> extends Com
3737

3838
public TdsMessageCodec tdsMessageCodec;
3939

40-
final C cmd;
4140
public MSSQLException failure;
4241
public R result;
4342

4443
MSSQLCommandCodec(C cmd) {
45-
this.cmd = cmd;
44+
super(cmd);
4645
}
4746

4847
public static MSSQLCommandCodec<?, ?> wrap(CommandBase<?> cmd) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private void fail(Throwable cause) {
6565
}
6666

6767
private void fail(MSSQLCommandCodec<?, ?> codec, Throwable cause) {
68-
codec.cmd.fail(cause);
68+
codec.fail(cause);
6969
}
7070

7171
@Override

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import io.netty.buffer.ByteBufAllocator;
1515
import io.netty.channel.ChannelHandlerContext;
1616
import io.netty.channel.ChannelInboundHandlerAdapter;
17+
import io.vertx.core.Completable;
1718
import io.vertx.sqlclient.internal.command.CommandBase;
1819
import io.vertx.sqlclient.internal.command.CommandResponse;
1920

@@ -55,7 +56,7 @@ public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
5556

5657
void fireCommandResponse(CommandResponse<?> commandResponse) {
5758
MSSQLCommandCodec<?, ?> c = tdsMessageCodec.poll();
58-
commandResponse.cmd = (CommandBase) c.cmd;
59+
commandResponse.handler = (Completable) c.handler;
5960
chctx.fireChannelRead(commandResponse);
6061
}
6162

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,11 @@ public abstract class CommandCodec<R, C extends CommandBase<R>> extends CommandM
4949

5050
public Throwable failure;
5151
public R result;
52-
final C cmd;
5352
MySQLEncoder encoder;
5453
int sequenceId;
5554

5655
CommandCodec(C cmd) {
57-
this.cmd = cmd;
56+
super(cmd);
5857
}
5958

6059
public static CommandCodec<?, ?> wrap(CommandBase<?> cmd) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private void clearInflightCommands(Throwable cause) {
7878
private void fail(CommandCodec<?, ?> codec, Throwable cause) {
7979
if (failure == null) {
8080
failure = cause;
81-
codec.cmd.fail(cause);
81+
codec.fail(cause);
8282
}
8383
}
8484

0 commit comments

Comments
 (0)