Fix Conflicts apm-jdk-threadpool-plugin conflicts with apm-jdk-forkjoinpool-plugin#753
Fix Conflicts apm-jdk-threadpool-plugin conflicts with apm-jdk-forkjoinpool-plugin#753wu-sheng merged 1 commit intoapache:mainfrom
Conversation
| return argument instanceof EnhancedInstance && ((EnhancedInstance) argument).getSkyWalkingDynamicField() instanceof ContextSnapshot; | ||
| return argument instanceof EnhancedInstance | ||
| && ((EnhancedInstance) argument).getSkyWalkingDynamicField() instanceof ContextSnapshot | ||
| && !(argument instanceof ForkJoinTask); |
There was a problem hiding this comment.
When argument is ForkJoinTask, it will be repeatedly enhanced?
There was a problem hiding this comment.
yes.
Because forkjoinpool plugin enhanced is not work in threadpool plugin.
Also threadpool plugin enhanced is not work in forkjoinpool plugin.
There was a problem hiding this comment.
I can't remember when the previous two conditions matched, did you verify that?
There was a problem hiding this comment.
But this plugin doesn't consider this kind of compatibility AFAIK. But still, these codes exist. I want to understand why to make sure the new added conditions don't impact existing features.
There was a problem hiding this comment.
I can't remember when the previous two conditions matched, did you verify that?我不记得前两个条件何时匹配,你验证过吗?
this is verify code and result. It looks normal
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.*;
@Slf4j
@RestController
@RequestMapping(value = "/test")
public class TestController {
ExecutorService executorService = Executors.newFixedThreadPool(10);
@PutMapping("/test1")
public void test() {
executorService.submit(() -> {
log.info("submit");
});
executorService.submit(new MyForkJoinTask(() -> {
log.info("继承ForkJoinTask");
}));
CompletableFuture.runAsync(() -> {
log.info("CompletableFuture底层的AsyncRun继承ForkJoinTask");
}, executorService);
ForkJoinPool.commonPool().execute((Runnable) new MyForkJoinTask(() -> {
log.info("Runnable: 继承ForkJoinTask");
}));
ForkJoinPool.commonPool().execute((ForkJoinTask<Void>) new MyForkJoinTask(() -> {
log.info("ForkJoinTask: 继承ForkJoinTask");
}));
}
static final class MyForkJoinTask extends ForkJoinTask<Void> implements Runnable {
CompletableFuture<Void> dep;
Runnable fn;
MyForkJoinTask(Runnable fn) {
this.dep = new CompletableFuture<Void>();
;
this.fn = fn;
}
public final Void getRawResult() {
return null;
}
public final void setRawResult(Void v) {
}
public final boolean exec() {
run();
return false;
}
public void run() {
CompletableFuture<Void> d;
Runnable f;
if ((d = dep) != null && (f = fn) != null) {
dep = null;
fn = null;
if (!d.isDone()) {
try {
f.run();
d.complete(null);
} catch (Throwable ex) {
d.complete(null);
}
}
}
}
}
}There was a problem hiding this comment.
Sorry. I don't mean your codes are verified. I want to know why the method #notToEnhance existed before.
|
@xu1009 @Cool-Coding If you are still watching here, could you join this review? |
Have any conclusion? |


CHANGESlog.