diff --git a/logback-classic/src/test/input/joran/include/includeWithVariableAndConditional.xml b/logback-classic/src/test/input/joran/include/includeWithVariableAndConditional.xml
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/NoAutoStartUtil.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/NoAutoStartUtil.java
index aaa595cc57..59bfb2bc4e 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/NoAutoStartUtil.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/NoAutoStartUtil.java
@@ -24,7 +24,7 @@ public class NoAutoStartUtil {
/**
* Returns true if the class of the object 'o' passed as parameter is *not*
* marked with the NoAutoStart annotation. Return true otherwise.
- *
+ *
* @param o
* @return true for classes not marked with the NoAutoStart annotation
*/
@@ -48,7 +48,6 @@ public static boolean notMarkedWithNoAutoStart(Object o) {
*
The algorithm operates as follows:
*
* - Search for the annotation on the given class and return it if found.
- *
- Recursively search through all annotations that the given class declares.
*
- Recursively search through all interfaces that the given class declares.
*
- Recursively search through the superclass hierarchy of the given class.
*
@@ -62,7 +61,7 @@ public static boolean notMarkedWithNoAutoStart(Object o) {
private static A findAnnotation(Class> clazz, Class annotationType) {
return findAnnotation(clazz, annotationType, new HashSet<>());
}
-
+
/**
* Perform the search algorithm for {@link #findAnnotation(Class, Class)},
* avoiding endless recursion by tracking which annotations have already
@@ -75,21 +74,12 @@ private static A findAnnotation(Class> clazz, Class
@SuppressWarnings("unchecked")
private static A findAnnotation(Class> clazz, Class annotationType, Set visited) {
- Annotation[] anns = clazz.getDeclaredAnnotations();
- for (Annotation ann : anns) {
- if (ann.annotationType() == annotationType) {
- return (A) ann;
- }
- }
- for (Annotation ann : anns) {
- if (visited.add(ann)) {
- A annotation = findAnnotation(ann.annotationType(), annotationType, visited);
- if (annotation != null) {
- return annotation;
- }
- }
+ Annotation foundAnnotation = clazz.getAnnotation(annotationType);
+ if(foundAnnotation != null) {
+ return (A) foundAnnotation;
}
+
for (Class> ifc : clazz.getInterfaces()) {
A annotation = findAnnotation(ifc, annotationType, visited);
if (annotation != null) {
diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/NoAutoStartUtilTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/NoAutoStartUtilTest.java
index 4a5390a446..92862c9b35 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/NoAutoStartUtilTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/NoAutoStartUtilTest.java
@@ -20,7 +20,6 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -83,25 +82,5 @@ public void noAutoStartOnInterfaceImplementedByAncestor() {
private static class ComponentWithAncestorImplementingInterfaceWithNoAutoStart extends ComponentWithNoAutoStartOnInterface {
}
-
-
- /*
- * Custom annotation annotated with @NoAutoStart
- */
- @Test
- public void noAutoStartAsMetaAnnotation() {
- ComponentWithMetaAnnotation o = new ComponentWithMetaAnnotation();
- assertFalse(NoAutoStartUtil.notMarkedWithNoAutoStart(o));
- }
-
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.TYPE)
- @NoAutoStart
- public @interface MetaNoAutoStart {
- }
-
- @MetaNoAutoStart
- private static class ComponentWithMetaAnnotation {
- }
}