Suspected visibility issues in the highly mt code
@kalkeea 已經在處理了。
開始於 2026年1月14日。
評估
這個 Issue 還沒有評估資料。
描述
While analysing some issue we currently face (cause yet unknown), I'd like to make some notes about suspected 'visibility' issues accross this API library.
When one thread updates a field it cannot be guaranteed that another thread sees the same value unless the field is declared volatile or the writing thread and the reading thread both lock on the same lock/monitor.
With this thought in mind I looked at fields which are often updated while locking on thisLock but thisLock is not locked while reading: there's no guarantee the reader sees the latest update of the field.
Please consider this general comment and review the code + run it through standard code analysis tools.
My examples of suspicion are:
HybridConnectionListener line 521 reading:
CompletableFuture controlConnectionTask = this.controlConnection.connectAsyncTask;
[ this method seems only to exisit for the purpose of unit testing?? ]
Maybe more serious issue:
HybridConnectionListener ->ControlConnection
line 545: private boolean closeCalled;
(not volatile declared?!)
And on line 809 it's accessed outside of thisLock:
if (!webSocket.isOpen()) {
this.closeOrAbortWebSocketAsync(connectTask, webSocket.getCloseReason());
if (this.closeCalled) {
keepGoing = false;
}
At this point assuming this code is executed by another thread than the one setting this.closeCalled, it's possible that this thread does not see this.closeCalled set to true and will continue retrying to reconnect (keepGoing true). This is currently a suspicion that we have why the listener continues to reconnect when we try to close it!
A much better practise would be to use AtomicBoolean, AtomicReference or other java.concurrent objects for any 'state' that is shared between threads (looking at the code any field is a suspect with the extensive use of CompletableFuture's / multi threading!). The concurrent objects would also allow more efficient get/set and increment operations.
One last example I suspect:
HybridConnectionListener -> ControlConnection
Line 543: private int connectDelayIndex;
(not volatile, consider AtomicInteger!!)
On line 699 this int is accessed outside of a lock and its value could be non consistent , i.e. assuming the wrong connection delay:
private CompletableFuture connectAsync(Duration timeout) {
try {
this.listener.throwIfDisposed();
CompletableFuture<Void> delayTask = CompletableFutureUtil.delayAsync(RelayConstants.CONNECTION_DELAY_INTERVALS[this.connectDelayIndex], EXECUTOR);
(note that it's always updated under control of thisLock! However when reading the lock should also be taken to ensure consistent read and prevent visibility issues!)
- 主要語言
- Java
- 星號
- 9
- 分支
- 15
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
Azure/azure-relay-java 的其他 Issue
-
難度 4/5 3-5 天 新手友好度 30/100
Azure/azure-relay-java#113 ·
-
0.0.4 Release throws java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip() on Java 8 Runtime可能重新可做 @kalkeea 於 317 天前認領,目前沒有進行中的 PR。 未關閉
Azure/azure-relay-java#87 · 已指派 1 人 ·
-
Channel Read spinning on 0 bytes, consuming 100% CPU可能重新可做 @kalkeea 於 317 天前認領,目前沒有進行中的 PR。 未關閉
Azure/azure-relay-java#84 · 已指派 1 人 ·
-
Mistakes in exception handling HybridConnectionListener可能重新可做 @kalkeea 於 317 天前認領,目前沒有進行中的 PR。 未關閉Relay
Azure/azure-relay-java#71 · 2 則留言 · 已指派 2 人 ·
-
Connection timeout with running with jetty 9.4.28.v20200408可能重新可做 @kalkeea 於 317 天前認領,目前沒有進行中的 PR。 未關閉Relay
Azure/azure-relay-java#70 · 2 則留言 · 已指派 2 人 ·
查看 Azure/azure-relay-java 的全部 Issue
相似的 Issue
-
documentation good first issue help wanted
難度 1/5 1 小時以內 新手友好度 90/100
-
Attachment upload accepts a file part with no file chosen and stores an empty comp_attachment可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉bug
難度 2/5 1-3 小時 新手友好度 75/100
eclipse-sw360/sw360#4849 ·
維護者通常 2 天內回覆
-
[Bug]: Skip cross-field checkpointing validation rules when checkpointing is disabled可能已有人在做 @hutiefang76 今天認領。 未關閉accepted bug good first issue java
難度 2/5 1-3 小時 新手友好度 72/100
Sekelenao/Flinkboot#473 · 1 則留言 ·
維護者通常 1 天內回覆
-
help wanted priority: low Review effort [1-5]: 2 status: needs-triage type: tests
難度 1/5 1-3 小時 新手友好度 86/100
carlos-emr/carlos#6433 · 1 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 2 天內回覆