cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clecl...@apache.org
Subject svn commit: r900243 - /cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
Date Sun, 17 Jan 2010 23:27:59 GMT
Author: cleclerc
Date: Sun Jan 17 23:27:59 2010
New Revision: 900243

URL: http://svn.apache.org/viewvc?rev=900243&view=rev
Log:
[CXF-2622] clear threadlocal variables in JAXRSInInterceptor.handleFault() in case of exception

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=900243&r1=900242&r2=900243&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
Sun Jan 17 23:27:59 2010
@@ -36,6 +36,7 @@
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.impl.RequestPreprocessor;
 import org.apache.cxf.jaxrs.impl.UriInfoImpl;
+import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.model.ProviderInfo;
@@ -58,6 +59,28 @@
         super(Phase.UNMARSHAL);
     }
 
+    @Override
+    public void handleFault(Message message) {
+        super.handleFault(message);
+        
+        LOG.fine("Cleanup thread local variables");
+        
+        Object rootInstance = message.getExchange().remove(JAXRSUtils.ROOT_INSTANCE);
+        Object rootProvider = message.getExchange().remove(JAXRSUtils.ROOT_PROVIDER);
+        if (rootInstance != null && rootProvider != null) {
+            try {
+                ((ResourceProvider)rootProvider).releaseInstance(message, rootInstance);
+            } catch (Throwable tex) {
+                LOG.warning("Exception occurred during releasing the service instance, "
+ tex.getMessage());
+            }
+        }
+        ProviderFactory.getInstance(message).clearThreadLocalProxies();
+        ClassResourceInfo cri = (ClassResourceInfo)message.getExchange().get(JAXRSUtils.ROOT_RESOURCE_CLASS);
+        if (cri != null) {
+            cri.clearThreadLocalProxies();
+        }
+    }
+    
     public void handleMessage(Message message) {
         
         try {



Mime
View raw message