cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r894489 - /incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/JMXEnabledThreadPoolExecutor.java
Date Tue, 29 Dec 2009 21:49:37 GMT
Author: jbellis
Date: Tue Dec 29 21:49:36 2009
New Revision: 894489

URL: http://svn.apache.org/viewvc?rev=894489&view=rev
Log:
fix allowing unregisterMBean to be called more than once.  patch by jbellis

Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/JMXEnabledThreadPoolExecutor.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/JMXEnabledThreadPoolExecutor.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/JMXEnabledThreadPoolExecutor.java?rev=894489&r1=894488&r2=894489&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/JMXEnabledThreadPoolExecutor.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/JMXEnabledThreadPoolExecutor.java
Tue Dec 29 21:49:36 2009
@@ -23,8 +23,7 @@
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
+import javax.management.*;
 
 /**
  * This is a wrapper class for the <i>ScheduledThreadPoolExecutor</i>. It provides
an implementation
@@ -69,24 +68,33 @@
         {
             ManagementFactory.getPlatformMBeanServer().unregisterMBean(new ObjectName(mbeanName));
         }
-        catch (Exception ex)
+        catch (Exception e)
         {
-            // don't let it get in the way, but notify.
-            logger.error(ex.getMessage(), ex);
+            throw new RuntimeException(e);
         }
     }
 
     @Override
-    public void shutdown()
+    public synchronized void shutdown()
     {
-        unregisterMBean();
+        // synchronized, because there is no way to access super.mainLock, which would be
+        // the preferred way to make this threadsafe
+        if (!isShutdown())
+        {
+            unregisterMBean();
+        }
         super.shutdown();
     }
 
     @Override
-    public List<Runnable> shutdownNow()
+    public synchronized List<Runnable> shutdownNow()
     {
-        unregisterMBean();
+        // synchronized, because there is no way to access super.mainLock, which would be
+        // the preferred way to make this threadsafe
+        if (!isShutdown())
+        {
+            unregisterMBean();
+        }
         return super.shutdownNow();
     }
 



Mime
View raw message