Using Spring AOP on App Engine causes StackOverflowError

后端 未结 3 736
故里飘歌
故里飘歌 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.

    0 讨论(0)
  • 2021-01-12 06:41

    This is either because of infinite recursion, or because your stack is just too big. Try bumping up your stack size to see if that solves the problem (using, for example, -Xss1m). If this does not help, then you may have infinite recursion. See also:

    Java stack overflow error - how to increase the stack size in Eclipse?

    0 讨论(0)
  • 2021-01-12 06:44

    It seems that the issue has been fixed in App Engine version 1.9.7. See more details here.

    0 讨论(0)
提交回复
热议问题