Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CF6DA10BA3 for ; Fri, 28 Feb 2014 16:09:26 +0000 (UTC) Received: (qmail 61966 invoked by uid 500); 28 Feb 2014 16:09:24 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 61784 invoked by uid 500); 28 Feb 2014 16:09:22 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 61718 invoked by uid 99); 28 Feb 2014 16:09:21 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Feb 2014 16:09:21 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 8D285930AD3; Fri, 28 Feb 2014 16:09:21 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sergeyb@apache.org To: commits@cxf.apache.org Date: Fri, 28 Feb 2014 16:09:21 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/2] git commit: Preventing possible ThreadLocalClientState NPE 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 Authored: Fri Feb 28 16:08:43 2014 +0000 Committer: Sergey Beryozkin 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(); + prepareCheckpointMap(); } } + private void prepareCheckpointMap() { + if (checkpointMap == null) { + checkpointMap = new ConcurrentHashMap(); + } + } + private class CleanupThread extends Thread { private Thread thread; private long originalTime;