Skip to content

Commit 31956ff

Browse files
author
David R. MacIver
committed
the tracer should use a separate command assembler per channel. It happened to work when you were using the connection in a single threaded manner, but would get frames intended for different channels confused if you had multiple threads firing
1 parent 223aaa8 commit 31956ff

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/com/rabbitmq/tools/Tracer.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import java.io.IOException;
3838
import java.net.ServerSocket;
3939
import java.net.Socket;
40+
import java.util.HashMap;
4041

4142
import com.rabbitmq.client.AMQP;
4243
import com.rabbitmq.client.impl.AMQCommand;
@@ -159,14 +160,13 @@ public class DirectionHandler implements Runnable {
159160

160161
public DataOutputStream o;
161162

162-
public AMQCommand.Assembler c;
163+
public HashMap<Integer, AMQCommand.Assembler> assemblers = new HashMap();
163164

164165
public DirectionHandler(BlockingCell<Object> waitCell, boolean inBound, DataInputStream i, DataOutputStream o) {
165166
this.waitCell = waitCell;
166167
this.inBound = inBound;
167168
this.i = i;
168169
this.o = o;
169-
this.c = AMQCommand.newAssembler();
170170
}
171171

172172
public Frame readFrame() throws IOException {
@@ -221,10 +221,15 @@ public void doFrame() throws IOException {
221221
reportFrame(f);
222222
}
223223
} else {
224+
AMQCommand.Assembler c = assemblers.get(f.channel);
225+
if(c == null){
226+
c = AMQCommand.newAssembler();
227+
assemblers.put(f.channel, c);
228+
}
224229
AMQCommand cmd = c.handleFrame(f);
225230
if (cmd != null) {
226231
report(f.channel, cmd);
227-
c = AMQCommand.newAssembler();
232+
assemblers.remove(f.channel);
228233
}
229234
}
230235
}

0 commit comments

Comments
 (0)