arextest / arextest/arex-agent-java

[Bug] CompletableFuture 异步调用未录制

Open
#589 1 comment 0 reactions 1 assignee Claimed by @lucas-myx View on GitHub
bug :lady_beetle:
Dominant language
Java
Stars
564
Forks
140
Avg merge
36m
Merged PRs (30d)
2

Description

### Search before asking

- [ ] I have searched the existing [issues](https://github.com/arextest/arex-agent-java/issues) before asking.

### AREX Test Service

AREX Java Agent (arextest/arex-agent-java)

### Current Behavior

dubbo服务作为入口,方法里使用CompletableFuture进行了两次异步调用,第二次调用依赖第一次返回结果,发现只录制到了第一次的dubbo请求,第二次没有录上。

我们async接口内部实现是调用的dubbo方法,这里为了简单复现问题,实现了两个service做查询,配置动态类模拟录制过程。

controller类:
@GetMapping("test/test12")
public String test12() {
CompletableFuture future = async(true, "abc").thenApply(result -> {
System.out.println("1getValue:" + result);
return result + "-线程1";
}).thenCompose(this::getFutureValue);
String s = "";
try {
s = future.get();
System.out.println("result:" + s);
} catch (Exception e) {
throw new RuntimeException(e);
}
return "success";
}

public CompletableFuture async(boolean isConfig, String txt) {
return CompletableFuture.supplyAsync(() -> {
if (isConfig) {
return ConfigService.getConfig(txt);
} else {
return CacheService.getValue(txt);
}
}, this.executorService);
}

private CompletableFuture getFutureValue(String result) {
return async(false, result).thenApply(re -> {
System.out.println("2getValue:" + re);
return re + "-线程2";
});
}

service1:
public class ConfigService {

private static final ConfigService configService = new ConfigService();

public static ConfigService getInstance() {
return configService;
}

private ConfigService() {
}

public static String getConfig(String key) {
return "config-" + key;
}
}

service2:
public class CacheService {

private static final CacheService cacheService = new CacheService();

public static CacheService getInstance() {
return cacheService;
}

private CacheService() {
}

public static String getValue(String key) {
return key + "-" + key;
}

}

### Expected Behavior

CompletableFuture 两次异步调用都能录制

### Steps To Reproduce

""

### 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!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.