[jboss-cvs] JBoss Messaging SVN: r2183 - in trunk: src/main/org/jboss/jms/client/delegate and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Feb 5 06:23:45 EST 2007


Author: timfox
Date: 2007-02-05 06:23:44 -0500 (Mon, 05 Feb 2007)
New Revision: 2183

Modified:
   trunk/src/etc/server/default/deploy/clustered-mysql-persistence-service.xml
   trunk/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java
   trunk/src/main/org/jboss/jms/client/remoting/JMSRemotingConnection.java
   trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java
   trunk/src/main/org/jboss/jms/server/endpoint/ServerBrowserEndpoint.java
   trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
   trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java
   trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
   trunk/src/main/org/jboss/jms/wireformat/Dispatcher.java
   trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeMBeanTest.java
Log:
Added Dispatcher sanity check for http://jira.jboss.com/jira/browse/JBMESSAGING-812, changed default group name and added safe property lookup



Modified: trunk/src/etc/server/default/deploy/clustered-mysql-persistence-service.xml
===================================================================
--- trunk/src/etc/server/default/deploy/clustered-mysql-persistence-service.xml	2007-02-04 09:26:42 UTC (rev 2182)
+++ trunk/src/etc/server/default/deploy/clustered-mysql-persistence-service.xml	2007-02-05 11:23:44 UTC (rev 2183)
@@ -76,7 +76,7 @@
 DELETE_BINDING=DELETE FROM JMS_POSTOFFICE WHERE POSTOFFICE_NAME=? AND NODE_ID=? AND QUEUE_NAME=?
 LOAD_BINDINGS=SELECT NODE_ID, QUEUE_NAME, COND, SELECTOR, CHANNEL_ID, IS_FAILED_OVER, FAILED_NODE_ID FROM JMS_POSTOFFICE WHERE POSTOFFICE_NAME  = ?
       ]]></attribute>
-      <attribute name="GroupName">Queue</attribute>
+      <attribute name="GroupName">DefaultPostOffice</attribute>
       <attribute name="StateTimeout">5000</attribute>
       <attribute name="CastTimeout">5000</attribute>
       <attribute name="StatsSendPeriod">10000</attribute>

Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java	2007-02-04 09:26:42 UTC (rev 2182)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java	2007-02-05 11:23:44 UTC (rev 2183)
@@ -33,10 +33,10 @@
 import org.jboss.jms.wireformat.BrowserHasNextMessageRequest;
 import org.jboss.jms.wireformat.BrowserNextMessageBlockRequest;
 import org.jboss.jms.wireformat.BrowserNextMessageRequest;
+import org.jboss.jms.wireformat.BrowserResetRequest;
 import org.jboss.jms.wireformat.CloseRequest;
 import org.jboss.jms.wireformat.ClosingRequest;
 import org.jboss.jms.wireformat.RequestSupport;
