Suspected visibility issues in the highly mt code
@kalkeea đang làm issue này rồi.
Từ ngày 14/1/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
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!)
- Ngôn ngữ chính
- Java
- Star
- 9
- Fork
- 15
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Azure/azure-relay-java
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
Azure/azure-relay-java#113 ·
-
0.0.4 Release throws java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip() on Java 8 RuntimeCó thể làm lại được @kalkeea đã nhận 317 ngày trước và không có pull request nào đang mở. Đang mở
Azure/azure-relay-java#87 · 1 người được giao ·
-
Channel Read spinning on 0 bytes, consuming 100% CPUCó thể làm lại được @kalkeea đã nhận 317 ngày trước và không có pull request nào đang mở. Đang mở
Azure/azure-relay-java#84 · 1 người được giao ·
-
Mistakes in exception handling HybridConnectionListenerCó thể làm lại được @kalkeea đã nhận 317 ngày trước và không có pull request nào đang mở. Đang mởRelay
Azure/azure-relay-java#71 · 2 bình luận · 2 người được giao ·
-
Connection timeout with running with jetty 9.4.28.v20200408Có thể làm lại được @kalkeea đã nhận 317 ngày trước và không có pull request nào đang mở. Đang mởRelay
Azure/azure-relay-java#70 · 2 bình luận · 2 người được giao ·
Tất cả issue của Azure/azure-relay-java
Issue tương tự
-
documentation good first issue help wanted
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
Attachment upload accepts a file part with no file chosen and stores an empty comp_attachmentĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
eclipse-sw360/sw360#4849 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Bug]: Skip cross-field checkpointing validation rules when checkpointing is disabledCó thể đã có người làm @hutiefang76 đã nhận hôm nay. Đang mởaccepted bug good first issue java
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Sekelenao/Flinkboot#473 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
help wanted priority: low Review effort [1-5]: 2 status: needs-triage type: tests
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 86/100
carlos-emr/carlos#6433 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 2 ngày