cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asold...@apache.org
Subject [3/4] git commit: [CXF-5626] Restore former MessageContext into WebServiceContext instead of clearing it
Date Fri, 21 Mar 2014 15:58:50 GMT
[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/f71fe68b
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/f71fe68b
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/f71fe68b

Branch: refs/heads/2.6.x-fixes
Commit: f71fe68b7b82ebbd45041a9d4bae720900bf3ce7
Parents: f4682ef
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 16:25:57 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/f71fe68b/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 e4b8b06..575f7ca 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;
@@ -57,7 +58,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))
{
@@ -81,8 +82,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/f71fe68b/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 1da4d3f..d44047b 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
@@ -127,8 +127,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/f71fe68b/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