add aopContext exception msg

  • because AopContext use ThreadLocal to expose Proxy object in current Thread, thus AopContext.currentProxy() that invoking in other thread will throw an exception.

  • for example:

@Service
    public static class AsyncTransactionalTestBean {

        @Transactional
        public Collection<?> testTransToAsync() {
            System.out.println("testTransToAsync " + Thread.currentThread().getName());
            ((AsyncTransactionalTestBean) AopContext.currentProxy()).testAsyncToAsync();
            return null;
        }


        @Async
        public void testAsyncToAsync() {
            System.out.println("testAsyncToAsync " + Thread.currentThread().getName());
            ((AsyncTransactionalTestBean) AopContext.currentProxy()).testAsync();
        }

        @Async
        public void testAsync() {
            System.out.println("testAsync " + Thread.currentThread().getName());
        }
    }

AsyncTransactionalTestBean.testTransToAsync() will Exception

  • for concrete example:https://github.com/lixiaolong11000/async

Thank you.

Comment From: sbrannen

This has been merged into master in 047eefd2e2 and revised in e8ef93c508.

Thanks