Skip to content

Commit

Permalink
fix: catching rejected execution
Browse files Browse the repository at this point in the history
closes: #6747

Signed-off-by: Steve Hawkins <[email protected]>
  • Loading branch information
shawkins committed Jan 3, 2025
1 parent 5fd904c commit a613c0a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
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

0 comments on commit a613c0a

Please sign in to comment.