-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Labels
bugSomething isn't working and you are sure it's a bug!Something isn't working and you are sure it's a bug!
Description
Search before asking
- I had searched in the issues and found no similar issues.
Apache SkyWalking Component
OAP server (apache/skywalking)
What happened
CompletableFuture#runAsync(Runnable runnable,Executor executor)
If print logs in runnable, traceId will not be printed in the log
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 happen
apm-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
- skywalking 9.3.0
- enable apm-jdk-threadpool-plugin、apm-jdk-forkjoinpool-plugin
- Print traceId in the logback.xml
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 else
No response
Are you willing to submit a pull request to fix on your own?
- Yes I am willing to submit a pull request on my own!
Code of Conduct
- I agree to follow this project's Code of Conduct
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't working and you are sure it's a bug!Something isn't working and you are sure it's a bug!
