-
Notifications
You must be signed in to change notification settings - Fork 41
[ECO-5117] Fix channel ATTACH/DETACH state checks #1046
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
Conversation
WalkthroughThe changes in this pull request involve modifications to the Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Outside diff range and nitpick comments (1)
lib/src/main/java/io/ably/lib/realtime/ChannelBase.java (1)
Line range hint
948-950: Address the TODO comment regarding test failure insetConnectedThe
setConnectedmethod contains a TODO comment indicating a failing test due to explicit attach after connect. Investigate and resolve this issue to ensure that the channel correctly reattaches when the connection is reestablished, adhering to RTN15c6 and RTN15c7 specifications.Would you like assistance in diagnosing the test failure or updating the test to reflect the intended behavior?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
lib/src/main/java/io/ably/lib/realtime/ChannelBase.java(2 hunks)lib/src/test/java/io/ably/lib/test/realtime/RealtimeChannelTest.java(3 hunks)
🔇 Additional comments (5)
lib/src/main/java/io/ably/lib/realtime/ChannelBase.java (5)
224-236: Verify handling of 'failed' state during attach
In the attachImpl method, when the channel state is failed, the code sets this.reason = null; and proceeds without explicitly initiating a new attach operation. Ensure that this approach aligns with the RTL4g specification, which states that the channel should proceed as if it were in the initialized state when attach is called on a failed channel.
317-322: Confirm success callback for 'initialized' and 'detached' states in detach
In the detachImpl method, when the channel state is initialized or detached, the code calls callCompletionListenerSuccess(listener);. Verify that returning success in these states is appropriate and consistent with the RTL5a specification.
322-330: Handle pending detach requests in 'detaching' and 'attaching' states
The code adds the listener to the channel's state change listeners when the state is detaching, and queues the detach request when the state is attaching. Ensure that this logic correctly handles concurrent detach operations as specified in RTL5i.
330-334: Appropriate error callback for 'failed' state during detach
In the detachImpl method, when the channel state is failed, the code constructs an ErrorInfo object based on this.reason and calls callCompletionListenerError(listener, error);. This behavior aligns with the RTL5b specification, which expects an error when detaching a channel in a failed state.
335-338: Transition from 'suspended' to 'detached' during detach
When the channel state is suspended, the code transitions the state to detached by calling setState(ChannelState.detached, null); and then invokes callCompletionListenerSuccess(listener);. This complies with the RTL5j specification, ensuring proper state management during detach operations from a suspended state.
lib/src/test/java/io/ably/lib/test/realtime/RealtimeChannelTest.java
Outdated
Show resolved
Hide resolved
lib/src/test/java/io/ably/lib/test/realtime/RealtimeChannelTest.java
Outdated
Show resolved
Hide resolved
lib/src/test/java/io/ably/lib/test/realtime/RealtimeChannelTest.java
Outdated
Show resolved
Hide resolved
ttypic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
ec5b6dd to
47cd42f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
lib/src/test/java/io/ably/lib/test/realtime/RealtimeChannelTest.java (2)
1071-1106: Good test coverage for detach in suspended state.The test effectively verifies channel detach behavior when in suspended state. Consider adding a verification that channel.reason is null after successful detach, similar to the attach test.
/* Verify onSuccess callback gets called */ detachWaiter.waitFor(); assertTrue(detachWaiter.success); +assertNull("Verify error reason is cleared", channel.reason);
1108-1147: Comprehensive test for detach failure in failed state.Good validation of error conditions and state transitions. Consider adding a test case for the scenario where the channel moves from failed to attached state while a detach operation is pending.
@Test public void detach_pending_when_channel_moves_to_attached() { // Setup code... // Simulate connection failure ably.connection.connectionManager.requestState(ConnectionState.failed); channelWaiter.waitFor(ChannelState.failed); // Start detach operation Helpers.CompletionWaiter detachWaiter = new Helpers.CompletionWaiter(); channel.detach(detachWaiter); // Move channel to attached state ably.connection.connectionManager.requestState(ConnectionState.connected); channelWaiter.waitFor(ChannelState.attached); // Verify detach operation completes successfully detachWaiter.waitFor(); assertTrue(detachWaiter.success); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
lib/src/test/java/io/ably/lib/test/realtime/RealtimeChannelTest.java(3 hunks)
🔇 Additional comments (2)
lib/src/test/java/io/ably/lib/test/realtime/RealtimeChannelTest.java (2)
933-933: LGTM! Improved assertion message clarity.
The updated assertion message better describes the expected state.
947-998: Well structured test for channel attach in failed state.
Good test coverage that:
- Properly simulates connection failure
- Verifies state transitions (attached -> failed -> attaching -> attached)
- Validates error information
- Checks cleanup of error reason after reattach
|
@coderabbitai resolve |
✅ Actions performedComments resolved. |
Fixed #1045
Summary by CodeRabbit
New Features
failedandsuspended.Bug Fixes
failedorsuspendedstate.Tests