Skip to content
Permalink
Browse files
Preventing the error reporting when checking for getters on JAX-RS pr…
…oviders

git-svn-id: https://svn.apache.org/repos/asf/cxf/trunk@1565339 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Sergey Beryozkin committed Feb 6, 2014
1 parent 5b82381 commit c969819c79cb38b8d28dec65a8fd1b34fb1e6434
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
@@ -156,8 +156,9 @@ private static ThreadLocalProxy<?> getMethodThreadLocalProxy(Method m, Object pr
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
}
@@ -316,15 +316,20 @@ public static void injectThroughMethod(Object requestObject,
}
}

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 @@ private static <T> T createFromParameterHandler(String value,
}

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 @@ private static ThreadLocalProxy<?> createThreadLocalServletApiContext(String nam
}
}

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 static void injectContextProxiesAndApplication(AbstractResourceInfo cri,
? app : cri.getContextSetterProxy(method);
try {
synchronized (instance) {
if (value == InjectionUtils.extractFromMethod(instance, method)) {
if (value == InjectionUtils.extractFromMethod(instance,
getGetterFromSetter(method),
false)) {
continue;
}
}

0 comments on commit c969819

Please sign in to comment.