Skip to content

@Scheduled annotation fixedDelayString attribute does not resolve SpEL expressions [SPR-14114] #18686

Closed
@spring-projects-issues

Description

@spring-projects-issues

Sean Stephenson opened SPR-14114 and commented

I have a @Scheduled method that should execute every N seconds, where N is an interval specified in a config file. Here is how my declaration looks.

@Scheduled(fixedDelayString = "#{${myapp.intervalInSeconds} * 1000}")
public void run() {
// ...
}

Unfortunately, while specifying a property replace expression like "${myapp.intervalInSeconds}" works correctly, using a SpEL expression to convert this to milliseconds does not work. I get the following error message on attempting to start Spring.

Caused by: java.lang.IllegalStateException: Encountered invalid @Scheduled method 'run': Invalid fixedDelayString value "#{10 * 1000}" - cannot parse into integer


Affects: 4.1.7

Issue Links:

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: duplicateA duplicate of another issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions