Skip to content

Commit 713069b

Browse files
author
David R. MacIver
committed
add more stringent test to channel disconnection
1 parent 1d52d31 commit 713069b

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/com/rabbitmq/client/impl/AMQConnection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ public class AMQConnection extends ShutdownNotifierComponent implements Connecti
113113
* Protected API - respond, in the driver thread, to a ShutdownSignal.
114114
* @param channelNumber the number of the channel to disconnect
115115
*/
116-
public final void disconnectChannel(int channelNumber) {
117-
_channelManager.disconnectChannel(channelNumber);
116+
public final void disconnectChannel(ChannelN channel) {
117+
_channelManager.disconnectChannel(channel);
118118
}
119119

120120
public void ensureIsOpen()

src/com/rabbitmq/client/impl/ChannelManager.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ public void handleSignal(ShutdownSignalException signal) {
8686
synchronized(_channelMap) {
8787
channels = new HashSet<ChannelN>(_channelMap.values());
8888
}
89-
for (AMQChannel channel : channels) {
90-
disconnectChannel(channel.getChannelNumber());
89+
for (ChannelN channel : channels) {
90+
disconnectChannel(channel);
9191
channel.processShutdownSignal(signal, true, true);
9292
}
9393
}
@@ -126,13 +126,13 @@ private void addChannel(ChannelN chan) {
126126
_channelMap.put(chan.getChannelNumber(), chan);
127127
}
128128

129-
public synchronized void disconnectChannel(int channelNumber) {
130-
if (_channelMap.remove(channelNumber) == null)
129+
public synchronized void disconnectChannel(ChannelN channel) {
130+
int channelNumber = channel.getChannelNumber();
131+
if (_channelMap.remove(channelNumber) != channel)
131132
throw new IllegalStateException(
132133
"We have attempted to "
133134
+ "create a disconnect a channel that's no longer in "
134135
+ "use. This should never happen. Please report this as a bug.");
135-
System.err.println("DISCONN CH" + channelNumber);
136136
channelNumberAllocator.free(channelNumber);
137137
}
138138
}

src/com/rabbitmq/client/impl/ChannelN.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public void broadcastShutdownSignal(ShutdownSignalException signal) {
166166
}
167167

168168
public void releaseChannelNumber() {
169-
_connection.disconnectChannel(_channelNumber);
169+
_connection.disconnectChannel(this);
170170
}
171171

172172
/**

0 commit comments

Comments
 (0)