Skip to content

Commit 278c835

Browse files
committed
Check Connection availability in NIO loop
Fixes #11
1 parent e680acd commit 278c835

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/main/java/com/rabbitmq/client/impl/AMQChannel.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,12 @@ public void handleCompleteInboundCommand(AMQCommand command) throws IOException
143143
if (!processAsync(command)) {
144144
// The filter decided not to handle/consume the command,
145145
// so it must be some reply to an earlier RPC.
146-
nextOutstandingRpc().handleCommand(command);
147-
markRpcFinished();
146+
RpcContinuation nextOutstandingRpc = nextOutstandingRpc();
147+
// the outstanding RPC can be null when calling Channel#asyncRpc
148+
if(nextOutstandingRpc != null) {
149+
nextOutstandingRpc.handleCommand(command);
150+
markRpcFinished();
151+
}
148152
}
149153
}
150154

src/main/java/com/rabbitmq/client/impl/nio/NioLoop.java

+5
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ public void run() {
134134
key.cancel();
135135
continue;
136136
}
137+
if(state.getConnection() == null) {
138+
// we're in AMQConnection#start, between the header sending and the FrameHandler#initialize
139+
// let's wait a bit more
140+
continue;
141+
}
137142

138143
DataInputStream inputStream = state.inputStream;
139144

0 commit comments

Comments
 (0)