cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject [1/2] git commit: Preventing possible ThreadLocalClientState NPE
Date Fri, 28 Feb 2014 16:09:21 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 07108f9a1 -> 9423ee7e1


Preventing possible ThreadLocalClientState NPE


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/d86d201d
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/d86d201d
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/d86d201d

Branch: refs/heads/master
Commit: d86d201d00092876a06176638d520fce94e58d89
Parents: 276343f
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Fri Feb 28 16:08:43 2014 +0000
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Fri Feb 28 16:08:43 2014 +0000

----------------------------------------------------------------------
 .../org/apache/cxf/jaxrs/client/ThreadLocalClientState.java | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/d86d201d/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java
b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java
index 033a139..7155941 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java
@@ -120,6 +120,7 @@ public class ThreadLocalClientState implements ClientState {
             cs = new LocalClientState(initialState);
             state.put(Thread.currentThread(), cs);
             if (timeToKeepState > 0) {
+                prepareCheckpointMap();
                 long currentTime = System.currentTimeMillis();
                 checkpointMap.put(Thread.currentThread(), currentTime);
                 new CleanupThread(Thread.currentThread(), currentTime).start();
@@ -131,10 +132,16 @@ public class ThreadLocalClientState implements ClientState {
     public void setTimeToKeepState(long timeToKeepState) {
         this.timeToKeepState = timeToKeepState;
         if (timeToKeepState > 0) {
-            checkpointMap = new ConcurrentHashMap<Thread, Long>();
+            prepareCheckpointMap();
         }
     }
 
+    private void prepareCheckpointMap() {
+        if (checkpointMap == null) {
+            checkpointMap = new ConcurrentHashMap<Thread, Long>();
+        }
+    }
+    
     private class CleanupThread extends Thread {
         private Thread thread;
         private long originalTime;


Mime
View raw message