cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1541186 - /cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/BusFactory.java
Date Tue, 12 Nov 2013 18:22:40 GMT
Author: dkulp
Date: Tue Nov 12 18:22:39 2013
New Revision: 1541186

URL: http://svn.apache.org/r1541186
Log:
Merged revisions 1541153 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes

........
  r1541153 | dkulp | 2013-11-12 12:05:02 -0500 (Tue, 12 Nov 2013) | 10 lines

  Merged revisions 1541140 via  git cherry-pick from
  https://svn.apache.org/repos/asf/cxf/trunk

  ........
    r1541140 | dkulp | 2013-11-12 11:57:27 -0500 (Tue, 12 Nov 2013) | 2 lines

    Make the thread bus holders final so the jit can optimize the accesses better.

  ........

........

Modified:
    cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/BusFactory.java

Modified: cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/BusFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/BusFactory.java?rev=1541186&r1=1541185&r2=1541186&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/BusFactory.java (original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/BusFactory.java Tue Nov 12 18:22:39
2013
@@ -73,8 +73,8 @@ public abstract class BusFactory {
         volatile boolean stale;
     }
     
-    protected static Map<Thread, BusHolder> threadBusses = new WeakHashMap<Thread,
BusHolder>();
-    protected static ThreadLocal<BusHolder> threadBus = new ThreadLocal<BusHolder>();
+    protected static final Map<Thread, BusHolder> THREAD_BUSSES = new WeakHashMap<Thread,
BusHolder>();
+    protected static final ThreadLocal<BusHolder> THREAD_BUS = new ThreadLocal<BusHolder>();
 
     private static final Logger LOG = LogUtils.getL7dLogger(BusFactory.class);
 
@@ -114,21 +114,21 @@ public abstract class BusFactory {
     }
     
     private static BusHolder getThreadBusHolder(boolean set) {
-        BusHolder h = threadBus.get();
+        BusHolder h = THREAD_BUS.get();
         if (h == null || h.stale) {
             Thread cur = Thread.currentThread();
-            synchronized (threadBusses) {
-                h = threadBusses.get(cur);
+            synchronized (THREAD_BUSSES) {
+                h = THREAD_BUSSES.get(cur);
             }
             if (h == null || h.stale) {
                 h = new BusHolder();
             
-                synchronized (threadBusses) {
-                    threadBusses.put(cur, h);
+                synchronized (THREAD_BUSSES) {
+                    THREAD_BUSSES.put(cur, h);
                 }
             }
             if (set) {
-                threadBus.set(h);
+                THREAD_BUS.set(h);
             }
         }
         return h;
@@ -146,7 +146,7 @@ public abstract class BusFactory {
         b.bus = bus;
         if (bus == null) {
             b.stale = true;
-            threadBus.remove();
+            THREAD_BUS.remove();
         }
     }
 
@@ -157,17 +157,17 @@ public abstract class BusFactory {
      */
     public static void setThreadDefaultBus(Bus bus) {
         if (bus == null) {
-            BusHolder h = threadBus.get();
+            BusHolder h = THREAD_BUS.get();
             if (h == null) {
                 Thread cur = Thread.currentThread();
-                synchronized (threadBusses) {
-                    h = threadBusses.get(cur);
+                synchronized (THREAD_BUSSES) {
+                    h = THREAD_BUSSES.get(cur);
                 }
             }
             if (h != null) {
                 h.bus = null;
                 h.stale = true;
-                threadBus.remove();
+                THREAD_BUS.remove();
             }
         } else {
             BusHolder b = getThreadBusHolder(true);
@@ -183,18 +183,18 @@ public abstract class BusFactory {
      */
     public static Bus getAndSetThreadDefaultBus(Bus bus) {
         if (bus == null) {
-            BusHolder b = threadBus.get();
+            BusHolder b = THREAD_BUS.get();
             if (b == null) {
                 Thread cur = Thread.currentThread();
-                synchronized (threadBusses) {
-                    b = threadBusses.get(cur);
+                synchronized (THREAD_BUSSES) {
+                    b = THREAD_BUSSES.get(cur);
                 }
             }
             if (b != null) {
                 Bus orig = b.bus;
                 b.bus = null;
                 b.stale = true;
-                threadBus.remove();
+                THREAD_BUS.remove();
                 return orig;
             }
             return null;
@@ -228,11 +228,11 @@ public abstract class BusFactory {
             }
             return b.bus;
         }
-        BusHolder h = threadBus.get();
+        BusHolder h = THREAD_BUS.get();
         if (h == null || h.stale) {
             Thread cur = Thread.currentThread();
-            synchronized (threadBusses) {
-                h = threadBusses.get(cur);
+            synchronized (THREAD_BUSSES) {
+                h = THREAD_BUSSES.get(cur);
             }
         }
         return h == null || h.stale ? null : h.bus;
@@ -254,8 +254,8 @@ public abstract class BusFactory {
      * @param bus the bus to remove
      */
     public static void clearDefaultBusForAnyThread(final Bus bus) {
-        synchronized (threadBusses) {
-            for (final Iterator<BusHolder> iterator = threadBusses.values().iterator();
+        synchronized (THREAD_BUSSES) {
+            for (final Iterator<BusHolder> iterator = THREAD_BUSSES.values().iterator();
                 iterator.hasNext();) {
                 BusHolder itBus = iterator.next();
                 if (bus == null || itBus == null || itBus.bus == null



Mime
View raw message