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

Improve exception message in AopContext.currentProxy() #24321

Conversation

lixiaolong11000
Copy link
Contributor

@lixiaolong11000 lixiaolong11000 commented Jan 9, 2020

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

Thank you.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 9, 2020
@sbrannen sbrannen changed the title add aopContext exception msg Improve exception message in AopContext.currentProxy() Jan 9, 2020
@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 9, 2020
@sbrannen sbrannen self-assigned this Jan 9, 2020
@sbrannen sbrannen added this to the 5.2.3 milestone Jan 9, 2020
@sbrannen sbrannen closed this in 047eefd Jan 9, 2020
sbrannen added a commit that referenced this pull request Jan 9, 2020
@sbrannen
Copy link
Member

sbrannen commented Jan 9, 2020

This has been merged into master in 047eefd and revised in e8ef93c.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants