[AIT-296] fix: clear buffered operations unconditionally on ATTACHED (RTO4d)#1196
[AIT-296] fix: clear buffered operations unconditionally on ATTACHED (RTO4d)#1196ttypic wants to merge 1 commit intoAIT-276/apply-on-ackfrom
Conversation
WalkthroughConsolidates when buffered object operations are cleared: DefaultRealtimeObjects now unconditionally clears the buffer on ATTACHED (RTO4d), while ObjectsManager.startNewSync no longer clears Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@liveobjects/src/test/kotlin/io/ably/lib/objects/unit/objects/DefaultRealtimeObjectsTest.kt`:
- Around line 300-301: The test expects bufferedObjectOperations to be preserved
across server-initiated resyncs, but ObjectsManager.startNewSync currently
clears bufferedObjectOperations; update the implementation by removing the call
that empties the buffer so that the ObjectsManager.bufferedObjectOperations (or
BufferedObjectOperations collection) is not cleared during startNewSync,
ensuring the behavior matches the test (and spec RTO5a2b) and leaving any
buffered ops intact across resyncs.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 85bd7049-01ca-4888-839a-0787bcc94aa2
📒 Files selected for processing (3)
liveobjects/src/main/kotlin/io/ably/lib/objects/DefaultRealtimeObjects.ktliveobjects/src/test/kotlin/io/ably/lib/objects/unit/objects/DefaultRealtimeObjectsTest.ktliveobjects/src/test/kotlin/io/ably/lib/objects/unit/objects/ObjectsManagerTest.kt
liveobjects/src/test/kotlin/io/ably/lib/objects/unit/objects/DefaultRealtimeObjectsTest.kt
Show resolved
Hide resolved
…(RTO4d) - Ensured `BufferedObjectOperations` is always cleared when channel state transitions to ATTACHED, regardless of the `hasObjects` flag. - Updated tests to verify buffer clearing behavior (RTO4d).
8eb140f to
d89628c
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
liveobjects/src/test/kotlin/io/ably/lib/objects/unit/objects/DefaultRealtimeObjectsTest.kt (1)
34-41: Make instance cleanup automatic to avoid future test leaks.Good addition of
tearDown(). One maintainability gap: cleanup still depends on remembering to push every createdDefaultRealtimeObjectsintotestInstances.♻️ Small refactor to centralize tracking
class DefaultRealtimeObjectsTest { private val testInstances = mutableListOf<DefaultRealtimeObjects>() + + private fun trackedRealtimeObjects(relaxed: Boolean = false): DefaultRealtimeObjects = + getDefaultRealtimeObjectsWithMockedDeps(relaxed = relaxed).also { testInstances.add(it) } `@After` fun tearDown() { val cleanupError = AblyException.fromErrorInfo(ErrorInfo("test cleanup", 500)) testInstances.forEach { it.dispose(cleanupError) } testInstances.clear() }Then replace direct calls like
getDefaultRealtimeObjectsWithMockedDeps()withtrackedRealtimeObjects().🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@liveobjects/src/test/kotlin/io/ably/lib/objects/unit/objects/DefaultRealtimeObjectsTest.kt` around lines 34 - 41, Tests rely on manually adding each DefaultRealtimeObjects to testInstances for teardown, which is error-prone; create a helper trackedRealtimeObjects() that constructs a DefaultRealtimeObjects (delegating to getDefaultRealtimeObjectsWithMockedDeps() or similar), automatically appends it to the testInstances list, and return it to callers so tests no longer need to push instances themselves; update tests to call trackedRealtimeObjects() instead of getDefaultRealtimeObjectsWithMockedDeps() and keep tearDown() as-is to dispose all tracked DefaultRealtimeObjects.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@liveobjects/src/test/kotlin/io/ably/lib/objects/unit/objects/DefaultRealtimeObjectsTest.kt`:
- Around line 34-41: Tests rely on manually adding each DefaultRealtimeObjects
to testInstances for teardown, which is error-prone; create a helper
trackedRealtimeObjects() that constructs a DefaultRealtimeObjects (delegating to
getDefaultRealtimeObjectsWithMockedDeps() or similar), automatically appends it
to the testInstances list, and return it to callers so tests no longer need to
push instances themselves; update tests to call trackedRealtimeObjects() instead
of getDefaultRealtimeObjectsWithMockedDeps() and keep tearDown() as-is to
dispose all tracked DefaultRealtimeObjects.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2cf77248-6664-448e-971d-94a0cbbccd10
📒 Files selected for processing (4)
liveobjects/src/main/kotlin/io/ably/lib/objects/DefaultRealtimeObjects.ktliveobjects/src/main/kotlin/io/ably/lib/objects/ObjectsManager.ktliveobjects/src/test/kotlin/io/ably/lib/objects/unit/objects/DefaultRealtimeObjectsTest.ktliveobjects/src/test/kotlin/io/ably/lib/objects/unit/objects/ObjectsManagerTest.kt
💤 Files with no reviewable changes (1)
- liveobjects/src/main/kotlin/io/ably/lib/objects/ObjectsManager.kt
🚧 Files skipped from review as they are similar to previous changes (2)
- liveobjects/src/test/kotlin/io/ably/lib/objects/unit/objects/ObjectsManagerTest.kt
- liveobjects/src/main/kotlin/io/ably/lib/objects/DefaultRealtimeObjects.kt
BufferedObjectOperationsis always cleared when channel state transitions to ATTACHED, regardless of thehasObjectsflag.Spec: ably/specification#416
Js: ably/ably-js#2150
Summary by CodeRabbit
Bug Fixes
Tests