From a93de90ef7be612fbc0891f014b827be8785bf3c Mon Sep 17 00:00:00 2001 From: Rupert Smith Date: Tue, 9 Oct 2007 14:05:30 +0000 Subject: Changed exception handler to propagate unknown exceptions to all method listeners, rather than throw it back to the caller. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2.1@583173 13f79535-47bb-0310-9956-ffa450edef68 --- .../Client/Protocol/AMQProtocolListener.cs | 25 +++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'dotnet/Qpid.Client/Client') diff --git a/dotnet/Qpid.Client/Client/Protocol/AMQProtocolListener.cs b/dotnet/Qpid.Client/Client/Protocol/AMQProtocolListener.cs index 3d31d6c2f3..c51538b70e 100644 --- a/dotnet/Qpid.Client/Client/Protocol/AMQProtocolListener.cs +++ b/dotnet/Qpid.Client/Client/Protocol/AMQProtocolListener.cs @@ -161,20 +161,20 @@ namespace Apache.Qpid.Client.Protocol /// /// Receives notification of any IO exceptions on the connection. /// - ///

Upon receipt of a connection closed exception, the fail-over process is attempted. If the fail-over fails, then all method listeners - /// and the application connection object are notified of the connection failure exception. + ///

Upon receipt of a connection closed exception or any IOException, the fail-over process is attempted. If the fail-over fails, then + /// all method listeners and the application connection object are notified of the connection failure exception. /// - ///

This exception handler only deals with AMQConnectionClosedExceptions, any other exception types are thrown back to the caller. + ///

All other exception types are propagated to all method listeners. ///

public void OnException(Exception cause) { _log.Warn("public void OnException(Exception cause = " + cause + "): called"); - if (cause is AMQConnectionClosedException || cause is System.IO.IOException) + // Ensure that the method listener set cannot be changed whilst this exception is propagated to all listeners. This also + // ensures that this exception is fully propagated to all listeners, before another one can be processed. + lock (_lock) { - // Ensure that the method listener set cannot be changed whilst this exception is propagated to all listeners. This also - // ensures that this exception is fully propagated to all listeners, before another one can be processed. - lock (_lock) + if (cause is AMQConnectionClosedException || cause is System.IO.IOException) { // Try a fail-over because the connection has failed. FailoverState failoverState = AttemptFailover(); @@ -190,11 +190,12 @@ namespace Apache.Qpid.Client.Protocol _connection.ExceptionReceived(cause); } } - } - // Throw the exception back to the caller if it is not of a known type, to ensure unhandled runtimes are not swallowed. - else - { - throw cause; + // Notify all method listeners of the exception. + else + { + PropagateExceptionToWaiters(cause); + _connection.ExceptionReceived(cause); + } } } -- cgit v1.2.1