commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1572118 - in /commons/proper/dbcp/trunk/src: changes/changes.xml main/java/org/apache/commons/dbcp2/BasicDataSource.java
Date Wed, 26 Feb 2014 16:03:11 GMT
Author: sebb
Date: Wed Feb 26 16:03:11 2014
New Revision: 1572118

URL: http://svn.apache.org/r1572118
Log:
DBCP-411 BasicManagedDataSource - unregister from JMX on close()

Modified:
    commons/proper/dbcp/trunk/src/changes/changes.xml
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java

Modified: commons/proper/dbcp/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/changes/changes.xml?rev=1572118&r1=1572117&r2=1572118&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/changes/changes.xml (original)
+++ commons/proper/dbcp/trunk/src/changes/changes.xml Wed Feb 26 16:03:11 2014
@@ -43,7 +43,10 @@ The <action> type attribute can be add,u
      4.1, so requires Java 7.  Java 6 users should use DBCP 1.4.x which supports
      JDBC 4. Java 1.4 and Java 5 users should use DBCP 1.3.x which supports JDBC
      3. Applications running under Java 7 should use DBCP 2.0.x.">
-      <action issue="DBCP-154" dev="markt" type="fix">
+      <action issue="DBCP-411" dev="sebb" type="fix">
+        BasicManagedDataSource - unregister from JMX on close().
+      </action>
+        <action issue="DBCP-154" dev="markt" type="fix">
         Log validation failures of poolable connections.
       </action>
       <action issue="DBCP-403" dev="sebb" type="fix">

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java?rev=1572118&r1=1572117&r2=1572118&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
Wed Feb 26 16:03:11 2014
@@ -36,6 +36,7 @@ import java.util.Properties;
 import java.util.logging.Logger;
 
 import javax.management.InstanceAlreadyExistsException;
+import javax.management.JMException;
 import javax.management.MBeanRegistration;
 import javax.management.MBeanRegistrationException;
 import javax.management.MBeanServer;
@@ -1829,6 +1830,16 @@ public class BasicDataSource implements 
      * @throws SQLException if an error occurs closing idle connections
      */
     public synchronized void close() throws SQLException {
+        if (registeredJmxName != null) {
+            MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+            try {
+                mbs.unregisterMBean(registeredJmxName);
+            } catch (JMException e) {
+                log.warn("Failed to unregister the JMX name: " + registeredJmxName, e);
+            } finally {
+                registeredJmxName = null;
+            }
+        }
         closed = true;
         GenericObjectPool<?> oldpool = connectionPool;
         connectionPool = null;



Mime
View raw message