Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@BasePathAwareController detection fails for CGLib-proxied controllers [DATAREST-1132] #1488

Closed
spring-projects-issues opened this issue Sep 13, 2017 · 3 comments

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Sep 13, 2017

Patrik Mihalcin opened DATAREST-1132 and commented

I have very basic controller in my project which I annotated with @BasePathAwareController

@BasePathAwareController
public class MyBasePathAwareController {
    @GetMapping(value = "/strings")
    @ResponseBody
    public List<String> getStrings() {
        return Arrays.asList("base", "path", "aware");
    }
}

When I add this controller to my bigger spring boot project, it does not recognize any annotations, so code in BasePathAwareHandlerMapping returns false

@Override
protected boolean isHandler(Class<?> beanType) {
     return beanType.getAnnotation(BasePathAwareController.class) != null;
}

but code from RepositoryRestHandlerMapping returns true

@Override
protected boolean isHandler(Class<?> beanType) {
     return AnnotationUtils.findAnnotation(beanType, RepositoryRestController.class) != null;
}

I also see that the MyBasePathAwareController in my bigger spring boot project is cglib-backed proxy with no annotations and it is normal bean in smaller spring boot project

Can't we use

@Override
protected boolean isHandler(Class<?> beanType) {
     return AnnotationUtils.findAnnotation(beanType, BasePathAwareController.class) != null;
}

in BasePathAwareHandlerMapping as well?

It is also strange that the same controller is cglib-backed proxy (annotations information is not retained) in one project and in the other not.

See screenshots


Affects: 2.5.11 (Hopper SR11), 3.0 RC3 (Kay), 2.6.7 (Ingalls SR7)

Attachments:

Referenced from: pull request #281, and commits d56a106, 1b959bd, 1e3c939

Backported to: 2.6.8 (Ingalls SR8)

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Sep 24, 2017

Anton Liauchuk commented

#281

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Sep 25, 2017

Oliver Drotbohm commented

That's in place. The PR suggested didn't work as it changes the way @BasePathAwareController was detected on meta-annotations. Feel free to give the snapshots a try

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jan 12, 2018

Patrik Mihalcin commented

I confirm it works as expected now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants