apache / apache/dubbo

AsyncContextImpl$future字段没有并发控制

Open
#6,572 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
41.6k
Forks
26.4k
Avg merge
15h 13m
Merged PRs (30d)
4

Description

* Dubbo version: latest

https://github.com/apache/dubbo/blob/dubbo-2.7.8/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/AsyncContextImpl.java

```java
private final AtomicBoolean started = new AtomicBoolean(false);
private CompletableFuture future;

public void start() {
if (this.started.compareAndSet(false, true)) {
this.future = new CompletableFuture<>();
}
}

public void write(Object value) {
if (isAsyncStarted() && stop()) {
if (value instanceof Throwable) {
Throwable bizExe = (Throwable) value;
future.completeExceptionally(bizExe);
} else {
future.complete(value);
}
} else {
// ignored
}
}
```

当`isAsyncStarted()`返回true时确定能保证future字段的可见性么?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.