cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asold...@apache.org
Subject git commit: [CXF-5626] Restore former MessageContext into WebServiceContext instead of clearing it
Date Fri, 21 Mar 2014 14:50:23 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 44c3a63f9 -> 4c4ce8b73


[CXF-5626] Restore former MessageContext into WebServiceContext instead of clearing it


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

Branch: refs/heads/master
Commit: 4c4ce8b73cdb5b6af6433667457cd68f60c5f145
Parents: 44c3a63
Author: Alessio Soldano <asoldano@redhat.com>
Authored: Fri Mar 21 15:48:39 2014 +0100
Committer: Alessio Soldano <asoldano@redhat.com>
Committed: Fri Mar 21 15:48:39 2014 +0100

----------------------------------------------------------------------
 .../apache/cxf/jaxws/JAXWSMethodInvoker.java    | 11 ++++++++---
 .../jaxws/context/WebServiceContextImpl.java    | 10 +++++++++-
 .../cxf/jaxws/handler/HandlerChainInvoker.java  | 20 ++++++++++++++++----
 3 files changed, 33 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/4c4ce8b7/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java
b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java
index 695aec1..4a7cddf 100644
--- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java
+++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java
@@ -25,6 +25,7 @@ import java.util.List;
 import java.util.Map;
 
 import javax.xml.ws.Provider;
+import javax.xml.ws.handler.MessageContext;
 import javax.xml.ws.handler.MessageContext.Scope;
 
 import org.apache.cxf.helpers.CastUtils;
@@ -59,7 +60,7 @@ public class JAXWSMethodInvoker extends AbstractJAXWSMethodInvoker {
         
         Map<String, Object> handlerScopedStuff = removeHandlerProperties(ctx);
         
-        WebServiceContextImpl.setMessageContext(ctx);
+        final MessageContext oldCtx = WebServiceContextImpl.setMessageContext(ctx);
         List<Object> res = null;
         try {
             if ((params == null || params.isEmpty()) && m.getDeclaringClass().equals(Provider.class))
{
@@ -87,8 +88,12 @@ public class JAXWSMethodInvoker extends AbstractJAXWSMethodInvoker {
             }
             throw f;
         } finally {
-            //clear the WebServiceContextImpl's ThreadLocal variable
-            WebServiceContextImpl.clear();
+            //restore the WebServiceContextImpl's ThreadLocal variable to the previous value
+            if (oldCtx == null) {
+                WebServiceContextImpl.clear();
+            } else {
+                WebServiceContextImpl.setMessageContext(oldCtx);
+            }
             
             addHandlerProperties(ctx, handlerScopedStuff);
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/4c4ce8b7/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextImpl.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextImpl.java
b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextImpl.java
index eafa9a0..7d19630 100644
--- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextImpl.java
+++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextImpl.java
@@ -133,8 +133,16 @@ public class WebServiceContextImpl implements WebServiceContext {
         }
     }
 
-    public static void setMessageContext(MessageContext ctx) {
+    /**
+     * Sets reference to the specified MessageContext and returns the previous reference,
if any.
+     * 
+     * @param ctx       The MessageContext to set
+     * @return          The former MessageContext reference, if any.
+     */
+    public static MessageContext setMessageContext(MessageContext ctx) {
+        MessageContext oldCtx = context.get();
         context.set(ctx);
+        return oldCtx;
     }
 
     public static void clear() {

http://git-wip-us.apache.org/repos/asf/cxf/blob/4c4ce8b7/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java
b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java
index 5f75ed5..4d51df7 100644
--- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java
+++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java
@@ -249,11 +249,17 @@ public class HandlerChainInvoker {
         }
 
         boolean continueProcessing = true;
+        MessageContext oldCtx = null;
         try {
-            WebServiceContextImpl.setMessageContext(ctx);
+            oldCtx = WebServiceContextImpl.setMessageContext(ctx);
             continueProcessing = invokeHandleMessage(handlerChain, ctx);
         } finally {
-            WebServiceContextImpl.clear();
+            // restore the WebServiceContextImpl's ThreadLocal variable to the previous value
+            if (oldCtx == null) {
+                WebServiceContextImpl.clear();
+            } else {
+                WebServiceContextImpl.setMessageContext(oldCtx);
+            }
         }
 
         return continueProcessing;
@@ -300,11 +306,17 @@ public class HandlerChainInvoker {
         }
 
         boolean continueProcessing = true;
+        MessageContext oldCtx = null;
         try {
-            WebServiceContextImpl.setMessageContext(ctx);
+            oldCtx = WebServiceContextImpl.setMessageContext(ctx);
             continueProcessing = invokeHandleFault(handlerChain, ctx);
         } finally {
-            WebServiceContextImpl.clear();
+            // restore the WebServiceContextImpl's ThreadLocal variable to the previous value
+            if (oldCtx == null) {
+                WebServiceContextImpl.clear();
+            } else {
+                WebServiceContextImpl.setMessageContext(oldCtx);
+            }
         }
 
         return continueProcessing;


Mime
View raw message