Skip to main content

[glassfish~svn:50754] roll back svn rev 50745 since it's introducing FindBugs High Priority err

  • From: janey@...
  • To: commits@...
  • Subject: [glassfish~svn:50754] roll back svn rev 50745 since it's introducing FindBugs High Priority err
  • Date: Wed, 9 Nov 2011 19:57:57 +0000

Project:    glassfish
Repository: svn
Revision:   50754
Author:     janey
Date:       2011-11-09 19:57:55 UTC
Link:       

Log Message:
------------
roll back svn rev 50745 since it's introducing FindBugs High Priority errors.




Revisions:
----------
50754


Modified Paths:
---------------
trunk/main/nucleus/common/mbeanserver/src/main/java/org/glassfish/admin/mbeanserver/JMXStartupService.java
trunk/main/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/MbeanService.java


Diffs:
------
Index: 
trunk/main/nucleus/common/mbeanserver/src/main/java/org/glassfish/admin/mbeanserver/JMXStartupService.java
===================================================================
--- 
trunk/main/nucleus/common/mbeanserver/src/main/java/org/glassfish/admin/mbeanserver/JMXStartupService.java
  (revision 50753)
+++ 
trunk/main/nucleus/common/mbeanserver/src/main/java/org/glassfish/admin/mbeanserver/JMXStartupService.java
  (revision 50754)
@@ -41,11 +41,15 @@
 
 import java.util.logging.Level;
 import java.util.logging.Logger;
-import javax.management.*;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanRegistrationException;
 
 import com.sun.logging.LogDomains;
 import org.jvnet.hk2.annotations.Service;
 
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
 import org.glassfish.api.Startup;
 import org.glassfish.api.Async;
 
@@ -59,20 +63,18 @@
 import java.util.ArrayList;
 
 import java.lang.management.ManagementFactory;
-
 import com.sun.enterprise.config.serverbeans.AdminService;
 import com.sun.enterprise.config.serverbeans.JmxConnector;
 import com.sun.enterprise.config.serverbeans.Domain;
 
 import org.glassfish.grizzly.config.dom.Ssl;
-
 import javax.management.remote.JMXConnectorServer;
 import javax.management.remote.JMXServiceURL;
 
 
 import java.io.IOException;
 import java.util.Set;
-
+import javax.management.JMException;
 import org.glassfish.api.admin.ServerEnvironment;
 import org.glassfish.api.event.EventListener;
 import org.glassfish.api.event.EventTypes;
