Propagate Connection Closure to Client#64
Merged
JavaSaBr merged 12 commits intoJavaSaBr:developfrom May 9, 2026
Merged
Conversation
JavaSaBr
reviewed
May 7, 2026
JavaSaBr
reviewed
May 9, 2026
| } | ||
|
|
||
| protected void notifySinksWithError(Throwable error) { | ||
| Array<FluxSink<?>> localActiveSinks = activeSinksOperations.getInReadLock(Array::copyOf); |
Owner
There was a problem hiding this comment.
do you really want to allocate a full array for such reading?
Contributor
Author
There was a problem hiding this comment.
I think so because sink.error(exc) in line 223 activates sink.onDispose() callback making write lock, so this situation causes dead lock. Any better ideas are welcome
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the rlib-network reactive API by ensuring server-side connection closures are propagated to client subscribers (via a dedicated ConnectionClosedException), reducing the risk of stale client connection state in reactive streams.
Changes:
- Introduces
ConnectionClosedExceptionand emits it to active reactive subscribers when a connection closes. - Updates network packet readers to treat channel-closure exceptions as a signal to close the connection.
- Adds unit tests (plus a shared await helper in
rlib-commontest fixtures) to validate closure propagation behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| rlib-network/src/test/java/javasabr/rlib/network/ConnectionCloseTest.java | Adds tests for client notification on server close and for EOF handling when a client channel closes abruptly. |
| rlib-network/src/main/java/javasabr/rlib/network/packet/impl/AbstractSslNetworkPacketReader.java | Treats EOF (-1) as an empty read to trigger connection closure handling in SSL mode. |
| rlib-network/src/main/java/javasabr/rlib/network/packet/impl/AbstractNetworkPacketReader.java | Closes the connection on AsynchronousCloseException / ClosedChannelException to propagate closure to higher layers. |
| rlib-network/src/main/java/javasabr/rlib/network/impl/AbstractConnection.java | Tracks active FluxSinks and notifies them with ConnectionClosedException during connection close. |
| rlib-network/src/main/java/javasabr/rlib/network/exception/ConnectionClosedException.java | Adds a specific exception type for connection-closure signaling. |
| rlib-network/build.gradle | Adds dependency on rlib-common test fixtures for shared test utilities. |
| rlib-common/src/testFixtures/java/javasabr/rlib/common/util/AwaitUtils.java | Introduces a small polling helper used by network tests. |
| rlib-common/src/test/java/javasabr/rlib/common/util/AwaitUtilsTest.java | Adds unit tests for the new await helper. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
JavaSaBr
reviewed
May 9, 2026
JavaSaBr
approved these changes
May 9, 2026
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces the propagation of connection closures from the server to the client. Previously, clients might not have been correctly notified when a connection was closed by the server, potentially leading to stale connection states or unhandled exceptions in reactive streams.
Changes
ConnectionClosedExceptionto explicitly handle connection closure scenarios.AbstractConnectionto notify activeFluxSinksubscribers with aConnectionClosedExceptionwhen a connection is closed.AbstractNetworkPacketReaderandAbstractSslNetworkPacketReaderto correctly detect and report connection closures.ConnectionCloseTestto verify that the client correctly receives theConnectionClosedExceptionwhen a server connection is closed.