cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-7309] Trying to prevent NPE when the providers are hot-redeployed, patch from Ezequiel Rosas Garcia applied
Date Fri, 26 May 2017 16:14:31 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes ab09ffcae -> 84b6266ae


[CXF-7309] Trying to prevent NPE when the providers are hot-redeployed, patch from Ezequiel
Rosas Garcia applied


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

Branch: refs/heads/3.1.x-fixes
Commit: 84b6266ae8bf57067040120fb0336e0480546ec7
Parents: ab09ffc
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Fri May 26 17:14:00 2017 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Fri May 26 17:14:00 2017 +0100

----------------------------------------------------------------------
 .../apache/cxf/jaxrs/utils/InjectionUtils.java  | 34 ++++++++++++--------
 .../java/org/apache/cxf/jaxrs/Customer.java     |  4 +--
 .../apache/cxf/jaxrs/utils/JAXRSUtilsTest.java  |  2 +-
 3 files changed, 24 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/84b6266a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
index 73b3e56..9101949 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
@@ -1093,18 +1093,13 @@ public final class InjectionUtils {
         synchronized (instance) {        
             for (Map.Entry<Class<?>, Method> entry : cri.getContextMethods().entrySet())
{
                 Method method = entry.getValue();
+                final Object proxy = extractFromSetter(instance, method);
+                if (proxy instanceof ThreadLocalProxy) {
+                    continue;
+                }
                 Object value = method.getParameterTypes()[0] == Application.class 
-                    ? app : cri.getContextSetterProxy(method);
-                try {
-                    if (value == InjectionUtils.extractFromMethod(instance, 
-                                                                  getGetterFromSetter(method),

-                                                                  false)) {
-                        continue;
-                    }
+                        ? app : cri.getContextSetterProxy(method);
                     
-                } catch (Throwable t) {
-                    // continue
-                }
                 InjectionUtils.injectThroughMethod(instance, method, value);
             }
             
@@ -1167,10 +1162,12 @@ public final class InjectionUtils {
                 if (!cri.isSingleton()) {
                     InjectionUtils.injectThroughMethod(requestObject, method, o, message);
                 } else {
-                    ThreadLocalProxy<Object> proxy 
-                        = (ThreadLocalProxy<Object>)cri.getContextSetterProxy(method);
+                    Object proxy = extractFromSetter(requestObject, method);
+                    if (!(proxy instanceof ThreadLocalProxy)) {
+                        proxy = cri.getContextSetterProxy(method);
+                    }
                     if (proxy != null) {
-                        proxy.set(o);
+                        ((ThreadLocalProxy<Object>) proxy).set(o);
                     }
                 }
                 
@@ -1475,4 +1472,15 @@ public final class InjectionUtils {
     public static Object getEntity(Object o) {
         return o instanceof GenericEntity ? ((GenericEntity<?>)o).getEntity() : o;
     }
+    public static Object extractFromSetter(Object provider, Method m) {
+        if (provider == null) {
+            return null;
+        }
+        try {
+            final Method getter = getGetterFromSetter(m);
+            return extractFromMethod(provider, getter, false);
+        } catch (Throwable t) {
+            return null;
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/84b6266a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
index f55fc1d..53c7bab 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
@@ -273,11 +273,11 @@ public class Customer extends AbstractCustomer implements CustomerInfo
{
     }
     
     @Context
-    public void setServletContext(ServletContext sc) {
+    public void setServletContext3(ServletContext sc) {
         servletContext3 = sc;
     }
     
-    public ServletContext getThreadLocalServletContext() {
+    public ServletContext getServletContext3() {
         return servletContext3;
     }
     

http://git-wip-us.apache.org/repos/asf/cxf/blob/84b6266a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
index 04d5455..a24fd64 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
@@ -1817,7 +1817,7 @@ public class JAXRSUtilsTest extends Assert {
                    ((ThreadLocalProxy<Providers>)c.getBodyWorkers()).get().getClass());
   
         assertSame(servletContextMock, 
-                   ((ThreadLocalProxy<ServletContext>)c.getThreadLocalServletContext()).get());
+                   ((ThreadLocalProxy<ServletContext>)c.getServletContext3()).get());
         assertSame(servletContextMock, 
                    ((ThreadLocalProxy<ServletContext>)c.getServletContext()).get());
         assertSame(servletContextMock, 


Mime
View raw message