Rewrite parts of the executors
instrumentation to wrap Runnable
s
#9324
Labels
enhancement
New feature or request
executors
instrumentation to wrap Runnable
s
#9324
Is your feature request related to a problem? Please describe.
See #9175 and #9179
There is an issue with the
Executor#execute(Runnable)
instrumentation caused by our handling of state: when you submit the sameRunnable
instance to theexecute()
method, the agent attaches context to it using a virtual field. Because it's the same instance, and we don't create a wrapper, the passed state gets mangled when said runnable gets executed concurrently in several threads.This problem does not surface for other
ExecutorService
methods (e.g.schedule()
) in thejava.concurrent
executor implementations because they all always create a newFutureTask
and then delegate toexecute()
; so the runnable is a fresh instance every time.Describe the solution you'd like
For the
java.concurrent
executors, we could ignore all the extra methods that delegate toexecute()
and just instrumentexecute()
itself, creating a newRunnable
wrapper every time it gets called.Extra care should be applied to non-standard executors, or executors that use non-standard queues (e.g. Slick
AsyncExecutor
)Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: