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

Task scheduler configured by XML is not eligible for getting processed by all BeanPostProcessors #34015

Open
ProgMiner opened this issue Dec 4, 2024 · 2 comments
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@ProgMiner
Copy link

Hello!

Seems like XML-based scheduling configuration from documentation produces well-known "is not eligible" warning.

Minimal sample

Tested on Spring Core versions: 6.1.15, 6.2.0.

applicationContext.xml:

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:task="http://www.springframework.org/schema/task"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">
    <task:scheduler id="scheduler" pool-size="5" />
    <task:annotation-driven scheduler="scheduler" />
</beans>

Reference: https://docs.spring.io/spring-framework/reference/integration/scheduling.html#scheduling-enable-annotation-support

Main.java:

import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {

    public static void main(String[] args) {
        new ClassPathXmlApplicationContext("applicationContext.xml");
    }
}

Starting results in singular log message:

WARNING: Bean 'scheduler' of type [org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected/applied to a currently created BeanPostProcessor [org.springframework.context.annotation.internalScheduledAnnotationProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies/advisors. If this bean does not have to be post-processed, declare it with ROLE_INFRASTRUCTURE.

Unfortunately, I haven't found any way to mark this bean as infrastructure using only XML.

Related: #32055, spring-projects/spring-integration#7602

Best regards!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 4, 2024
@snicoll
Copy link
Member

snicoll commented Dec 4, 2024

Thanks for the report, I can reproduce the problem based on the code snippet you've shared. Going forward, it would be very much appreciated to share a small sample we can run ourselves (zip or link to a GitHub project) rather than having to piece things together from code in text.

@snicoll snicoll added type: bug A general bug in: core Issues in core modules (aop, beans, core, context, expression) and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Dec 4, 2024
@snicoll snicoll added this to the 6.2.x milestone Dec 4, 2024
@ProgMiner
Copy link
Author

Thanks for your answer and suggestion about samples!

Can I do something to fix this bug? I think that there are two points:

  • <task:scheduler> could create infrastructure bean, maybe with special option to enable or disable this behaviour
  • There must be way to specify role of bean using XML

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: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants