Rollback wrapping of runnables on each schedule for Spring Scheduling #7290
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What Does This Do
This PR rollbacks instrumenting spring scheduling
TaskScheduler
which was wrapping theRunnable
in each schedule.This was done as part of #6249 in order to have the right Runnable names displayed on actuator's endpoints.
Wrapping the runnable on each schedule can cause side effects if a custom task scheduler is used and if inside the
schedule
methodinstanceof
is used to check whenever the Runnable is of a certain type since we're wrapping it withSpringSchedulingRunnableWrapper
.In order to be less invasive and, at same time, preserve the right labelling on actuator, I've restored the old approach instrumenting
Task
instead ofTaskScheduler
which was causing that bad behaviour. I've also overridden thetoString
method ofSpringSchedulingRunnableWrapper
in order to target the wrapped runnable instead. This will work for spring boot actuator since the displayed name is obtained callingtoString
(https://github.com/spring-projects/spring-boot/blob/69630bba37caa3a092b19392949705a41234d703/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/scheduling/ScheduledTasksEndpoint.java#L285)Motivation
Additional Notes
Jira ticket: APMS-12578