Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: catching rejected execution #6760

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#### Bugs

* Fix #6747: Preventing websocket error logs when the client is closed

#### Improvements

#### Dependency Upgrade
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;

Expand Down Expand Up @@ -370,19 +371,23 @@ public void onClose(WebSocket webSocket, int code, String reason) {
}
closeWebSocketOnce(code, reason);
LOGGER.debug("Exec Web Socket: On Close with code:[{}], due to: [{}]", code, reason);
serialExecutor.execute(() -> {
try {
if (exitCode.complete(null)) {
// this is expected for processes that don't terminate - uploads for example
LOGGER.debug("Exec Web Socket: completed with a null exit code - no status was received prior to onClose");
}
cleanUpOnce();
} finally {
if (listener != null) {
listener.onClose(code, reason);
try {
serialExecutor.execute(() -> {
try {
if (exitCode.complete(null)) {
// this is expected for processes that don't terminate - uploads for example
LOGGER.debug("Exec Web Socket: completed with a null exit code - no status was received prior to onClose");
}
cleanUpOnce();
} finally {
if (listener != null) {
listener.onClose(code, reason);
}
}
}
});
});
} catch (RejectedExecutionException e) {
LOGGER.debug("Client already shutdown, aborting normal closure", e);
}
}

@Override
Expand Down
Loading