db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r636583 - in /db/derby/code/trunk/java: drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java engine/org/apache/derby/impl/services/jmx/JMXManagementService.java
Date Thu, 13 Mar 2008 00:00:33 GMT
Author: djd
Date: Wed Mar 12 17:00:31 2008
New Revision: 636583

URL: http://svn.apache.org/viewvc?rev=636583&view=rev
Log:
DERBY-1387 Make the registration of MBeans with JMX robust in the case of permission issues.
Stops a hang in derbynet._Suite where a network server was booted with insufficient permissions
for MBeans.

Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/jmx/JMXManagementService.java

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?rev=636583&r1=636582&r2=636583&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
(original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
Wed Mar 12 17:00:31 2008
@@ -776,17 +776,17 @@
         ManagementService mgmtService = ((ManagementService)
                 Monitor.getSystemModule(Module.JMX));
         
-        Object versionMBean = mgmtService.registerMBean(
+        final Object versionMBean = mgmtService.registerMBean(
                            new Version(
                                    getNetProductVersionHolder(),
                                    null /*SystemPermission.SERVER*/),
                            VersionMBean.class,
                            "type=Version,jar=derbynet.jar");
-        Object networkServerMBean = mgmtService.registerMBean(
+        final Object networkServerMBean = mgmtService.registerMBean(
                             new NetworkServerMBeanImpl(this),
                             NetworkServerMBean.class,
                             "type=NetworkServer");
-        			
+                			
 		// wait until we are told to shutdown or someone sends an InterruptedException
         synchronized(shutdownSync) {
             try {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/jmx/JMXManagementService.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/jmx/JMXManagementService.java?rev=636583&r1=636582&r2=636583&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/jmx/JMXManagementService.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/jmx/JMXManagementService.java
Wed Mar 12 17:00:31 2008
@@ -175,9 +175,12 @@
                     });
             
         } catch (SecurityException se) {
-            // TODO: just ignoring inability to create or
-            // find the mbean server.
-            // or should an error or warning be raised?
+            // Ignoring inability to create or
+            // find the mbean server. MBeans can continue
+            // to be registered with this service and
+            // startMangement() can be called to get
+            // them registered with JMX if someone else
+            // starts the MBean server.
         }
     }
 
@@ -240,6 +243,11 @@
     private void jmxRegister(final StandardMBean standardMBean,
             final ObjectName beanName) throws JMException
     {
+        // Already registered? Can happen if we don't have permission
+        // to unregister the MBeans.
+        if (mbeanServer.isRegistered(beanName))
+            return;
+            
         try {
 
             AccessController
@@ -254,6 +262,10 @@
 
         } catch (PrivilegedActionException pae) {
             throw (JMException) pae.getException();
+        } catch (SecurityException se) {
+            // If we can't register the MBean then so be it.
+            // The application can later enabled the MBeans
+            // by using org.apache.derby.mbeans.Management
         }
     }
     
@@ -312,6 +324,10 @@
             // JMException jme = (JMException) pae.getException();
             //if (!(jme instanceof InstanceNotFoundException))
                 // throw StandardException.plainWrapException(jme);
+        } catch (SecurityException se) {
+            // Can't unregister the MBean we registered due to permission
+            // problems, oh-well just leave it there. We are fail-safe
+            // if we attempt to re-register it.
         }
     }
 



Mime
View raw message