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