Uploaded image for project: 'Spring Data REST'
  1. Spring Data REST
  2. DATAREST-1132

@BasePathAwareController detection fails for CGLib-proxied controllers

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.5.11 (Hopper SR11), 3.0 RC3 (Kay), 2.6.7 (Ingalls SR7)
    • Component/s: Infrastructure
    • Labels:
      None

      Description

      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

        Attachments

          Activity

            People

            Assignee:
            olivergierke Oliver Drotbohm
            Reporter:
            caparzo Patrik Mihalcin
            Last updater:
            Spring Issues Spring Issues
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: