Support TimeUnit in the @Scheduled annotation#27309
Support TimeUnit in the @Scheduled annotation#27309vbrown37 wants to merge 11 commits intospring-projects:mainfrom
TimeUnit in the @Scheduled annotation#27309Conversation
|
@Axzial Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
|
@Axzial Thank you for signing the Contributor License Agreement! |
# Conflicts: # spring-context/src/main/java/org/springframework/scheduling/annotation/Scheduled.java
# Conflicts: # spring-context/src/main/java/org/springframework/scheduling/annotation/Scheduled.java
# Conflicts: # spring-context/src/main/java/org/springframework/scheduling/annotation/Scheduled.java
TimeUnit in the @Scheduled annotation
sbrannen
left a comment
There was a problem hiding this comment.
I've requested some minor changes.
Please also introduce some tests that use different TimeUnit values.
If you can get these changes in soon, this can be included in Spring Framework 5.3.10.
sbrannen
left a comment
There was a problem hiding this comment.
Thanks for making the requested changes!
I'll make a final review of this PR in time for 5.3.10.
| if (StringUtils.hasLength(initialDelayString)) { | ||
| try { | ||
| initialDelay = parseDelayAsLong(initialDelayString); | ||
| initialDelay = TimeUnit.MILLISECONDS.convert(parseDelayAsLong(initialDelayString), scheduled.timeUnit()); |
There was a problem hiding this comment.
While performing a final review, I noticed that this introduces a 🐛 when the String is a java.time.Duration string, since the value gets converted to milliseconds and then converted again using the configured time unit.
I've fixed this locally, and you can see the result once I've merged the changes into main.
There was a problem hiding this comment.
Oh ok, good to know ! Thank you.
|
@Axzial, if you would like for your name to be included in the |
Sure, Victor Brown, Thank you. |
This commit also fixes a bug introduced in commit e99b43b, where java.time.Duration strings were converted to milliseconds and then converted again using the configured TimeUnit. See spring-projectsgh-27309
This commit introduces a new `timeUnit` attribute in the @scheduled annotation to allow the user to specify a time unit other than milliseconds. Closes spring-projectsgh-27309
This commit also fixes a bug introduced in commit e99b43b, where java.time.Duration strings were converted to milliseconds and then converted again using the configured TimeUnit. See spring-projectsgh-27309
Added an option to use
java.util.concurrent.TimeUnitwithfixedDelay,fixedRateandinitialDelayin the@Scheduledannotation. Using by default milliseconds as before.