cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clecl...@apache.org
Subject svn commit: r910415 - in /cxf/branches/2.2.x-fixes: ./ rt/management/src/main/java/org/apache/cxf/management/counters/CounterRepository.java
Date Tue, 16 Feb 2010 07:14:34 GMT
Author: cleclerc
Date: Tue Feb 16 07:14:33 2010
New Revision: 910415

URL: http://svn.apache.org/viewvc?rev=910415&view=rev
Log:
Merged revisions 910414 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r910414 | cleclerc | 2010-02-16 08:08:11 +0100 (Tue, 16 Feb 2010) | 2 lines
  
  [CXF-2676] JMX InstanceAlreadyExistsException under high load initialization
  Add lock around counter creation
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/management/src/main/java/org/apache/cxf/management/counters/CounterRepository.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Feb 16 07:14:33 2010
@@ -1 +1 @@
-/cxf/trunk:909927-909933,910308
+/cxf/trunk:909927-909933,910308,910414

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/rt/management/src/main/java/org/apache/cxf/management/counters/CounterRepository.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/management/src/main/java/org/apache/cxf/management/counters/CounterRepository.java?rev=910415&r1=910414&r2=910415&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/management/src/main/java/org/apache/cxf/management/counters/CounterRepository.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/management/src/main/java/org/apache/cxf/management/counters/CounterRepository.java
Tue Feb 16 07:14:33 2010
@@ -21,6 +21,8 @@
 
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -48,6 +50,7 @@
     
     private Map<ObjectName, Counter> counters;
     private Bus bus;
+    private Lock counterCreationLock = new ReentrantLock();
     
     public CounterRepository() {
         counters = new ConcurrentHashMap<ObjectName, Counter>();
@@ -84,9 +87,18 @@
     
     public void increaseCounter(ObjectName on, MessageHandlingTimeRecorder mhtr) {
         Counter counter = getCounter(on);
-        if (null == counter) {            
-            counter = createCounter(on, mhtr);
-            counters.put(on, counter);
+        if (null == counter) {
+            counterCreationLock.lock();
+            try {
+                // check if the counter has been created during the locked time
+                counter = getCounter(on);
+                if (counter == null) {
+                    counter = createCounter(on, mhtr);
+                    counters.put(on, counter);
+                }
+            } finally {
+                counterCreationLock.unlock();
+            }
         }
         counter.increase(mhtr);        
         if (LOG.isLoggable(Level.FINE)) {



Mime
View raw message