@@ -80,8 +82,8 @@
 import org.glassfish.internal.api.*;
 
 /**
- * Responsible for creating the {@link BootAMXMBean}, and starting 
JMXConnectors,
- * which will initialize (boot) AMX when a connection arrives.
+Responsible for creating the {@link BootAMXMBean}, and starting 
JMXConnectors,
+which will initialize (boot) AMX when a connection arrives.
  */
 @Service
 public final class JMXStartupService implements PostStartup, PostConstruct {
@@ -89,12 +91,11 @@
     private static void debug(final String s) {
         System.out.println("### " + s);
     }
-
     @Inject
     private MBeanServer mMBeanServer;
     @Inject
     private Domain mDomain;
-    @Inject(name = ServerEnvironment.DEFAULT_INSTANCE_NAME)
+    @Inject(name=ServerEnvironment.DEFAULT_INSTANCE_NAME)
     private AdminService mAdminService;
     @Inject
     private Habitat mHabitat;
@@ -140,19 +141,14 @@
     private synchronized void shutdown() {
         mLogger.fine("JMXStartupService: shutting down AMX and JMX");
 
-        if (mBootAMX != null) mBootAMX.shutdown();
+        if(mBootAMX != null) mBootAMX.shutdown();
         mBootAMX = null;
 
-        if (mConnectorsStarterThread != null) 
mConnectorsStarterThread.shutdown();
+        if(mConnectorsStarterThread != null) 
mConnectorsStarterThread.shutdown();
         mConnectorsStarterThread = null;
 
         // we can't block here waiting, we have to assume that the rest of 
the AMX modules do the right thing
         mLogger.log(java.util.logging.Level.INFO, 
"jmx.startupService.shutdown");
-
-        if (javax.management.MBeanServerFactory.findMBeanServer(null).size() 
> 0) {
-            MBeanServer server = 
javax.management.MBeanServerFactory.findMBeanServer(null).get(0);
-            javax.management.MBeanServerFactory.releaseMBeanServer(server);
-        }
     }
 
     private static final class BootAMXThread extends Thread {
@@ -169,7 +165,7 @@
     }
 
     /**
-     * Thread that starts the configured JMXConnectors.
+    Thread that starts the configured JMXConnectors.
      */
     private static final class JMXConnectorsStarterThread extends Thread {
 
@@ -197,7 +193,7 @@
                 ((RMIConnectorStarter) starter).stopAndUnexport();
             }
             try {
-                if (connObjectName != null) {
+                if(connObjectName != null) {
                     mMBeanServer.unregisterMBean(connObjectName);
                     connObjectName = null;
                 }
@@ -205,12 +201,12 @@
                 mLogger.log(Level.SEVERE, "jmx.MBeanRegistrationException", 
ex);
             } catch (InstanceNotFoundException ex) {
                 mLogger.log(Level.SEVERE, "jmx.InstanceNotFoundException", 
ex);
-            }
+            } 
             for (final JMXConnectorServer connector : mConnectorServers) {
                 try {
                     final JMXServiceURL address = connector.getAddress();
                     connector.stop();
-                    mLogger.log(Level.INFO, 
"jmx.startupService.stopped.jmxconnector", address);
+                    
mLogger.log(Level.INFO,"jmx.startupService.stopped.jmxconnector",address);
                 } catch (final Exception e) {
                     e.printStackTrace();
                 }
@@ -244,25 +240,25 @@
             final BootAMXListener listener = mNeedBootListeners ? new 
BootAMXListener(server, mAMXBooterNew) : null;
             if (protocol.equals("rmi_jrmp")) {
                 starter = new RMIConnectorStarter(mMBeanServer, address, 
port,
-                        protocol, authRealmName, securityEnabled, habitat,
-                        listener, ssl);
+                            protocol, authRealmName, securityEnabled, 
habitat,
+                                listener, ssl);
                 server = ((RMIConnectorStarter) starter).start();
             } else if (protocol.equals("jmxmp")) {
                 starter = new JMXMPConnectorStarter(mMBeanServer, address, 
port,
-                        authRealmName, securityEnabled,
-                        habitat, listener, ssl);
+                            authRealmName, securityEnabled,
+                                habitat, listener, ssl);
                 server = ((JMXMPConnectorStarter) starter).start();
             } else {
                 throw new 
IllegalArgumentException("JMXStartupService.startConnector(): Unknown 
protocol: " + protocol);
             }
 
             final JMXServiceURL url = server.getAddress();
-            mLogger.log(Level.INFO, "jmx.startedservice", url);
+            mLogger.log(Level.INFO,"jmx.startedservice",url);
 
             try {
                 connObjectName = new ObjectName(JMX_CONNECTOR_SERVER_PREFIX 
+ ",protocol=" + protocol + ",name=" + connConfig.getName());
                 ObjectName connObjectName1 = 
mMBeanServer.registerMBean(server, connObjectName).getObjectName();
-            } catch (final Exception e) {
+           } catch (final Exception e) {
                 // it's not critical to have it registered as an MBean
                 e.printStackTrace();
             }
@@ -276,13 +272,12 @@
 
             return server;
         }
-
         private final List<JMXConnectorServer> mConnectorServers = new 
ArrayList<JMXConnectorServer>();
 
         public void run() {
             for (final JmxConnector c : mConfiguredConnectors) {
                 if (!Boolean.parseBoolean(c.getEnabled())) {
-                    mLogger.log(Level.INFO, "jmx.startedservice.disabled", 
c.getName());
+                    
mLogger.log(Level.INFO,"jmx.startedservice.disabled",c.getName());
                     continue;
                 }
 
@@ -290,13 +285,12 @@
                     final JMXConnectorServer server = startConnector(c);
                     mConnectorServers.add(server);
                 } catch (final Throwable t) {
-                    mLogger.log(Level.WARNING, 
"jmx.cannotstart.jmxconnector", new Object[]{toString(c), t});
+                    
mLogger.log(Level.WARNING,"jmx.cannotstart.jmxconnector", new Object[] 
{toString(c),t});
                     t.printStackTrace();
                 }
             }
         }
     }
