cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1152084 - /cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java
Date Fri, 29 Jul 2011 03:18:04 GMT
Author: dkulp
Date: Fri Jul 29 03:18:03 2011
New Revision: 1152084

URL: http://svn.apache.org/viewvc?rev=1152084&view=rev
Log:
[CXF-3696] FIx potential lockup in BusFactory

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java?rev=1152084&r1=1152083&r2=1152084&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java Fri Jul 29 03:18:03 2011
@@ -148,19 +148,24 @@ public abstract class BusFactory {
     public static Bus getThreadDefaultBus(boolean createIfNeeded) {
         Bus threadBus;
         synchronized (threadBusses) {
-            if (createIfNeeded) {
-                threadBus = threadBusses.get(Thread.currentThread());
-                if (createIfNeeded && threadBus == null) {
-                    threadBus = getDefaultBus(true);
-                    threadBusses.put(Thread.currentThread(), threadBus);
-                }
-            } else {
-                threadBus = threadBusses.get(Thread.currentThread());
-            }
+            threadBus = threadBusses.get(Thread.currentThread());
+        }
+        if (createIfNeeded && threadBus == null) {
+            threadBus = createThreadBus();
+        }
+        return threadBus;
+    }
+    private static synchronized Bus createThreadBus() {
+        Bus threadBus;
+        synchronized (threadBusses) {
+            threadBus = threadBusses.get(Thread.currentThread());
+        }
+        if (threadBus == null) {
+            threadBus = getDefaultBus(true);
+            threadBusses.put(Thread.currentThread(), threadBus);
         }
         return threadBus;
     }
-
     /**
      * Removes a bus from being a thread default bus for any thread.
      * <p>



Mime
View raw message