-import org.jboss.jms.wireformat.BrowserResetRequest;
 
 /**
  * The client-side Browser delegate class.

Modified: trunk/src/main/org/jboss/jms/client/remoting/JMSRemotingConnection.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/remoting/JMSRemotingConnection.java	2007-02-04 09:26:42 UTC (rev 2182)
+++ trunk/src/main/org/jboss/jms/client/remoting/JMSRemotingConnection.java	2007-02-05 11:23:44 UTC (rev 2183)
@@ -54,6 +54,23 @@
    public static final String CALLBACK_POLL_PERIOD_DEFAULT = "100";
 
    private static final Logger log = Logger.getLogger(JMSRemotingConnection.class);
+   
+   private static String getPropertySafely(String propName)
+   {
+      String prop = null;
+      
+      try
+      {
+         prop = System.getProperty(propName);
+      }
+      catch (Exception ignore)
+      {
+         //May get a security exception depending on security permissions, in which case
+         //we return null
+      }
+      
+      return prop;
+   }
 
    // Static ---------------------------------------------------------------------------------------
 
@@ -89,13 +106,15 @@
          metadata.put(SocketServerInvoker.SERVER_SOCKET_CLASS_FLAG,
                       "org.jboss.jms.server.remoting.ServerSocketWrapper");
 
-         String bindAddress = System.getProperty("jboss.messaging.callback.bind.address");
+         String bindAddress = getPropertySafely("jboss.messaging.callback.bind.address");
+                  
          if (bindAddress != null)
          {
             metadata.put(Client.CALLBACK_SERVER_HOST, bindAddress);
          }
 
-         String propertyPort = System.getProperty("jboss.messaging.callback.bind.port");
+         String propertyPort = getPropertySafely("jboss.messaging.callback.bind.port");
+                  
          if (propertyPort != null)
          {
             metadata.put(Client.CALLBACK_SERVER_PORT, propertyPort);
@@ -105,7 +124,7 @@
       {
          // "jboss.messaging.callback.pollPeriod" system property, if set, has the
          // highest priority ...
-         String callbackPollPeriod = System.getProperty("jboss.messaging.callback.pollPeriod");
+         String callbackPollPeriod = getPropertySafely("jboss.messaging.callback.pollPeriod");
 
          if (callbackPollPeriod == null)
          {
@@ -121,7 +140,7 @@
          metadata.put(CallbackPoller.CALLBACK_POLL_PERIOD, callbackPollPeriod);
 
          String reportPollingStatistics =
-            System.getProperty("jboss.messaging.callback.reportPollingStatistics");
+            getPropertySafely("jboss.messaging.callback.reportPollingStatistics");
 
          if (reportPollingStatistics != null)
          {
@@ -333,7 +352,7 @@
    // Protected ------------------------------------------------------------------------------------
 
    // Private --------------------------------------------------------------------------------------
-
+   
    // Inner classes --------------------------------------------------------------------------------
 
 }

Modified: trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java	2007-02-04 09:26:42 UTC (rev 2182)
+++ trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java	2007-02-05 11:23:44 UTC (rev 2183)
@@ -255,7 +255,7 @@
 
       }
 
-      Dispatcher.instance.unregisterTarget(endpoint.getID());
+      Dispatcher.instance.unregisterTarget(endpoint.getID(), delegate);
    }
 
    // MessagingComponent implementation ------------------------------------------------------------

Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerBrowserEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerBrowserEndpoint.java	2007-02-04 09:26:42 UTC (rev 2182)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerBrowserEndpoint.java	2007-02-05 11:23:44 UTC (rev 2183)
@@ -230,7 +230,7 @@
       
       iterator = null;
       
-      Dispatcher.instance.unregisterTarget(id);
+      Dispatcher.instance.unregisterTarget(id, this);
       
       closed = true;
    }

Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java	2007-02-04 09:26:42 UTC (rev 2182)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java	2007-02-05 11:23:44 UTC (rev 2183)
@@ -403,7 +403,7 @@
    
          cm.unregisterConnection(jmsClientVMID, remotingClientSessionID);
    
-         Dispatcher.instance.unregisterTarget(id);
+         Dispatcher.instance.unregisterTarget(id, this);
 
          closed = true;
       }

Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java	2007-02-04 09:26:42 UTC (rev 2182)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java	2007-02-05 11:23:44 UTC (rev 2183)
@@ -460,7 +460,7 @@
 
       messageQueue.remove(this); 
       
-      Dispatcher.instance.unregisterTarget(id);
+      Dispatcher.instance.unregisterTarget(id, this);
       
       // If this is a consumer of a non durable subscription then we want to unbind the
       // subscription and delete all its data.

Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java	2007-02-04 09:26:42 UTC (rev 2182)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java	2007-02-05 11:23:44 UTC (rev 2183)
@@ -879,7 +879,7 @@
       
       sp.removeSession(new Integer(id));
             
-      Dispatcher.instance.unregisterTarget(id);
+      Dispatcher.instance.unregisterTarget(id, this);
       
       closed = true;
    }            

Modified: trunk/src/main/org/jboss/jms/wireformat/Dispatcher.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/Dispatcher.java	2007-02-04 09:26:42 UTC (rev 2182)
+++ trunk/src/main/org/jboss/jms/wireformat/Dispatcher.java	2007-02-05 11:23:44 UTC (rev 2183)
@@ -23,6 +23,9 @@
 
 import java.util.Map;
 
+import org.jboss.jms.server.endpoint.advised.AdvisedSupport;
+import org.jboss.logging.Logger;
+
 import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
 
 /**
@@ -36,6 +39,8 @@
  */
 public class Dispatcher
 {
+   private static final Logger log = Logger.getLogger(Dispatcher.class);
+   
    public static Dispatcher instance = new Dispatcher();
    
    private Map targets;
@@ -65,14 +70,34 @@
       registerTarget(new Integer(id), obj);
    }
    
