Skip to content

Commit 0db1ae4

Browse files
author
David R. MacIver
committed
override the exception handler to not print the stack trace when it catches a channel exception
1 parent 5852d8e commit 0db1ae4

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

test/src/com/rabbitmq/client/test/CloseInMainLoop.java

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,37 @@ public boolean hadValidShutdown(){
1818
}
1919

2020
public SpecialConnection() throws Exception{
21-
super(new ConnectionParameters(), new SocketFrameHandler(SocketFactory.getDefault().createSocket("localhost", 5672)));
22-
this.start(true);
23-
}
21+
super(
22+
new ConnectionParameters(),
23+
new SocketFrameHandler(SocketFactory.getDefault().createSocket("localhost", 5672)),
24+
new DefaultExceptionHandler(){
25+
@Override public void handleConsumerException(Channel channel,
26+
Throwable exception,
27+
Consumer consumer,
28+
String consumerTag,
29+
String methodName){
30+
try {
31+
((AMQConnection) channel.getConnection()).close(AMQP.INTERNAL_ERROR,
32+
"Internal error in Consumer " +
33+
consumerTag,
34+
false,
35+
exception);
36+
} catch (IOException ioe) {
37+
// Man, this clearly isn't our day.
38+
// Ignore the exception? TODO: Log the nested failure
39+
}
40+
}
41+
});
42+
43+
this.start(true);
44+
}
2445

2546
@Override
2647
public boolean processControlCommand(Command c) throws IOException{
2748
if(c.getMethod() instanceof AMQP.Connection.CloseOk) validShutdown.set(true);
2849
return super.processControlCommand(c);
2950
}
51+
3052
}
3153

3254

0 commit comments

Comments
 (0)