-
Search before asking
Apache SkyWalking ComponentOAP server (apache/skywalking) What happenedCompletableFuture#runAsync(Runnable runnable,Executor executor) Essentially, there is a problem with java.util.concurrent.ThreadPoolExecutor#execute(Runnable runnable). If Runnable extends ForkJoinTask, Runnable will not be enhanced. What you expected to happenapm-jdk-threadpool-plugin enhances Runnable. If Runnable extends ForkJoinTask, Runnable will be enhanced by apm-jdk-forkjoinpool-plugin first, and then will not be enhanced by apm-jdk-threadpool-plugin, so the subsequent plugin will not work properly. How to reproduce
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ForkJoinTask;
@Slf4j
@RestController
@RequestMapping(value = "/test")
public class TestController {
ExecutorService executorService = Executors.newFixedThreadPool(10);
@PutMapping("/test1")
public void test() {
executorService.submit(() -> {
log.info("有traceId");
});
executorService.submit(new MyForkJoinTask(() -> {
log.info("没有traceId: 继承ForkJoinTask");
}));
CompletableFuture.runAsync(() -> {
log.info("没有traceId: CompletableFuture底层的AsyncRun继承ForkJoinTask");
}, executorService);
}
public static class MyForkJoinTask extends ForkJoinTask<Void> implements Runnable {
Runnable runnable;
public MyForkJoinTask(Runnable runnable) {
this.runnable = runnable;
}
@Override
public void run() {runnable.run();}
@Override
public Void getRawResult() {return null;}
@Override
protected void setRawResult(Void value) {}
@Override
protected boolean exec() {return false;}
}
} Anything elseNo response Are you willing to submit a pull request to fix on your own?
Code of Conduct
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
As explained. Move to discussions, if you have a fix proposal, we could discuss there. |
Beta Was this translation helpful? Give feedback.
-
For our project, forkjoinpool is not allowed, so just remove apm-jdk-forkjoinpool-plugin plugin |
Beta Was this translation helpful? Give feedback.
For our project, forkjoinpool is not allowed, so just remove apm-jdk-forkjoinpool-plugin plugin