Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rework handleChannelKiller to close channel only (if possible).

  • Loading branch information...
commit 54c13420668a7b91bc6530d6de20d6162a006666 1 parent 4547642
@Zteve Zteve authored
Showing with 19 additions and 14 deletions.
  1. +19 −14 src/com/rabbitmq/client/impl/DefaultExceptionHandler.java
View
33 src/com/rabbitmq/client/impl/DefaultExceptionHandler.java
@@ -19,6 +19,7 @@
import java.io.IOException;
import com.rabbitmq.client.AMQP;
+import com.rabbitmq.client.AlreadyClosedException;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.Consumer;
@@ -55,23 +56,27 @@ public void handleConsumerException(Channel channel, Throwable exception,
+ " for channel " + channel);
}
- protected void handleChannelKiller(Channel channel,
- Throwable exception,
- String what)
- {
- // TODO: Convert to logging framework
- System.err.println(what + " threw an exception for channel " +
- channel + ":");
+ protected void handleChannelKiller(Channel channel, Throwable exception, String what) {
+ // TODO: log the exception
+ System.err.println(what + " threw an exception for channel " + channel + ":");
exception.printStackTrace();
try {
- ((AMQConnection) channel.getConnection()).close(AMQP.INTERNAL_ERROR,
- "Internal error in " + what,
- false,
- exception);
+ channel.close();
+ } catch (AlreadyClosedException ace) {
+ //noop
} catch (IOException ioe) {
- // Man, this clearly isn't our day.
- // Ignore the exception? TODO: Log the nested failure
+ // TODO: log the failure
+ System.err.println("Failure during close of channel " + channel + " after " + exception + ":");
+ ioe.printStackTrace();
+ AMQConnection conn = (AMQConnection) channel.getConnection();
+ try {
+ conn.close(AMQP.INTERNAL_ERROR, "Internal error closing channel for " + what,
+ false, ioe);
+ } catch (IOException ioeH) {
+ // TODO: log the failure
+ System.err.println("Failure during close of connection " + conn + " after " + ioe + ":");
+ ioeH.printStackTrace();
+ }
}
-
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.