GuoHaoZai opened a new issue, #13203:
URL: https://github.com/apache/skywalking/issues/13203

   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/skywalking/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Apache SkyWalking Component
   
   Java Agent (apache/skywalking-java)
   
   ### What happened
   
   CompletableFuture#runAsync(Runnable runnable, Executor executor)
   若在runnable中打印日志,日志中打印不出traceId
   
   本质上是java.util.concurrent.ThreadPoolExecutor#execute(Runnable 
runnable)有问题,若Runnable继承了ForkJoinTask,则Runnable不会被增强
   
   ### What you expected to happen
   
   apm-jdk-threadpool-plugin、apm-jdk-forkjoinpool-plugin这两个插件冲突。
   
   
apm-jdk-threadpool-plugin对Runnable进行了增强,若Runnable继承了ForkJoinTask,则Runnable首先会被apm-jdk-forkjoinpool-plugin赠强,然后不会被apm-jdk-threadpool-plugin增强,所以后面的插件不会正常工作
   
   
![Image](https://github.com/user-attachments/assets/10b650e1-ce3a-4a55-a885-f1d3cf83925d)
   
   ### How to reproduce
   
   1. skywalking 9.3.0
   2. 开启apm-jdk-threadpool-plugin、apm-jdk-forkjoinpool-plugin插件
   3. 日志配置文件中打印traceId
   
   ```java
   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?
   
   - [x] Yes I am willing to submit a pull request on my own!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to