cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1565339 - in /cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs: model/AbstractResourceInfo.java utils/InjectionUtils.java
Date Thu, 06 Feb 2014 16:48:56 GMT
Author: sergeyb
Date: Thu Feb  6 16:48:56 2014
New Revision: 1565339

URL: http://svn.apache.org/r1565339
Log:
Preventing the error reporting when checking for getters on JAX-RS providers

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java?rev=1565339&r1=1565338&r2=1565339&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
Thu Feb  6 16:48:56 2014
@@ -156,8 +156,9 @@ public abstract class AbstractResourceIn
             Object proxy = null;
             synchronized (provider) {
                 try {
-                    Method getter = m.getClass().getMethod("get" + m.getName().substring(3),
new Class[]{});
-                    proxy = InjectionUtils.extractFromMethod(provider, getter);
+                    proxy = InjectionUtils.extractFromMethod(provider, 
+                                                             InjectionUtils.getGetterFromSetter(m),

+                                                             false);
                 } catch (Throwable t) {
                     // continue
                 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=1565339&r1=1565338&r2=1565339&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
Thu Feb  6 16:48:56 2014
@@ -316,15 +316,20 @@ public final class InjectionUtils {
         }
     }
 
+    public static Object extractFromMethod(Object requestObject, Method method) {
+        return extractFromMethod(requestObject, method, true);
+    }
+    
     public static Object extractFromMethod(Object requestObject,
-                                           Method method) {
+                                           Method method,
+                                           boolean logError) {
         try {
             Method methodToInvoke = checkProxy(method, requestObject);
             return methodToInvoke.invoke(requestObject);
         } catch (IllegalAccessException ex) {
-            reportServerError("METHOD_ACCESS_FAILURE", method.getName());
+            reportServerError("METHOD_ACCESS_FAILURE", method.getName(), logError);
         } catch (Exception ex) {
-            reportServerError("METHOD_INJECTION_FAILURE", method.getName());
+            reportServerError("METHOD_INJECTION_FAILURE", method.getName(), logError);
         }
         return null;
     }
@@ -446,11 +451,17 @@ public final class InjectionUtils {
     }
     
     public static void reportServerError(String messageName, String parameter) {
+        reportServerError(messageName, parameter, true);
+    }
+    
+    public static void reportServerError(String messageName, String parameter, boolean logError)
{
         org.apache.cxf.common.i18n.Message errorMessage = 
             new org.apache.cxf.common.i18n.Message(messageName, 
                                                    BUNDLE, 
                                                    parameter);
-        LOG.severe(errorMessage.toString());
+        if (logError) {
+            LOG.severe(errorMessage.toString());
+        }
         Response r = Response.status(Response.Status.INTERNAL_SERVER_ERROR)
                          .type(MediaType.TEXT_PLAIN_TYPE)
                          .entity(errorMessage.toString()).build();
@@ -971,6 +982,10 @@ public final class InjectionUtils {
         }
     }
     
+    public static Method getGetterFromSetter(Method setter) throws Exception {
+        return setter.getClass().getMethod("get" + setter.getName().substring(3), new Class[]{});
+    }
+    
     public static void injectContextProxiesAndApplication(AbstractResourceInfo cri, 
                                                           Object instance,
                                                           Application app) {
@@ -984,7 +999,9 @@ public final class InjectionUtils {
                 ? app : cri.getContextSetterProxy(method);
             try {
                 synchronized (instance) {
-                    if (value == InjectionUtils.extractFromMethod(instance, method)) {
+                    if (value == InjectionUtils.extractFromMethod(instance, 
+                                                                  getGetterFromSetter(method),

+                                                                  false)) {
                         continue;
                     }
                 }



Mime
View raw message