activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1227186 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java
Date Wed, 04 Jan 2012 15:20:56 GMT
Author: chirino
Date: Wed Jan  4 15:20:55 2012
New Revision: 1227186

URL: http://svn.apache.org/viewvc?rev=1227186&view=rev
Log:
Fixes AMQ-3651 : If the broker binds RMI registry port when it starts up, the broker should
release RMI registry port when it shuts down

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java?rev=1227186&r1=1227185&r2=1227186&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java
Wed Jan  4 15:20:55 2012
@@ -64,6 +64,7 @@ public class ManagementContext implement
     private JMXConnectorServer connectorServer;
     private ObjectName namingServiceObjectName;
     private Registry registry;
+    private ServerSocket registrySocket;
     private final List<ObjectName> registeredMBeanNames = new CopyOnWriteArrayList<ObjectName>();
     private boolean allowRemoteAddressInMBeanNames = true;
 
@@ -146,6 +147,13 @@ public class ManagementContext implement
                 }
             }
             beanServer = null;
+            if(registrySocket!=null) {
+                try {
+                    registrySocket.close();
+                } catch (IOException e) {
+                }
+                registrySocket = null;
+            }
         }
     }
 
@@ -419,12 +427,13 @@ public class ManagementContext implement
                 registry = LocateRegistry.createRegistry(connectorPort, null, new RMIServerSocketFactory()
{
                     public ServerSocket createServerSocket(int port)
                             throws IOException {
-                        ServerSocket result = new ServerSocket(port);
-                        result.setReuseAddress(true);
-                        return result;
+                        registrySocket = new ServerSocket(port);
+                        registrySocket.setReuseAddress(true);
+                        return registrySocket;
                     }});
             }
             namingServiceObjectName = ObjectName.getInstance("naming:type=rmiregistry");
+
             // Do not use the createMBean as the mx4j jar may not be in the
             // same class loader than the server
             Class cl = Class.forName("mx4j.tools.naming.NamingService");



Mime
View raw message