You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by jg...@apache.org on 2013/02/27 22:16:21 UTC

svn commit: r1450964 - /activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Connection.cs

Author: jgomes
Date: Wed Feb 27 21:16:21 2013
New Revision: 1450964

URL: http://svn.apache.org/r1450964
Log:
Simplify exception handling.  Compact Framework does not support dynamic assembly reflection.  Also, STOMP protocol has much simpler scenarios.

Modified:
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Connection.cs

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Connection.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Connection.cs?rev=1450964&r1=1450963&r2=1450964&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Connection.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Connection.cs Wed Feb 27 21:16:21 2013
@@ -605,16 +605,13 @@ namespace Apache.NMS.Stomp
 										{
 											ExceptionResponse error = response as ExceptionResponse;
 											NMSException exception = CreateExceptionFromBrokerError(error.Exception);
-											if(exception is InvalidClientIDException)
-											{
-												// This is non-recoverable.
-												// Shutdown the transport connection, and re-create it, but don't start it.
-												// It will be started if the connection is re-attempted.
-												this.transport.Stop();
-												ITransport newTransport = TransportFactory.CreateTransport(this.brokerUri);
-												SetTransport(newTransport);
-												throw exception;
-											}
+											// This is non-recoverable.
+											// Shutdown the transport connection, and re-create it, but don't start it.
+											// It will be started if the connection is re-attempted.
+											this.transport.Stop();
+											ITransport newTransport = TransportFactory.CreateTransport(this.brokerUri);
+											SetTransport(newTransport);
+											throw exception;
 										}
 									}
                                 }
@@ -932,63 +929,7 @@ namespace Apache.NMS.Stomp
 				return new BrokerException(brokerError);
 			}
 
-			NMSException exception = null;
-			String message = brokerError.Message;
-
-			// We only create instances of exceptions from the NMS API
-			Assembly nmsAssembly = Assembly.GetAssembly(typeof(NMSException));
-
-			// First try and see if it's one we populated ourselves in which case
-			// it will have the correct namespace and exception name.
-			Type exceptionType = nmsAssembly.GetType(exceptionClassName, false, true);
-
-			// Exceptions from the broker don't have the same namespace, so we
-			// trim that and try using the NMS namespace to see if we can get an
-			// NMSException based version of the same type.  We have to convert
-			// the JMS prefixed exceptions to NMS also.
-			if(null == exceptionType)
-			{
-				if(exceptionClassName.StartsWith("java.lang.SecurityException"))
-				{
-					exceptionClassName = "Apache.NMS.InvalidClientIDException";
-				}
-				else if(!exceptionClassName.StartsWith("Apache.NMS"))
-				{
-					string transformClassName;
-
-					if(exceptionClassName.Contains("."))
-					{
-						int pos = exceptionClassName.LastIndexOf(".");
-						transformClassName = exceptionClassName.Substring(pos + 1).Replace("JMS", "NMS");
-					}
-					else
-					{
-						transformClassName = exceptionClassName;
-					}
-
-					exceptionClassName = "Apache.NMS." + transformClassName;
-				}
-
-				exceptionType = nmsAssembly.GetType(exceptionClassName, false, true);
-			}
-
-			if(exceptionType != null)
-			{
-				object[] args = null;
-				if(!String.IsNullOrEmpty(message))
-				{
-					args = new object[1];
-					args[0] = message;
-				}
-
-				exception = Activator.CreateInstance(exceptionType, args) as NMSException;
-			}
-			else
-			{
-				exception = new BrokerException(brokerError);
-			}
-
-			return exception;
+			return new InvalidClientIDException(brokerError.Message);
 		}
 	}
 }