Using Spring AOP on App Engine causes StackOverflowError

后端 未结 3 749
故里飘歌
故里飘歌 2021-01-12 06:24

We have an app running on App Engine and using Spring framework. Recently we have added some new features that are based on AOP. We decided to use @AspectJ style hence we ad

3条回答
  •  悲&欢浪女
    2021-01-12 06:38

    A stack overflow usually indicates an infinite loop. With aspectj you could have this in the following case:

    Class Logger {
     @Autowired
     ConfigService conf;
     //... used for logging intercepted methods
    }
    
    Class ConfigServiceImpl implements ConfigService {
     //... this is used to retrieve config
    }
    

    If you now use aspectj expressions that says: I want to log my configServiceImpl then you will also have infinite loop when using the configService:

    • intercepted by logger
    • configservice injected in logger tries to retrieve logging config ...
    • ==> that configservice is intercepted by logger and story repeats

    I cannot explain why it is working on your local setup and not on app engine. Or why it is only when you are using @Configuration but I think you should look in the direction of a "circular dependency" like this.

提交回复
热议问题