Use offer instead of add when trying to test-insert element into the queue on ThreadPoolExecutor instrumentation
MODIFY
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/ThreadPoolExecutorInstrumentation.java
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/ThreadPoolExecutorInstrumentation.java
@@ -54,9 +54,9 @@ public class ThreadPoolExecutorInstrumentation extends Instrumenter.Default {
if (queue.size() == 0) {
try {
- queue.add(new GenericRunnable());
+ queue.offer(new GenericRunnable());
queue.clear(); // Remove the Runnable we just added.
- } catch (final ClassCastException e) {
+ } catch (final ClassCastException | IllegalArgumentException e) {
ExecutorInstrumentation.ConcurrentUtils.disableExecutor(executor);
}
}

Use offer instead of add when trying to test-insert element into the queue on ThreadPoolExecutor instrumentation