Goal: I'm trying to restrict the controllers that a ControllerAdvice handles, and am using the annotations field for it.

Expected: If i annotated a controller with a annotation

@CustomApi
@RestController
public class BuggedController

and have a controller advice with that annotation:

@ControllerAdvice( annotations = CustomApi.class )

That the ControllerAdvice is handling the contoller.

Actual: The controller advice ignores the annotated controller. However if i remove the annotations = CustomApi.class part from the ControllerAdvice it works(without the filtering)

I've attached a small example server that replicates the error

spring-bug-controller-advice.zip

Comment From: kse-music

your @CustomApi shoud add @Retention(RetentionPolicy.RUNTIME)

Comment From: bmaassenee

Thank you, haven't worked with custom annotations much, and really thought i had found a bug. But already found it hard to belief that such a core functionality would be broken.