Skip to content

Commit cec7279

Browse files
author
Alexandru Scvortov
committed
refactored code
1 parent 052f9ba commit cec7279

File tree

2 files changed

+19
-35
lines changed

2 files changed

+19
-35
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ public void releaseChannelNumber() {
189189

190190
/**
191191
* Protected API - Filters the inbound command stream, processing
192-
* Basic.Deliver, Basic.Return and Channel.Close specially.
192+
* Basic.Deliver, Basic.Return, Channel.Flow and Channel.Close
193+
* specially.
193194
*/
194195
@Override public boolean processAsync(Command command) throws IOException
195196
{

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

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -48,56 +48,39 @@ public void handleUnexpectedConnectionDriverException(Connection conn, Throwable
4848
}
4949

5050
public void handleReturnListenerException(Channel channel, Throwable exception) {
51-
// TODO: Convert to logging framework
52-
System.err.println("ReturnListener.handleBasicReturn threw an exception for channel " +
53-
channel + ":");
54-
exception.printStackTrace();
55-
try {
56-
((AMQConnection) channel.getConnection()).close(AMQP.INTERNAL_ERROR,
57-
"Internal error in ReturnListener",
58-
false,
59-
exception);
60-
} catch (IOException ioe) {
61-
// Man, this clearly isn't our day.
62-
// Ignore the exception? TODO: Log the nested failure
63-
}
51+
handleChannelKiller(channel, exception, "ReturnListener.handleBasicReturn");
6452
}
6553

6654
public void handleFlowListenerException(Channel channel, Throwable exception) {
67-
// TODO: Convert to logging framework
68-
System.err.println("FlowListener.handleFlow threw an exception for channel " +
69-
channel + ":");
70-
exception.printStackTrace();
71-
try {
72-
((AMQConnection) channel.getConnection()).close(AMQP.INTERNAL_ERROR,
73-
"Internal error in FlowListener",
74-
false,
75-
exception);
76-
} catch (IOException ioe) {
77-
// Man, this clearly isn't our day.
78-
// Ignore the exception? TODO: Log the nested failure
79-
}
55+
handleChannelKiller(channel, exception, "FlowListener.handleFlow");
8056
}
8157

82-
public void handleConsumerException(Channel channel,
83-
Throwable exception,
84-
Consumer consumer,
85-
String consumerTag,
58+
public void handleConsumerException(Channel channel, Throwable exception,
59+
Consumer _consumer, String consumerTag,
8660
String methodName)
61+
{
62+
handleChannelKiller(channel, exception, "Consumer " + consumerTag
63+
+ " method " + methodName
64+
+ " for channel " + channel);
65+
}
66+
67+
protected void handleChannelKiller(Channel channel,
68+
Throwable exception,
69+
String what)
8770
{
8871
// TODO: Convert to logging framework
89-
System.err.println("Consumer " + consumer + " method " + methodName + " for channel " +
90-
channel + " threw an exception:");
72+
System.err.println(what + " threw an exception for channel " +
73+
channel + ":");
9174
exception.printStackTrace();
9275
try {
9376
((AMQConnection) channel.getConnection()).close(AMQP.INTERNAL_ERROR,
94-
"Internal error in Consumer " +
95-
consumerTag,
77+
"Internal error in " + what,
9678
false,
9779
exception);
9880
} catch (IOException ioe) {
9981
// Man, this clearly isn't our day.
10082
// Ignore the exception? TODO: Log the nested failure
10183
}
84+
10285
}
10386
}

0 commit comments

Comments
 (0)