diff --git a/plugins/convention/src/main/java/org/apache/struts2/convention/annotation/AnnotationTools.java b/plugins/convention/src/main/java/org/apache/struts2/convention/annotation/AnnotationTools.java index d22bf9d08..d0902d67a 100644 --- a/plugins/convention/src/main/java/org/apache/struts2/convention/annotation/AnnotationTools.java +++ b/plugins/convention/src/main/java/org/apache/struts2/convention/annotation/AnnotationTools.java @@ -31,7 +31,7 @@ public class AnnotationTools { /** * Returns the annotation on the given class or the package of the class. This searchs up the - * class hierarchy and the package hierarchy. + * class hierarchy and the package hierarchy for the closest match. * * @param klass The class to search for the annotation. * @param annotationClass The Class of the annotation. @@ -45,9 +45,12 @@ public class AnnotationTools { ann = klass.getPackage().getAnnotation(annotationClass); if (ann == null) { klass = klass.getSuperclass(); + if (klass != null ) { + ann = klass.getAnnotation(annotationClass); + } } } return ann; } -} \ No newline at end of file +}