activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r385557 - /incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java
Date Mon, 13 Mar 2006 14:17:31 GMT
Author: jstrachan
Date: Mon Mar 13 06:17:14 2006
New Revision: 385557

URL: http://svn.apache.org/viewcvs?rev=385557&view=rev
Log:
fixed possible NPE

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

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java?rev=385557&r1=385556&r2=385557&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java
Mon Mar 13 06:17:14 2006
@@ -63,23 +63,27 @@
         this.beanServer=server;
     }
 
-    public void start() throws IOException{
+    public void start() throws IOException {
         // lets force the MBeanServer to be created if needed
-        if(started.compareAndSet(false,true)){
+        if (started.compareAndSet(false, true)) {
             getMBeanServer();
-            if(connectorServer!=null){
-                try{
-                    getMBeanServer().invoke(namingServiceObjectName,"start",null,null);
-                }catch(Throwable ignore){}
-                Thread t=new Thread("JMX connector"){
-                    public void run(){
-                        try{
-                            if(started.get()&&connectorServer!=null){
-                                connectorServer.start();
-                                log.info("JMX consoles can connect to "+connectorServer.getAddress());
+            if (connectorServer != null) {
+                try {
+                    getMBeanServer().invoke(namingServiceObjectName, "start", null, null);
+                }
+                catch (Throwable ignore) {
+                }
+                Thread t = new Thread("JMX connector") {
+                    public void run() {
+                        try {
+                            JMXConnectorServer server = connectorServer;
+                            if (started.get() && server != null) {
+                                server.start();
+                                log.info("JMX consoles can connect to " + server.getAddress());
                             }
-                        }catch(IOException e){
-                            log.warn("Failed to start jmx connector: "+e.getMessage());
+                        }
+                        catch (IOException e) {
+                            log.warn("Failed to start jmx connector: " + e.getMessage());
                         }
                     }
                 };
@@ -89,23 +93,27 @@
         }
     }
 
-    public void stop() throws IOException{
-        if(started.compareAndSet(true,false)){
-            if(connectorServer!=null){
-                try{
-                    connectorServer.stop();
-                }catch(IOException e){
-                    log.warn("Failed to stop jmx connector: "+e.getMessage());
-                }
-                connectorServer=null;
-                try{
-                    getMBeanServer().invoke(namingServiceObjectName,"stop",null,null);
-                }catch(Throwable ignore){}
+    public void stop() throws IOException {
+        if (started.compareAndSet(true, false)) {
+            JMXConnectorServer server = connectorServer;
+            connectorServer = null;
+            if (server != null) {
+                try {
+                    server.stop();
+                }
+                catch (IOException e) {
+                    log.warn("Failed to stop jmx connector: " + e.getMessage());
+                }
+                try {
+                    getMBeanServer().invoke(namingServiceObjectName, "stop", null, null);
+                }
+                catch (Throwable ignore) {
+                }
             }
-            if(locallyCreateMBeanServer&&beanServer!=null){
+            if (locallyCreateMBeanServer && beanServer != null) {
                 // check to see if the factory knows about this server
-                List list=MBeanServerFactory.findMBeanServer(null);
-                if(list!=null&&!list.isEmpty()&&list.contains(beanServer)){
+                List list = MBeanServerFactory.findMBeanServer(null);
+                if (list != null && !list.isEmpty() && list.contains(beanServer))
{
                     MBeanServerFactory.releaseMBeanServer(beanServer);
                 }
             }



Mime
View raw message