mirror of
https://github.com/apache/struts.git
synced 2026-08-06 23:27:07 +00:00
WW-5352 Add debug logging for parameter rejections
This commit is contained in:
+21
-4
@@ -399,8 +399,11 @@ public class ParametersInterceptor extends MethodFilterInterceptor {
|
||||
if (relevantMethod == null) {
|
||||
return false;
|
||||
}
|
||||
StrutsParameter annotation = getParameterAnnotation(relevantMethod);
|
||||
if (annotation == null || annotation.depth() < paramDepth) {
|
||||
if (getPermittedInjectionDepth(relevantMethod) < paramDepth) {
|
||||
LOG.debug(
|
||||
"Parameter injection for method [{}] on action [{}] rejected. Ensure it is annotated with @StrutsParameter with an appropriate 'depth'.",
|
||||
relevantMethod.getName(),
|
||||
relevantMethod.getDeclaringClass().getName());
|
||||
return false;
|
||||
}
|
||||
if (paramDepth >= 1) {
|
||||
@@ -450,8 +453,11 @@ public class ParametersInterceptor extends MethodFilterInterceptor {
|
||||
if (!Modifier.isPublic(field.getModifiers())) {
|
||||
return false;
|
||||
}
|
||||
StrutsParameter annotation = getParameterAnnotation(field);
|
||||
if (annotation == null || annotation.depth() < paramDepth) {
|
||||
if (getPermittedInjectionDepth(field) < paramDepth) {
|
||||
LOG.debug(
|
||||
"Parameter injection for field [{}] on action [{}] rejected. Ensure it is annotated with @StrutsParameter with an appropriate 'depth'.",
|
||||
fieldName,
|
||||
action.getClass().getName());
|
||||
return false;
|
||||
}
|
||||
if (paramDepth >= 1) {
|
||||
@@ -467,6 +473,17 @@ public class ParametersInterceptor extends MethodFilterInterceptor {
|
||||
allowlistParameterizedTypeArg(field.getGenericType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return permitted injection depth where -1 indicates not permitted
|
||||
*/
|
||||
protected int getPermittedInjectionDepth(AnnotatedElement element) {
|
||||
StrutsParameter annotation = getParameterAnnotation(element);
|
||||
if (annotation == null) {
|
||||
return -1;
|
||||
}
|
||||
return annotation.depth();
|
||||
}
|
||||
|
||||
/**
|
||||
* Annotation retrieval logic. Can be overridden to support extending annotations or some other form of annotation
|
||||
* inheritance.
|
||||
|
||||
Reference in New Issue
Block a user