Skip to content

Regression: Early instantiation of a bean prevents proxying for @Async in 4.2.x but works in 4.1.x [SPR-14030] #18602

Closed

Description

@spring-projects-issues

Andy Wilkinson opened SPR-14030 and commented

There's a behaviour difference between 4.2.x and 4.1.x around proxy creation for beans with @Async methods. When using 4.2.x, early instantiation of the bean makes it ineligible for proxying. It works fine with 4.1.x.

I'll submit a spring-framework-issues PR with a test that illustrates the problem once I've got the issue number.


Affects: 4.2.5

Reference URL: spring-projects/spring-boot#5366

Issue Links:

Activity

  1. spring-projects-issues commented on Mar 9, 2016

    @spring-projects-issues
    CollaboratorAuthor
  2. spring-projects-issues commented on Mar 10, 2016

    @spring-projects-issues
    CollaboratorAuthor

    Stéphane Nicoll commented

    That is a side effect of the change in #17839

  3. spring-projects-issues commented on Mar 11, 2016

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    I've addressed this through moving that lookup logic into AsyncExecutionAspectSupport, performed on demand when we actually execute a given @Async method. We already had resolution logic for qualifier-based executors there, so now we simply have our resolution logic for the default executor there as well.

    As a consequence, the intermediate AsyncAnnotationAdvisor class doesn't initialize a local default SimpleAsyncTaskExecutor anymore. This is now also left to AsyncExecutionAspectSupport since it would otherwise prevent the logic there from kicking in.

    As a side effect of the above, our AspectJ async aspect will receive a default executor now if it has been configured with a BeanFactory. Previously, it skipped execution completely if no explicit executor was given - even if it had a BeanFactory. However, the mismatch with its own qualifier-based resolution and with proxy-based setup was questionable before, so we consistently apply default resolution in case of a given BeanFactory in any scenario now. The only way to make the AspectJ async aspect skip async execution completely is to not populate the aspect at all, in particular neither with an Executor nor with a BeanFactory.

    Juergen

  4. spring-projects-issues commented on Mar 19, 2016

    @spring-projects-issues
    CollaboratorAuthor

    Sam Brannen commented

    Reopening this issue since it has caused tests in EnableSchedulingTests to fail.

    See failing performance builds starting with https://build.spring.io/browse/SPR-PERF-724.

    Note that the following tests have been temporarily disabled via @Ignore until this is resolved.

    • withExplicitSchedulerAmbiguity_andSchedulingEnabled()
    • withAmbiguousTaskSchedulers_andSingleTask()
  5. spring-projects-issues commented on Mar 25, 2016

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    Andy Wilkinson, this is also available in 4.2.6.BUILD-SNAPSHOT as of last night... Let me know whether it restores lazy initialization behavior along the lines of 4.1.x for you.

  6. spring-projects-issues commented on Mar 29, 2016

    @spring-projects-issues
    CollaboratorAuthor

    Andy Wilkinson commented

    Looks good – the project supplied with the original Boot issue is proxied correctly with the latest 4.2.6 snapshot and the async method runs on a separate thread.

  7. added
    type: bug
    in: core
    on Jan 11, 2019
  8. added this to the 4.2.6 milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coretype: bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions