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 にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
Azure/azure-relay-java#87 · 担当者 1 名 ·
-
Channel Read spinning on 0 bytes, consuming 100% CPU再び着手できるかも @kalkeea が 317 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
Azure/azure-relay-java#84 · 担当者 1 名 ·
-
Mistakes in exception handling HybridConnectionListener再び着手できるかも @kalkeea が 317 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンRelay
Azure/azure-relay-java#71 · コメント 2 件 · 担当者 2 名 ·
-
Connection timeout with running with jetty 9.4.28.v20200408再び着手できるかも @kalkeea が 317 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン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
-
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 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 2 日以内に返信