Skip CompletableFuture case in Java 7
MODIFY
dd-java-agent/instrumentation/java-concurrent/src/test/groovy/ExecutorInstrumentationTest.groovy
dd-java-agent/instrumentation/java-concurrent/src/test/groovy/ExecutorInstrumentationTest.groovy
@@ -14,6 +14,7 @@ import java.util.concurrent.ArrayBlockingQueue
import java.util.concurrent.Callable
import java.util.concurrent.CompletableFuture
import java.util.concurrent.ExecutionException
+import java.util.concurrent.Executor
import java.util.concurrent.ForkJoinPool
import java.util.concurrent.ForkJoinTask
import java.util.concurrent.Future
@@ -24,6 +25,8 @@ import java.util.concurrent.ThreadPoolExecutor
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException
+import static org.junit.Assume.assumeTrue
+
class ExecutorInstrumentationTest extends AgentTestRunner {
static {
@@ -59,6 +62,7 @@ class ExecutorInstrumentationTest extends AgentTestRunner {
def "#poolImpl '#name' propagates"() {
setup:
+ assumeTrue(poolImpl != null) // skip for Java 7 CompletableFuture
def pool = poolImpl
def m = method
@@ -133,7 +137,7 @@ class ExecutorInstrumentationTest extends AgentTestRunner {
"invokeAny with timeout" | invokeAnyTimeout | new CustomThreadPoolExecutor()
// Internal executor used by CompletableFuture
- "execute Runnable" | executeRunnable | new CompletableFuture.ThreadPerTaskExecutor()
+ "execute Runnable" | executeRunnable | java7SafeCompletableFutureThreadPerTaskExecutor()
}
def "#poolImpl '#name' disabled wrapping"() {
@@ -243,6 +247,14 @@ class ExecutorInstrumentationTest extends AgentTestRunner {
"submit Callable" | submitCallable | new ForkJoinPool()
}
+ private static Executor java7SafeCompletableFutureThreadPerTaskExecutor() {
+ try {
+ return new CompletableFuture.ThreadPerTaskExecutor()
+ } catch (NoClassDefFoundError e) {
+ return null
+ }
+ }
+
static class CustomThreadPoolExecutor extends AbstractExecutorService {
volatile running = true
def workQueue = new LinkedBlockingQueue<Runnable>(10)

Skip CompletableFuture case in Java 7