-   public boolean unregisterTarget(Integer id)
+   public boolean unregisterTarget(Integer id, Object endpoint)
    {
-      return targets.remove(id) != null;
+      //Note that we pass the object id in, this is as a sanity check
+      //to ensure the object we are deregistering is the correct one
+      //since there have been bugs related to removing deregistering the wrong object
+      //This can happen if an earlier test opens a connection then the test ends without closing
+      //the connection, then on the server side the serverpeer is restarted which resets the object
+      //counter, so a different object is registered under the id of the old object.
+      //Remoting then times out the old connection and dereigsters the new object which is
+      //registered under the same id
+      //See http://jira.jboss.com/jira/browse/JBMESSAGING-812
+      
+      AdvisedSupport advised = (AdvisedSupport)(targets.get(id));
+           
+      if (advised.getEndpoint() != endpoint)
+      {
+         log.warn("The object you are trying to deregister is not the same as the one you registered!");
+         return false;
+      }
+      else
+      {      
+         return targets.remove(id) != null;
+      }
    }
    
-   public boolean unregisterTarget(int id)
-   {
-      return unregisterTarget(new Integer(id));
+   public boolean unregisterTarget(int id, Object obj)
+   {      
+      return unregisterTarget(new Integer(id), obj);
    }
    
 }

Modified: trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeMBeanTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeMBeanTest.java	2007-02-04 09:26:42 UTC (rev 2182)
+++ trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeMBeanTest.java	2007-02-05 11:23:44 UTC (rev 2183)
@@ -257,7 +257,7 @@
          
       }
       finally
-      {
+      {         
          if (connSource != null)
          {
             connSource.close();
@@ -267,6 +267,15 @@
          {
             connTarget.close();
          }
+         
+         try
+         {
+            ServerManagement.getServer(0).invoke(on, "destroy", new Object[0], new String[0]);
+         }
+         catch(Exception e)
+         {
+            //Ignore            
+         }
       }
    }
          
@@ -275,6 +284,8 @@
       ServerManagement.deployQueue("sourceQueue", 1);
       ServerManagement.deployQueue("targetQueue", 2);
       
+      ObjectName on = null;
+      
       try
       {         
          Thread.sleep(5000);
@@ -289,7 +300,7 @@
          
          String sprops2 = tableToString(props2);
          
-         ObjectName on = deployBridge(0, "Bridge1", "/XAConnectionFactory", "/XAConnectionFactory",
+         on = deployBridge(0, "Bridge1", "/XAConnectionFactory", "/XAConnectionFactory",
                                       "/queue/sourceQueue", "/queue/targetQueue",
                                       null, null, null, null,
                                       Bridge.QOS_ONCE_AND_ONLY_ONCE, null, 1,
@@ -588,10 +599,22 @@
          
          log.trace("Checked bridge");
          
-         
       }
       finally
       {
+         try
+         {
+            if (on != null)
+            {
+               ServerManagement.getServer(0).invoke(on, "stop", new Object[0], new String[0]);
+               ServerManagement.getServer(0).invoke(on, "destroy", new Object[0], new String[0]);
+            }
+         }
+         catch(Exception e)
+         {
+            //Ignore            
+         }         
+         
          ServerManagement.undeployQueue("sourceQueue", 1);
          ServerManagement.undeployQueue("targetQueue", 2);
       }




More information about the jboss-cvs-commits mailing list