commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1213852 - in /commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl: GenericKeyedObjectPool.java GenericObjectPool.java
Date Tue, 13 Dec 2011 18:48:42 GMT
Author: sebb
Date: Tue Dec 13 18:48:41 2011
New Revision: 1213852

URL: http://svn.apache.org/viewvc?rev=1213852&view=rev
Log:
oname is private and only written once, so make it final

Modified:
    commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
    commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java?rev=1213852&r1=1213851&r2=1213852&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
Tue Dec 13 18:48:41 2011
@@ -256,6 +256,7 @@ public class GenericKeyedObjectPool<K,T>
 
         initStats();
 
+        ObjectName onameTemp = null;
         // JMX Registration
         if (config.isJmxEnabled()) {
             MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
@@ -267,7 +268,7 @@ public class GenericKeyedObjectPool<K,T>
                     ObjectName oname =
                         new ObjectName(ONAME_BASE + jmxNamePrefix + i);
                     mbs.registerMBean(this, oname);
-                    this.oname = oname;
+                    onameTemp = oname;
                     registered = true;
                 } catch (MalformedObjectNameException e) {
                     if (GenericObjectPoolConfig.DEFAULT_JMX_NAME_PREFIX.equals(
@@ -292,6 +293,7 @@ public class GenericKeyedObjectPool<K,T>
                 }
             }
         }
+        this.oname = onameTemp;
     }
 
     //--- configuration methods --------------------------------------
@@ -2131,7 +2133,7 @@ public class GenericKeyedObjectPool<K,T>
     private final Object maxBorrowWaitTimeMillisLock = new Object();
     private volatile long maxBorrowWaitTimeMillis = 0; // @GuardedBy("maxBorrowWaitTimeMillisLock")
 
-    private ObjectName oname = null;
+    private final ObjectName oname;
 
     private static final String ONAME_BASE =
         "org.apache.commoms.pool2:type=GenericKeyedObjectPool,name=";

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java?rev=1213852&r1=1213851&r2=1213852&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java
Tue Dec 13 18:48:41 2011
@@ -210,6 +210,7 @@ public class GenericObjectPool<T> extend
 
         initStats();
 
+        ObjectName onameTemp = null;
         // JMX Registration
         if (config.isJmxEnabled()) {
             MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
@@ -221,7 +222,7 @@ public class GenericObjectPool<T> extend
                     ObjectName oname =
                         new ObjectName(ONAME_BASE + jmxNamePrefix + i);
                     mbs.registerMBean(this, oname);
-                    this.oname = oname;
+                    onameTemp = oname;
                     registered = true;
                 } catch (MalformedObjectNameException e) {
                     if (GenericObjectPoolConfig.DEFAULT_JMX_NAME_PREFIX.equals(
@@ -246,6 +247,7 @@ public class GenericObjectPool<T> extend
                 }
             }
         }
+        this.oname = onameTemp;
     }
 
 
@@ -1581,7 +1583,7 @@ public class GenericObjectPool<T> extend
     private final Object maxBorrowWaitTimeMillisLock = new Object();
     private volatile long maxBorrowWaitTimeMillis = 0; // @GuardedBy("maxBorrowWaitTimeMillisLock")
 
-    private ObjectName oname = null;
+    private final ObjectName oname;
 
     private static final String ONAME_BASE =
         "org.apache.commoms.pool2:type=GenericObjectPool,name=";



Mime
View raw message