Skip to content

Commit f32ed30

Browse files
committed
remove support for metaannotations for NoAutoStart annotation
Signed-off-by: Ceki Gulcu <[email protected]>
1 parent 4476edd commit f32ed30

File tree

3 files changed

+6
-37
lines changed

3 files changed

+6
-37
lines changed

logback-classic/src/test/input/joran/include/includeWithVariableAndConditional.xml

Whitespace-only changes.

logback-core/src/main/java/ch/qos/logback/core/joran/spi/NoAutoStartUtil.java

+6-16
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class NoAutoStartUtil {
2424
/**
2525
* Returns true if the class of the object 'o' passed as parameter is *not*
2626
* marked with the NoAutoStart annotation. Return true otherwise.
27-
*
27+
*
2828
* @param o
2929
* @return true for classes not marked with the NoAutoStart annotation
3030
*/
@@ -48,7 +48,6 @@ public static boolean notMarkedWithNoAutoStart(Object o) {
4848
* <p>The algorithm operates as follows:
4949
* <ol>
5050
* <li>Search for the annotation on the given class and return it if found.
51-
* <li>Recursively search through all annotations that the given class declares.
5251
* <li>Recursively search through all interfaces that the given class declares.
5352
* <li>Recursively search through the superclass hierarchy of the given class.
5453
* </ol>
@@ -62,7 +61,7 @@ public static boolean notMarkedWithNoAutoStart(Object o) {
6261
private static <A extends Annotation> A findAnnotation(Class<?> clazz, Class<A> annotationType) {
6362
return findAnnotation(clazz, annotationType, new HashSet<>());
6463
}
65-
64+
6665
/**
6766
* Perform the search algorithm for {@link #findAnnotation(Class, Class)},
6867
* avoiding endless recursion by tracking which annotations have already
@@ -75,21 +74,12 @@ private static <A extends Annotation> A findAnnotation(Class<?> clazz, Class<A>
7574
@SuppressWarnings("unchecked")
7675
private static <A extends Annotation> A findAnnotation(Class<?> clazz, Class<A> annotationType, Set<Annotation> visited) {
7776

78-
Annotation[] anns = clazz.getDeclaredAnnotations();
79-
for (Annotation ann : anns) {
80-
if (ann.annotationType() == annotationType) {
81-
return (A) ann;
82-
}
83-
}
84-
for (Annotation ann : anns) {
85-
if (visited.add(ann)) {
86-
A annotation = findAnnotation(ann.annotationType(), annotationType, visited);
87-
if (annotation != null) {
88-
return annotation;
89-
}
90-
}
77+
Annotation foundAnnotation = clazz.getAnnotation(annotationType);
78+
if(foundAnnotation != null) {
79+
return (A) foundAnnotation;
9180
}
9281

82+
9383
for (Class<?> ifc : clazz.getInterfaces()) {
9484
A annotation = findAnnotation(ifc, annotationType, visited);
9585
if (annotation != null) {

logback-core/src/test/java/ch/qos/logback/core/joran/spi/NoAutoStartUtilTest.java

-21
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.lang.annotation.RetentionPolicy;
2121
import java.lang.annotation.Target;
2222

23-
import org.junit.Test;
2423
import static org.junit.jupiter.api.Assertions.assertFalse;
2524
import static org.junit.jupiter.api.Assertions.assertTrue;
2625

@@ -83,25 +82,5 @@ public void noAutoStartOnInterfaceImplementedByAncestor() {
8382

8483
private static class ComponentWithAncestorImplementingInterfaceWithNoAutoStart extends ComponentWithNoAutoStartOnInterface {
8584
}
86-
87-
8885

89-
/*
90-
* Custom annotation annotated with @NoAutoStart
91-
*/
92-
@Test
93-
public void noAutoStartAsMetaAnnotation() {
94-
ComponentWithMetaAnnotation o = new ComponentWithMetaAnnotation();
95-
assertFalse(NoAutoStartUtil.notMarkedWithNoAutoStart(o));
96-
}
97-
98-
@Retention(RetentionPolicy.RUNTIME)
99-
@Target(ElementType.TYPE)
100-
@NoAutoStart
101-
public @interface MetaNoAutoStart {
102-
}
103-
104-
@MetaNoAutoStart
105-
private static class ComponentWithMetaAnnotation {
106-
}
10786
}

0 commit comments

Comments
 (0)