-
     public static final String JMX_CONNECTOR_SERVER_PREFIX = 
"jmxremote:type=jmx-connector-server";
 
     public static final Set<ObjectName> getJMXConnectorServers(final 
MBeanServer server) {
@@ -309,7 +303,7 @@
     }
 
     /**
-     * Return the JMXServiceURLs for all connectors we've loaded.
+    Return the JMXServiceURLs for all connectors we've loaded.
      */
     public static JMXServiceURL[] getJMXServiceURLs(final MBeanServer 
server) {
         final Set<ObjectName> objectNames = getJMXConnectorServers(server);
Index: 
trunk/main/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/MbeanService.java
===================================================================
--- 
trunk/main/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/MbeanService.java
  (revision 50753)
+++ 
trunk/main/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/MbeanService.java
  (revision 50754)
@@ -59,7 +59,6 @@
 import java.util.Properties;
 import java.util.List;
 import java.util.ArrayList;
-
 import org.glassfish.api.admin.ServerEnvironment;
 
 @Service
@@ -78,35 +77,27 @@
     @Inject
     private static ServerEnvironment env;
 
-    static MbeanService mbeanService;
-
-    public MbeanService() {
-        mbeanService = this;
-    }
-
     @Override
     public Lifecycle getLifecycle() {
         return Startup.Lifecycle.SERVER;
     }
 
     public static MbeanService getInstance() {
-        if (habitat == null)
+        if(habitat == null)
             return null;
-        if (mbeanService != null)
-            return mbeanService;
         return habitat.getComponent(MbeanService.class);
     }
 
     public String getHost(String instance) throws InstanceNotFoundException {
         Server s = domain.getServerNamed(instance);
-        if (s == null)
+        if(s == null)
             throw new InstanceNotFoundException();
         return s.getAdminHost();
     }
 
     public String getJMXPort(String instance) throws 
InstanceNotFoundException {
         Server s = domain.getServerNamed(instance);
-        if (s == null)
+        if(s == null)
             throw new InstanceNotFoundException();
         return new PropertyResolver(domain, 
instance).getPropertyValue("JMX_SYSTEM_CONNECTOR_PORT");
     }
@@ -119,7 +110,7 @@
         Server s = null;
         try {
             s = domain.getServerNamed(name);
-        } catch (Throwable t) {
+        } catch(Throwable t) {
             return false;
         }
         return (s == null) ? false : true;
@@ -135,7 +126,7 @@
 
     private List<String> convertList(List<Server> servers) {
         List<String> serverStrings = new ArrayList<String>();
-        for (Server svr : servers)
+        for(Server svr : servers)
             serverStrings.add(svr.getName());
         return serverStrings;
     }
@@ -146,15 +137,14 @@
 
     /**
      * Returns if the SystemJMXConnector is secure or not
-     *
      * @param instance
      * @return
      */
     public boolean isSecureJMX(String instance) {
         String isSecure = "false";
-        if (domain.getServerNamed(instance) != null) {
+        if(domain.getServerNamed(instance) != null ) {
             if 
(domain.getServerNamed(instance).getConfig().getAdminService().getSystemJmxConnector()
 != null) {
-                isSecure = 
domain.getServerNamed(instance).getConfig().getAdminService().getSystemJmxConnector().getSecurityEnabled();
+                isSecure= 
domain.getServerNamed(instance).getConfig().getAdminService().getSystemJmxConnector().getSecurityEnabled();
             }
         }
         return Boolean.parseBoolean(isSecure);





[glassfish~svn:50754] roll back svn rev 50745 since it's introducing FindBugs High Priority err

janey 11/09/2011
 
 
Close
loading
Please Confirm
Close