Author: kwall
Date: Sun Feb  5 12:27:59 2012
New Revision: 1240708

URL: http://svn.apache.org/viewvc?rev=1240708&view=rev
Log:
QPID-3812: ExceptionListenerTest sporadically fails on java-mms-0.10

Remove possibility of race condition by updating Broker state *before* sending 
the connection reply.

Modified:
    
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionDelegate.java

Modified: 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionDelegate.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionDelegate.java?rev=1240708&r1=1240707&r2=1240708&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionDelegate.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerConnectionDelegate.java
 Sun Feb  5 12:27:59 2012
@@ -32,6 +32,8 @@ import org.apache.qpid.server.security.a
 import org.apache.qpid.server.subscription.Subscription_0_10;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.transport.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.security.sasl.SaslException;
 import javax.security.sasl.SaslServer;
@@ -46,6 +48,8 @@ import java.util.StringTokenizer;
 
 public class ServerConnectionDelegate extends ServerDelegate
 {
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(ServerConnectionDelegate.class);
+
     private final String _localFQDN;
     private final IApplicationRegistry _appRegistry;
     private int _maxNoOfChannels;
@@ -164,19 +168,19 @@ public class ServerConnectionDelegate ex
 
             if (!vhost.getSecurityManager().accessVirtualhost(vhostName, 
((ProtocolEngine) sconn.getConfig()).getRemoteAddress()))
             {
-                sconn.invoke(new 
ConnectionClose(ConnectionCloseCode.CONNECTION_FORCED, "Permission denied 
'"+vhostName+"'"));
                 sconn.setState(Connection.State.CLOSING);
+                sconn.invoke(new 
ConnectionClose(ConnectionCloseCode.CONNECTION_FORCED, "Permission denied 
'"+vhostName+"'"));
             }
             else
             {
-                   sconn.invoke(new ConnectionOpenOk(Collections.emptyList()));
-                   sconn.setState(Connection.State.OPEN);
+                sconn.setState(Connection.State.OPEN);
+                sconn.invoke(new ConnectionOpenOk(Collections.emptyList()));
             }
         }
         else
         {
-            sconn.invoke(new ConnectionClose(ConnectionCloseCode.INVALID_PATH, 
"Unknown virtualhost '"+vhostName+"'"));
             sconn.setState(Connection.State.CLOSING);
+            sconn.invoke(new ConnectionClose(ConnectionCloseCode.INVALID_PATH, 
"Unknown virtualhost '"+vhostName+"'"));
         }
         
     }
@@ -189,7 +193,7 @@ public class ServerConnectionDelegate ex
 
         if (okChannelMax > getChannelMax())
         {
-            _logger.error("Connection '" + sconn.getConnectionId() + "' being 
severed, " +
+            LOGGER.error("Connection '" + sconn.getConnectionId() + "' being 
severed, " +
                     "client connectionTuneOk returned a channelMax (" + 
okChannelMax +
                     ") above the servers offered limit (" + getChannelMax() 
+")");
 



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to