-
Notifications
You must be signed in to change notification settings - Fork 41
[ECO-5426][LiveObjects] Handle incoming object messages #1113
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
## Walkthrough
This change implements the core synchronization and operation handling logic for Ably LiveObjects, including object sync, state management, and operation application for LiveMap and LiveCounter types. It introduces multiple new internal classes, updates interfaces, adds error handling, and provides comprehensive unit tests for all major components and flows.
## Changes
| Files / Groups | Change Summary |
|-------------------------------------------------------------------------------|---------------|
| `lib/src/main/java/io/ably/lib/objects/LiveObjectsPlugin.java`, `ChannelBase.java`, `LiveCounter.java` | Added `handleStateChange` to `LiveObjectsPlugin` and integrated calls in channel state changes; changed `LiveCounter.value()` return type to `Number`. |
| `live-objects/src/main/kotlin/io/ably/lib/objects/DefaultLiveObjects.kt`, `DefaultLiveObjectsPlugin.kt` | Implemented async, sequential message processing, state management, and channel state change handling in `DefaultLiveObjects` and plugin. |
| `live-objects/src/main/kotlin/io/ably/lib/objects/ErrorCodes.kt`, `Utils.kt` | Added new error codes and helper for object-related errors. |
| `live-objects/src/main/kotlin/io/ably/lib/objects/Helpers.kt` | Added extension to set channel serial from protocol messages. |
| `live-objects/src/main/kotlin/io/ably/lib/objects/ObjectId.kt` | Introduced `ObjectId` class with parsing and stringification. |
| `live-objects/src/main/kotlin/io/ably/lib/objects/ObjectMessage.kt` | Added `Unknown` enum values, new extension for object data validation, and doc clarifications. |
| `live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsManager.kt` | Added `ObjectsManager` for sync, buffering, and applying object messages. |
| `live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsPool.kt` | Added `ObjectsPool` for managing live objects and GC logic. |
| `live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsSyncTracker.kt` | Added `ObjectsSyncTracker` for sync sequence tracking. |
| `live-objects/src/main/kotlin/io/ably/lib/objects/serialization/JsonSerialization.kt`, `MsgpackSerialization.kt` | Improved error handling and fallback for unknown enum codes in deserialization; simplified JSON encoding/decoding. |
| `live-objects/src/main/kotlin/io/ably/lib/objects/type/BaseLiveObject.kt` | Introduced `BaseLiveObject` abstract class and `ObjectType` enum. |
| `live-objects/src/main/kotlin/io/ably/lib/objects/type/livecounter/DefaultLiveCounter.kt`, `LiveCounterManager.kt` | Added internal `DefaultLiveCounter` class and manager for state/operation logic. |
| `live-objects/src/main/kotlin/io/ably/lib/objects/type/livemap/DefaultLiveMap.kt`, `LiveMapManager.kt` | Added internal `DefaultLiveMap` class and manager for map state/operation logic. |
| `live-objects/src/main/kotlin/io/ably/lib/objects/type/livemap/LiveMapEntry.kt`| Added `LiveMapEntry` data class and extension functions for tombstone and GC logic. |
| `live-objects/src/test/kotlin/io/ably/lib/objects/TestUtils.kt`, `TestHelpers.kt` | Added test helpers for reflection, mocking, and dependency injection. |
| `live-objects/src/test/kotlin/io/ably/lib/objects/unit/ObjectIdTest.kt`, `ObjectsSyncTrackerTest.kt` | Added unit tests for `ObjectId` and `ObjectsSyncTracker`. |
| `live-objects/src/test/kotlin/io/ably/lib/objects/unit/ObjectMessageSerializationTest.kt`, `ObjectMessageSizeTest.kt` | Adjusted imports and literals in serialization tests. |
| `live-objects/src/test/kotlin/io/ably/lib/objects/unit/RealtimeObjectsTest.kt` | Renamed test class for clarity. |
| `live-objects/src/test/kotlin/io/ably/lib/objects/unit/objects/DefaultLiveObjectsTest.kt`, `ObjectsManagerTest.kt`, `ObjectsPoolTest.kt` | Added comprehensive tests for live objects orchestration, sync, and pool logic. |
| `live-objects/src/test/kotlin/io/ably/lib/objects/unit/type/BaseLiveObjectTest.kt`, `livecounter/DefaultLiveCounterTest.kt`, `livecounter/LiveCounterManagerTest.kt`, `livemap/DefaultLiveMapTest.kt`, `livemap/LiveMapManagerTest.kt` | Added detailed unit tests for all live object types and their managers. |
## Sequence Diagram(s)
```mermaid
sequenceDiagram
participant ChannelBase
participant LiveObjectsPlugin
participant DefaultLiveObjects
participant ObjectsManager
participant ObjectsPool
ChannelBase->>LiveObjectsPlugin: handleStateChange(channelName, state, hasObjects)
LiveObjectsPlugin->>DefaultLiveObjects: handleStateChange(state, hasObjects)
DefaultLiveObjects->>ObjectsManager: startNewSync() / endSync()
DefaultLiveObjects->>ObjectsPool: resetToInitialPool() / clearObjectsData()
DefaultLiveObjects->>ObjectsManager: handleObjectMessages() / handleObjectSyncMessages()sequenceDiagram
participant DefaultLiveObjects
participant ObjectsManager
participant ObjectsPool
participant BaseLiveObject
DefaultLiveObjects->>ObjectsManager: handleObjectMessages(list)
ObjectsManager->>ObjectsPool: get(objectId) or createZeroValueObjectIfNotExists()
ObjectsPool->>BaseLiveObject: applyObjectSync() / applyObject()
Estimated code review effort🎯 5 (Critical) | ⏱️ ~150 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changes
Possibly related PRs
Suggested reviewers
Poem
|
d57e57b to
a67ea0c
Compare
1449ae8 to
38a7c34
Compare
context engineered prompts 1. Fixed build issues for some of the code. 2. Added spec annoations for code / code blocks
38a7c34 to
632a518
Compare
1. Added missing error codes and updated error handling for the same 2. Created separate class for ObjectId with static constructor
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
🧹 Nitpick comments (1)
live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsManager.kt (1)
29-42: Logic is correct with minor optimization opportunity.The method properly implements the buffering vs immediate application logic based on sync state.
Consider caching the state to avoid accessing it twice:
internal fun handleObjectMessages(objectMessages: List<ObjectMessage>) { + val currentState = liveObjects.state - if (liveObjects.state != ObjectsState.SYNCED) { + if (currentState != ObjectsState.SYNCED) { // RTO7 - The client receives object messages in realtime over the channel concurrently with the sync sequence. // Some of the incoming object messages may have already been applied to the objects described in // the sync sequence, but others may not; therefore we must buffer these messages so that we can apply // them to the objects once the sync is complete. - Log.v(tag, "Buffering ${objectMessages.size} object messages, state: $liveObjects.state") + Log.v(tag, "Buffering ${objectMessages.size} object messages, state: $currentState") bufferedObjectOperations.addAll(objectMessages) // RTO8a return }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
live-objects/src/main/kotlin/io/ably/lib/objects/Helpers.kt(1 hunks)live-objects/src/main/kotlin/io/ably/lib/objects/ObjectMessage.kt(4 hunks)live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsManager.kt(1 hunks)live-objects/src/main/kotlin/io/ably/lib/objects/serialization/JsonSerialization.kt(1 hunks)live-objects/src/main/kotlin/io/ably/lib/objects/serialization/MsgpackSerialization.kt(5 hunks)live-objects/src/test/kotlin/io/ably/lib/objects/unit/ObjectMessageSizeTest.kt(1 hunks)
🧠 Learnings (2)
📓 Common learnings
Learnt from: sacOO7
PR: ably/ably-java#1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:25-29
Timestamp: 2025-06-23T14:18:25.315Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class methods like writeMsgpackArray will have their type signatures updated to be non-nullable since the calling sites ensure objects are never null when passed to these methods.
Learnt from: sacOO7
PR: ably/ably-java#1087
File: lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java:32-34
Timestamp: 2025-05-27T12:11:25.084Z
Learning: In LiveObjects implementation (lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java), the send method intentionally hardcodes queueEvents to true rather than respecting ably.options.queueMessages. This is because LiveObjects requires reliable message delivery to ensure proper state synchronization and acknowledgment, unlike other realtime components that may allow configurable queuing behavior.
Learnt from: sacOO7
PR: ably/ably-java#1092
File: live-objects/src/test/kotlin/io/ably/lib/objects/TestUtils.kt:21-32
Timestamp: 2025-06-03T09:15:15.338Z
Learning: In test utility code for the Ably Java Live Objects module, the team prefers to keep reflection-based field access utilities simple without additional error handling, allowing tests to fail fast if incorrect field names are used.
Learnt from: sacOO7
PR: ably/ably-java#1085
File: lib/src/main/java/io/ably/lib/objects/LiveObjects.java:0-0
Timestamp: 2025-05-20T13:12:19.013Z
Learning: The LiveObjects interface does not currently include public API methods for resource management (dispose) or change listeners, as these features are not yet implemented.
Learnt from: sacOO7
PR: ably/ably-java#1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/MsgpackSerialization.kt:207-211
Timestamp: 2025-06-23T14:28:23.301Z
Learning: In the Ably Java LiveObjects MessagePack deserialization code, the `action` field in ObjectOperation is guaranteed to always be present in the protocol, so using a default value during deserialization is acceptable and won't mask real protocol errors.
Learnt from: sacOO7
PR: ably/ably-java#1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:38-46
Timestamp: 2025-06-23T14:14:17.847Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class uses intentional unsafe casting (`objects as Array<ObjectMessage>`) without type validation in both writeMsgpackArray and asJsonArray methods. This is a deliberate design decision to keep the dynamically-loaded class simple and let ClassCastException occur naturally for type mismatches.
Learnt from: sacOO7
PR: ably/ably-java#1092
File: live-objects/src/test/kotlin/io/ably/lib/objects/TestUtils.kt:48-61
Timestamp: 2025-06-03T09:15:18.827Z
Learning: User sacOO7 prefers simple test utilities without extensive error handling, believing tests should fail fast if incorrect field/method names are used rather than having defensive programming.
live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsManager.kt (4)
Learnt from: sacOO7
PR: #1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:25-29
Timestamp: 2025-06-23T14:18:25.315Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class methods like writeMsgpackArray will have their type signatures updated to be non-nullable since the calling sites ensure objects are never null when passed to these methods.
Learnt from: sacOO7
PR: #1087
File: lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java:32-34
Timestamp: 2025-05-27T12:11:25.084Z
Learning: In LiveObjects implementation (lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java), the send method intentionally hardcodes queueEvents to true rather than respecting ably.options.queueMessages. This is because LiveObjects requires reliable message delivery to ensure proper state synchronization and acknowledgment, unlike other realtime components that may allow configurable queuing behavior.
Learnt from: sacOO7
PR: #1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:38-46
Timestamp: 2025-06-23T14:14:17.847Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class uses intentional unsafe casting (objects as Array<ObjectMessage>) without type validation in both writeMsgpackArray and asJsonArray methods. This is a deliberate design decision to keep the dynamically-loaded class simple and let ClassCastException occur naturally for type mismatches.
Learnt from: sacOO7
PR: #1085
File: lib/src/main/java/io/ably/lib/objects/LiveObjects.java:0-0
Timestamp: 2025-05-20T13:12:19.013Z
Learning: The LiveObjects interface does not currently include public API methods for resource management (dispose) or change listeners, as these features are not yet implemented.
🧬 Code Graph Analysis (1)
live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsManager.kt (1)
live-objects/src/main/kotlin/io/ably/lib/objects/Utils.kt (1)
clientError(33-33)
🚧 Files skipped from review as they are similar to previous changes (5)
- live-objects/src/test/kotlin/io/ably/lib/objects/unit/ObjectMessageSizeTest.kt
- live-objects/src/main/kotlin/io/ably/lib/objects/Helpers.kt
- live-objects/src/main/kotlin/io/ably/lib/objects/serialization/JsonSerialization.kt
- live-objects/src/main/kotlin/io/ably/lib/objects/serialization/MsgpackSerialization.kt
- live-objects/src/main/kotlin/io/ably/lib/objects/ObjectMessage.kt
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: sacOO7
PR: ably/ably-java#1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:25-29
Timestamp: 2025-06-23T14:18:25.315Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class methods like writeMsgpackArray will have their type signatures updated to be non-nullable since the calling sites ensure objects are never null when passed to these methods.
Learnt from: sacOO7
PR: ably/ably-java#1087
File: lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java:32-34
Timestamp: 2025-05-27T12:11:25.084Z
Learning: In LiveObjects implementation (lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java), the send method intentionally hardcodes queueEvents to true rather than respecting ably.options.queueMessages. This is because LiveObjects requires reliable message delivery to ensure proper state synchronization and acknowledgment, unlike other realtime components that may allow configurable queuing behavior.
Learnt from: sacOO7
PR: ably/ably-java#1092
File: live-objects/src/test/kotlin/io/ably/lib/objects/TestUtils.kt:21-32
Timestamp: 2025-06-03T09:15:15.338Z
Learning: In test utility code for the Ably Java Live Objects module, the team prefers to keep reflection-based field access utilities simple without additional error handling, allowing tests to fail fast if incorrect field names are used.
Learnt from: sacOO7
PR: ably/ably-java#1085
File: lib/src/main/java/io/ably/lib/objects/LiveObjects.java:0-0
Timestamp: 2025-05-20T13:12:19.013Z
Learning: The LiveObjects interface does not currently include public API methods for resource management (dispose) or change listeners, as these features are not yet implemented.
Learnt from: sacOO7
PR: ably/ably-java#1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/MsgpackSerialization.kt:207-211
Timestamp: 2025-06-23T14:28:23.301Z
Learning: In the Ably Java LiveObjects MessagePack deserialization code, the `action` field in ObjectOperation is guaranteed to always be present in the protocol, so using a default value during deserialization is acceptable and won't mask real protocol errors.
Learnt from: sacOO7
PR: ably/ably-java#1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:38-46
Timestamp: 2025-06-23T14:14:17.847Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class uses intentional unsafe casting (`objects as Array<ObjectMessage>`) without type validation in both writeMsgpackArray and asJsonArray methods. This is a deliberate design decision to keep the dynamically-loaded class simple and let ClassCastException occur naturally for type mismatches.
Learnt from: sacOO7
PR: ably/ably-java#1092
File: live-objects/src/test/kotlin/io/ably/lib/objects/TestUtils.kt:48-61
Timestamp: 2025-06-03T09:15:18.827Z
Learning: User sacOO7 prefers simple test utilities without extensive error handling, believing tests should fail fast if incorrect field/method names are used rather than having defensive programming.
live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsManager.kt (4)
Learnt from: sacOO7
PR: #1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:25-29
Timestamp: 2025-06-23T14:18:25.315Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class methods like writeMsgpackArray will have their type signatures updated to be non-nullable since the calling sites ensure objects are never null when passed to these methods.
Learnt from: sacOO7
PR: #1087
File: lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java:32-34
Timestamp: 2025-05-27T12:11:25.084Z
Learning: In LiveObjects implementation (lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java), the send method intentionally hardcodes queueEvents to true rather than respecting ably.options.queueMessages. This is because LiveObjects requires reliable message delivery to ensure proper state synchronization and acknowledgment, unlike other realtime components that may allow configurable queuing behavior.
Learnt from: sacOO7
PR: #1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:38-46
Timestamp: 2025-06-23T14:14:17.847Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class uses intentional unsafe casting (objects as Array<ObjectMessage>) without type validation in both writeMsgpackArray and asJsonArray methods. This is a deliberate design decision to keep the dynamically-loaded class simple and let ClassCastException occur naturally for type mismatches.
Learnt from: sacOO7
PR: #1085
File: lib/src/main/java/io/ably/lib/objects/LiveObjects.java:0-0
Timestamp: 2025-05-20T13:12:19.013Z
Learning: The LiveObjects interface does not currently include public API methods for resource management (dispose) or change listeners, as these features are not yet implemented.
🧬 Code Graph Analysis (1)
live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsManager.kt (1)
live-objects/src/main/kotlin/io/ably/lib/objects/Utils.kt (1)
clientError(33-33)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: check-realtime-okhttp
- GitHub Check: check-liveobjects
- GitHub Check: check-rest
- GitHub Check: check-rest-okhttp
- GitHub Check: check (29)
- GitHub Check: check-realtime
- GitHub Check: check (24)
- GitHub Check: check
- GitHub Check: check (19)
- GitHub Check: build
- GitHub Check: check (21)
🔇 Additional comments (10)
live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsManager.kt (10)
12-23: Well-structured class with clear separation of concerns.The class design follows good practices with proper encapsulation, clear field purposes, and comprehensive spec documentation. The dependency injection pattern with
DefaultLiveObjectsprovides good testability.
49-66: Correctly implements sync sequence protocol.The method properly handles the sync sequence lifecycle with appropriate checks for new sync sequences and completion. The deferred state event mechanism ensures proper event ordering for listeners.
73-81: Properly implements sync sequence initialization.The method correctly clears stale data and sets up the new sync sequence according to the specification. The order of operations ensures clean state before starting the new sync.
88-99: Correctly implements sync sequence completion.The method follows the proper order of operations: apply sync data first, then buffered operations, followed by cleanup. This ensures consistent object state and proper resource management.
105-115: Simple and correct utility methods.These methods provide controlled access for clearing internal state, which is appropriate for the integration with
DefaultLiveObjects.handleStateChange.
122-155: Correctly implements sync data application with proper object lifecycle management.The method handles both existing and new objects appropriately, maintains object pool consistency by removing stale objects, and efficiently batches notifications after all updates are complete.
162-186: Well-designed object message application with robust error handling.The zero-value object creation strategy elegantly handles operations for unknown object IDs, while the error handling appropriately skips invalid messages with proper logging without stopping the entire batch.
193-208: Proper sync message validation and application.The method correctly validates that object states contain the required data (counter or map) and handles invalid messages gracefully with appropriate logging.
215-221: Clean object creation with proper type dispatch and validation.The method uses appropriate pattern matching to create the correct object type and properly validates that the object state contains required data, throwing a meaningful error for invalid states.
223-227: Appropriate cleanup implementation.The dispose method properly clears all internal state, providing clean resource management for the ObjectsManager lifecycle.
…r and LiveMap as thread safe
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
♻️ Duplicate comments (4)
live-objects/src/test/kotlin/io/ably/lib/objects/unit/type/BaseLiveObjectTest.kt (3)
51-51: Fix the reflection method lookup missing parameter types.The
findMethodcall is missing parameter types, which will causeNoSuchMethodExceptionat runtime sincecanApplyOperationrequires two String parameters.Apply this fix:
- val method = BaseLiveObject::class.java.findMethod("canApplyOperation") + val method = BaseLiveObject::class.java.getDeclaredMethod("canApplyOperation", String::class.java, String::class.java)
143-145: Fix incorrect test comment.The comment states "Should return false" but the test correctly uses
assertTrue. The comment should match the test expectation.- assertTrue(liveMap.canApplyOperation("site1", "serialA"), - "Should return false when message serial 'serialA' < siteSerial 'serial2'") + assertTrue(liveMap.canApplyOperation("site1", "serialA"), + "Should return true when message serial 'serialA' > siteSerial 'serial2'")
105-105: Avoid direct mutation of internal state in tests.The test directly mutates
siteTimeserials, which is an internal mutable map. This breaks encapsulation and ties tests to implementation details.Consider providing an internal test API in
BaseLiveObjectfor controlled state manipulation, such assetSiteSerial(siteId: String, serial: String), and update the test to use this API instead of direct map access.live-objects/src/test/kotlin/io/ably/lib/objects/unit/type/livecounter/LiveCounterManagerTest.kt (1)
124-124: Fix incorrect comment.The comment states "Should not change (still 0)" but the test expects the value to remain 4.0, not 0.
- assertEquals(4.0, liveCounter.data.get()) // Should not change (still 0) + assertEquals(4.0, liveCounter.data.get()) // Should not change (still 4)
🧹 Nitpick comments (1)
live-objects/src/main/kotlin/io/ably/lib/objects/type/livemap/DefaultLiveMap.kt (1)
40-74: Track TODO implementations for future completion.All public API methods are currently stubbed with TODO. This is expected for the current PR scope but should be tracked for future implementation.
Would you like me to create an issue to track the implementation of these LiveMap public API methods (
get,set,remove,entries,keys,values,size, and async variants)?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (15)
live-objects/src/main/kotlin/io/ably/lib/objects/DefaultLiveObjects.kt(2 hunks)live-objects/src/main/kotlin/io/ably/lib/objects/DefaultLiveObjectsPlugin.kt(2 hunks)live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsManager.kt(1 hunks)live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsPool.kt(1 hunks)live-objects/src/main/kotlin/io/ably/lib/objects/type/livecounter/DefaultLiveCounter.kt(1 hunks)live-objects/src/main/kotlin/io/ably/lib/objects/type/livecounter/LiveCounterManager.kt(1 hunks)live-objects/src/main/kotlin/io/ably/lib/objects/type/livemap/DefaultLiveMap.kt(1 hunks)live-objects/src/main/kotlin/io/ably/lib/objects/type/livemap/LiveMapEntry.kt(1 hunks)live-objects/src/main/kotlin/io/ably/lib/objects/type/livemap/LiveMapManager.kt(1 hunks)live-objects/src/test/kotlin/io/ably/lib/objects/unit/TestHelpers.kt(2 hunks)live-objects/src/test/kotlin/io/ably/lib/objects/unit/objects/DefaultLiveObjectsTest.kt(1 hunks)live-objects/src/test/kotlin/io/ably/lib/objects/unit/objects/ObjectsManagerTest.kt(1 hunks)live-objects/src/test/kotlin/io/ably/lib/objects/unit/objects/ObjectsPoolTest.kt(1 hunks)live-objects/src/test/kotlin/io/ably/lib/objects/unit/type/BaseLiveObjectTest.kt(1 hunks)live-objects/src/test/kotlin/io/ably/lib/objects/unit/type/livecounter/LiveCounterManagerTest.kt(1 hunks)
🧠 Learnings (8)
📓 Common learnings
Learnt from: sacOO7
PR: ably/ably-java#1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:25-29
Timestamp: 2025-06-23T14:18:25.315Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class methods like writeMsgpackArray will have their type signatures updated to be non-nullable since the calling sites ensure objects are never null when passed to these methods.
Learnt from: sacOO7
PR: ably/ably-java#1087
File: lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java:32-34
Timestamp: 2025-05-27T12:11:25.084Z
Learning: In LiveObjects implementation (lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java), the send method intentionally hardcodes queueEvents to true rather than respecting ably.options.queueMessages. This is because LiveObjects requires reliable message delivery to ensure proper state synchronization and acknowledgment, unlike other realtime components that may allow configurable queuing behavior.
Learnt from: sacOO7
PR: ably/ably-java#1092
File: live-objects/src/test/kotlin/io/ably/lib/objects/TestUtils.kt:21-32
Timestamp: 2025-06-03T09:15:15.338Z
Learning: In test utility code for the Ably Java Live Objects module, the team prefers to keep reflection-based field access utilities simple without additional error handling, allowing tests to fail fast if incorrect field names are used.
Learnt from: sacOO7
PR: ably/ably-java#1085
File: lib/src/main/java/io/ably/lib/objects/LiveObjects.java:0-0
Timestamp: 2025-05-20T13:12:19.013Z
Learning: The LiveObjects interface does not currently include public API methods for resource management (dispose) or change listeners, as these features are not yet implemented.
Learnt from: sacOO7
PR: ably/ably-java#1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/MsgpackSerialization.kt:207-211
Timestamp: 2025-06-23T14:28:23.301Z
Learning: In the Ably Java LiveObjects MessagePack deserialization code, the `action` field in ObjectOperation is guaranteed to always be present in the protocol, so using a default value during deserialization is acceptable and won't mask real protocol errors.
Learnt from: sacOO7
PR: ably/ably-java#1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:38-46
Timestamp: 2025-06-23T14:14:17.847Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class uses intentional unsafe casting (`objects as Array<ObjectMessage>`) without type validation in both writeMsgpackArray and asJsonArray methods. This is a deliberate design decision to keep the dynamically-loaded class simple and let ClassCastException occur naturally for type mismatches.
Learnt from: sacOO7
PR: ably/ably-java#1092
File: live-objects/src/test/kotlin/io/ably/lib/objects/TestUtils.kt:48-61
Timestamp: 2025-06-03T09:15:18.827Z
Learning: User sacOO7 prefers simple test utilities without extensive error handling, believing tests should fail fast if incorrect field/method names are used rather than having defensive programming.
live-objects/src/test/kotlin/io/ably/lib/objects/unit/type/BaseLiveObjectTest.kt (3)
Learnt from: sacOO7
PR: #1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:25-29
Timestamp: 2025-06-23T14:18:25.315Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class methods like writeMsgpackArray will have their type signatures updated to be non-nullable since the calling sites ensure objects are never null when passed to these methods.
Learnt from: sacOO7
PR: #1092
File: live-objects/src/test/kotlin/io/ably/lib/objects/TestUtils.kt:21-32
Timestamp: 2025-06-03T09:15:15.338Z
Learning: In test utility code for the Ably Java Live Objects module, the team prefers to keep reflection-based field access utilities simple without additional error handling, allowing tests to fail fast if incorrect field names are used.
Learnt from: sacOO7
PR: #1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:38-46
Timestamp: 2025-06-23T14:14:17.847Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class uses intentional unsafe casting (objects as Array<ObjectMessage>) without type validation in both writeMsgpackArray and asJsonArray methods. This is a deliberate design decision to keep the dynamically-loaded class simple and let ClassCastException occur naturally for type mismatches.
live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsManager.kt (4)
Learnt from: sacOO7
PR: #1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:25-29
Timestamp: 2025-06-23T14:18:25.315Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class methods like writeMsgpackArray will have their type signatures updated to be non-nullable since the calling sites ensure objects are never null when passed to these methods.
Learnt from: sacOO7
PR: #1087
File: lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java:32-34
Timestamp: 2025-05-27T12:11:25.084Z
Learning: In LiveObjects implementation (lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java), the send method intentionally hardcodes queueEvents to true rather than respecting ably.options.queueMessages. This is because LiveObjects requires reliable message delivery to ensure proper state synchronization and acknowledgment, unlike other realtime components that may allow configurable queuing behavior.
Learnt from: sacOO7
PR: #1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:38-46
Timestamp: 2025-06-23T14:14:17.847Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class uses intentional unsafe casting (objects as Array<ObjectMessage>) without type validation in both writeMsgpackArray and asJsonArray methods. This is a deliberate design decision to keep the dynamically-loaded class simple and let ClassCastException occur naturally for type mismatches.
Learnt from: sacOO7
PR: #1085
File: lib/src/main/java/io/ably/lib/objects/LiveObjects.java:0-0
Timestamp: 2025-05-20T13:12:19.013Z
Learning: The LiveObjects interface does not currently include public API methods for resource management (dispose) or change listeners, as these features are not yet implemented.
live-objects/src/main/kotlin/io/ably/lib/objects/type/livemap/DefaultLiveMap.kt (3)
Learnt from: sacOO7
PR: #1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:25-29
Timestamp: 2025-06-23T14:18:25.315Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class methods like writeMsgpackArray will have their type signatures updated to be non-nullable since the calling sites ensure objects are never null when passed to these methods.
Learnt from: sacOO7
PR: #1092
File: live-objects/src/test/kotlin/io/ably/lib/objects/TestUtils.kt:21-32
Timestamp: 2025-06-03T09:15:15.338Z
Learning: In test utility code for the Ably Java Live Objects module, the team prefers to keep reflection-based field access utilities simple without additional error handling, allowing tests to fail fast if incorrect field names are used.
Learnt from: sacOO7
PR: #1085
File: lib/src/main/java/io/ably/lib/objects/LiveObjects.java:0-0
Timestamp: 2025-05-20T13:12:19.013Z
Learning: The LiveObjects interface does not currently include public API methods for resource management (dispose) or change listeners, as these features are not yet implemented.
live-objects/src/test/kotlin/io/ably/lib/objects/unit/TestHelpers.kt (8)
Learnt from: sacOO7
PR: #1092
File: live-objects/src/test/kotlin/io/ably/lib/objects/TestUtils.kt:21-32
Timestamp: 2025-06-03T09:15:15.338Z
Learning: In test utility code for the Ably Java Live Objects module, the team prefers to keep reflection-based field access utilities simple without additional error handling, allowing tests to fail fast if incorrect field names are used.
Learnt from: sacOO7
PR: #1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:25-29
Timestamp: 2025-06-23T14:18:25.315Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class methods like writeMsgpackArray will have their type signatures updated to be non-nullable since the calling sites ensure objects are never null when passed to these methods.
Learnt from: sacOO7
PR: #1095
File: live-objects/src/test/kotlin/io/ably/lib/objects/unit/LiveObjectTest.kt:1-6
Timestamp: 2025-06-05T10:24:28.789Z
Learning: In Kotlin, functions, classes, and other declarations within the same package are automatically accessible without explicit import statements. Do not suggest adding imports for functions/classes that are already in the same package.
Learnt from: sacOO7
PR: #1059
File: lib/src/test/java/io/ably/lib/chat/ChatMessagesTest.java:124-143
Timestamp: 2025-01-22T13:13:02.809Z
Learning: In test classes, prefer keeping setup code within individual test methods rather than extracting to shared helpers, as it makes tests more independent and readable by keeping the context visible within each test.
Learnt from: sacOO7
PR: #1087
File: lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java:32-34
Timestamp: 2025-05-27T12:11:25.084Z
Learning: In LiveObjects implementation (lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java), the send method intentionally hardcodes queueEvents to true rather than respecting ably.options.queueMessages. This is because LiveObjects requires reliable message delivery to ensure proper state synchronization and acknowledgment, unlike other realtime components that may allow configurable queuing behavior.
Learnt from: sacOO7
PR: #1095
File: live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/IntegrationTest.kt:87-89
Timestamp: 2025-06-06T09:28:12.298Z
Learning: The Sandbox.kt file in ably-java live-objects module already has comprehensive HTTP retry mechanism using HttpRequestRetry with 5 retries, exponential backoff, and automatic retry on non-success responses and timeout exceptions.
Learnt from: sacOO7
PR: #1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:38-46
Timestamp: 2025-06-23T14:14:17.847Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class uses intentional unsafe casting (objects as Array<ObjectMessage>) without type validation in both writeMsgpackArray and asJsonArray methods. This is a deliberate design decision to keep the dynamically-loaded class simple and let ClassCastException occur naturally for type mismatches.
Learnt from: sacOO7
PR: #1085
File: lib/src/main/java/io/ably/lib/objects/LiveObjects.java:0-0
Timestamp: 2025-05-20T13:12:19.013Z
Learning: The LiveObjects interface does not currently include public API methods for resource management (dispose) or change listeners, as these features are not yet implemented.
live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsPool.kt (1)
Learnt from: sacOO7
PR: #1095
File: live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/IntegrationTest.kt:87-89
Timestamp: 2025-06-06T09:28:12.298Z
Learning: The Sandbox.kt file in ably-java live-objects module already has comprehensive HTTP retry mechanism using HttpRequestRetry with 5 retries, exponential backoff, and automatic retry on non-success responses and timeout exceptions.
live-objects/src/main/kotlin/io/ably/lib/objects/type/livemap/LiveMapEntry.kt (2)
Learnt from: sacOO7
PR: #1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:25-29
Timestamp: 2025-06-23T14:18:25.315Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class methods like writeMsgpackArray will have their type signatures updated to be non-nullable since the calling sites ensure objects are never null when passed to these methods.
Learnt from: sacOO7
PR: #1092
File: live-objects/src/test/kotlin/io/ably/lib/objects/TestUtils.kt:21-32
Timestamp: 2025-06-03T09:15:15.338Z
Learning: In test utility code for the Ably Java Live Objects module, the team prefers to keep reflection-based field access utilities simple without additional error handling, allowing tests to fail fast if incorrect field names are used.
live-objects/src/test/kotlin/io/ably/lib/objects/unit/type/livecounter/LiveCounterManagerTest.kt (1)
Learnt from: sacOO7
PR: #1092
File: live-objects/src/test/kotlin/io/ably/lib/objects/TestUtils.kt:21-32
Timestamp: 2025-06-03T09:15:15.338Z
Learning: In test utility code for the Ably Java Live Objects module, the team prefers to keep reflection-based field access utilities simple without additional error handling, allowing tests to fail fast if incorrect field names are used.
🧬 Code Graph Analysis (3)
live-objects/src/test/kotlin/io/ably/lib/objects/unit/type/BaseLiveObjectTest.kt (1)
live-objects/src/test/kotlin/io/ably/lib/objects/unit/TestHelpers.kt (1)
getDefaultLiveObjectsWithMockedDeps(79-97)
live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsManager.kt (1)
live-objects/src/main/kotlin/io/ably/lib/objects/Utils.kt (1)
clientError(33-33)
live-objects/src/test/kotlin/io/ably/lib/objects/unit/type/livecounter/LiveCounterManagerTest.kt (1)
live-objects/src/test/kotlin/io/ably/lib/objects/unit/TestHelpers.kt (1)
getDefaultLiveCounterWithMockedDeps(113-124)
🚧 Files skipped from review as they are similar to previous changes (8)
- live-objects/src/main/kotlin/io/ably/lib/objects/DefaultLiveObjectsPlugin.kt
- live-objects/src/main/kotlin/io/ably/lib/objects/type/livecounter/DefaultLiveCounter.kt
- live-objects/src/test/kotlin/io/ably/lib/objects/unit/objects/ObjectsPoolTest.kt
- live-objects/src/main/kotlin/io/ably/lib/objects/type/livecounter/LiveCounterManager.kt
- live-objects/src/test/kotlin/io/ably/lib/objects/unit/objects/ObjectsManagerTest.kt
- live-objects/src/main/kotlin/io/ably/lib/objects/DefaultLiveObjects.kt
- live-objects/src/test/kotlin/io/ably/lib/objects/unit/objects/DefaultLiveObjectsTest.kt
- live-objects/src/main/kotlin/io/ably/lib/objects/type/livemap/LiveMapManager.kt
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: sacOO7
PR: ably/ably-java#1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:25-29
Timestamp: 2025-06-23T14:18:25.315Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class methods like writeMsgpackArray will have their type signatures updated to be non-nullable since the calling sites ensure objects are never null when passed to these methods.
Learnt from: sacOO7
PR: ably/ably-java#1087
File: lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java:32-34
Timestamp: 2025-05-27T12:11:25.084Z
Learning: In LiveObjects implementation (lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java), the send method intentionally hardcodes queueEvents to true rather than respecting ably.options.queueMessages. This is because LiveObjects requires reliable message delivery to ensure proper state synchronization and acknowledgment, unlike other realtime components that may allow configurable queuing behavior.
Learnt from: sacOO7
PR: ably/ably-java#1092
File: live-objects/src/test/kotlin/io/ably/lib/objects/TestUtils.kt:21-32
Timestamp: 2025-06-03T09:15:15.338Z
Learning: In test utility code for the Ably Java Live Objects module, the team prefers to keep reflection-based field access utilities simple without additional error handling, allowing tests to fail fast if incorrect field names are used.
Learnt from: sacOO7
PR: ably/ably-java#1085
File: lib/src/main/java/io/ably/lib/objects/LiveObjects.java:0-0
Timestamp: 2025-05-20T13:12:19.013Z
Learning: The LiveObjects interface does not currently include public API methods for resource management (dispose) or change listeners, as these features are not yet implemented.
Learnt from: sacOO7
PR: ably/ably-java#1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/MsgpackSerialization.kt:207-211
Timestamp: 2025-06-23T14:28:23.301Z
Learning: In the Ably Java LiveObjects MessagePack deserialization code, the `action` field in ObjectOperation is guaranteed to always be present in the protocol, so using a default value during deserialization is acceptable and won't mask real protocol errors.
Learnt from: sacOO7
PR: ably/ably-java#1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:38-46
Timestamp: 2025-06-23T14:14:17.847Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class uses intentional unsafe casting (`objects as Array<ObjectMessage>`) without type validation in both writeMsgpackArray and asJsonArray methods. This is a deliberate design decision to keep the dynamically-loaded class simple and let ClassCastException occur naturally for type mismatches.
Learnt from: sacOO7
PR: ably/ably-java#1092
File: live-objects/src/test/kotlin/io/ably/lib/objects/TestUtils.kt:48-61
Timestamp: 2025-06-03T09:15:18.827Z
Learning: User sacOO7 prefers simple test utilities without extensive error handling, believing tests should fail fast if incorrect field/method names are used rather than having defensive programming.
live-objects/src/test/kotlin/io/ably/lib/objects/unit/type/BaseLiveObjectTest.kt (3)
Learnt from: sacOO7
PR: #1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:25-29
Timestamp: 2025-06-23T14:18:25.315Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class methods like writeMsgpackArray will have their type signatures updated to be non-nullable since the calling sites ensure objects are never null when passed to these methods.
Learnt from: sacOO7
PR: #1092
File: live-objects/src/test/kotlin/io/ably/lib/objects/TestUtils.kt:21-32
Timestamp: 2025-06-03T09:15:15.338Z
Learning: In test utility code for the Ably Java Live Objects module, the team prefers to keep reflection-based field access utilities simple without additional error handling, allowing tests to fail fast if incorrect field names are used.
Learnt from: sacOO7
PR: #1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:38-46
Timestamp: 2025-06-23T14:14:17.847Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class uses intentional unsafe casting (objects as Array<ObjectMessage>) without type validation in both writeMsgpackArray and asJsonArray methods. This is a deliberate design decision to keep the dynamically-loaded class simple and let ClassCastException occur naturally for type mismatches.
live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsManager.kt (4)
Learnt from: sacOO7
PR: #1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:25-29
Timestamp: 2025-06-23T14:18:25.315Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class methods like writeMsgpackArray will have their type signatures updated to be non-nullable since the calling sites ensure objects are never null when passed to these methods.
Learnt from: sacOO7
PR: #1087
File: lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java:32-34
Timestamp: 2025-05-27T12:11:25.084Z
Learning: In LiveObjects implementation (lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java), the send method intentionally hardcodes queueEvents to true rather than respecting ably.options.queueMessages. This is because LiveObjects requires reliable message delivery to ensure proper state synchronization and acknowledgment, unlike other realtime components that may allow configurable queuing behavior.
Learnt from: sacOO7
PR: #1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:38-46
Timestamp: 2025-06-23T14:14:17.847Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class uses intentional unsafe casting (objects as Array<ObjectMessage>) without type validation in both writeMsgpackArray and asJsonArray methods. This is a deliberate design decision to keep the dynamically-loaded class simple and let ClassCastException occur naturally for type mismatches.
Learnt from: sacOO7
PR: #1085
File: lib/src/main/java/io/ably/lib/objects/LiveObjects.java:0-0
Timestamp: 2025-05-20T13:12:19.013Z
Learning: The LiveObjects interface does not currently include public API methods for resource management (dispose) or change listeners, as these features are not yet implemented.
live-objects/src/main/kotlin/io/ably/lib/objects/type/livemap/DefaultLiveMap.kt (3)
Learnt from: sacOO7
PR: #1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:25-29
Timestamp: 2025-06-23T14:18:25.315Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class methods like writeMsgpackArray will have their type signatures updated to be non-nullable since the calling sites ensure objects are never null when passed to these methods.
Learnt from: sacOO7
PR: #1092
File: live-objects/src/test/kotlin/io/ably/lib/objects/TestUtils.kt:21-32
Timestamp: 2025-06-03T09:15:15.338Z
Learning: In test utility code for the Ably Java Live Objects module, the team prefers to keep reflection-based field access utilities simple without additional error handling, allowing tests to fail fast if incorrect field names are used.
Learnt from: sacOO7
PR: #1085
File: lib/src/main/java/io/ably/lib/objects/LiveObjects.java:0-0
Timestamp: 2025-05-20T13:12:19.013Z
Learning: The LiveObjects interface does not currently include public API methods for resource management (dispose) or change listeners, as these features are not yet implemented.
live-objects/src/test/kotlin/io/ably/lib/objects/unit/TestHelpers.kt (8)
Learnt from: sacOO7
PR: #1092
File: live-objects/src/test/kotlin/io/ably/lib/objects/TestUtils.kt:21-32
Timestamp: 2025-06-03T09:15:15.338Z
Learning: In test utility code for the Ably Java Live Objects module, the team prefers to keep reflection-based field access utilities simple without additional error handling, allowing tests to fail fast if incorrect field names are used.
Learnt from: sacOO7
PR: #1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:25-29
Timestamp: 2025-06-23T14:18:25.315Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class methods like writeMsgpackArray will have their type signatures updated to be non-nullable since the calling sites ensure objects are never null when passed to these methods.
Learnt from: sacOO7
PR: #1095
File: live-objects/src/test/kotlin/io/ably/lib/objects/unit/LiveObjectTest.kt:1-6
Timestamp: 2025-06-05T10:24:28.789Z
Learning: In Kotlin, functions, classes, and other declarations within the same package are automatically accessible without explicit import statements. Do not suggest adding imports for functions/classes that are already in the same package.
Learnt from: sacOO7
PR: #1059
File: lib/src/test/java/io/ably/lib/chat/ChatMessagesTest.java:124-143
Timestamp: 2025-01-22T13:13:02.809Z
Learning: In test classes, prefer keeping setup code within individual test methods rather than extracting to shared helpers, as it makes tests more independent and readable by keeping the context visible within each test.
Learnt from: sacOO7
PR: #1087
File: lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java:32-34
Timestamp: 2025-05-27T12:11:25.084Z
Learning: In LiveObjects implementation (lib/src/main/java/io/ably/lib/objects/LiveObjectsAdapter.java), the send method intentionally hardcodes queueEvents to true rather than respecting ably.options.queueMessages. This is because LiveObjects requires reliable message delivery to ensure proper state synchronization and acknowledgment, unlike other realtime components that may allow configurable queuing behavior.
Learnt from: sacOO7
PR: #1095
File: live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/IntegrationTest.kt:87-89
Timestamp: 2025-06-06T09:28:12.298Z
Learning: The Sandbox.kt file in ably-java live-objects module already has comprehensive HTTP retry mechanism using HttpRequestRetry with 5 retries, exponential backoff, and automatic retry on non-success responses and timeout exceptions.
Learnt from: sacOO7
PR: #1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:38-46
Timestamp: 2025-06-23T14:14:17.847Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class uses intentional unsafe casting (objects as Array<ObjectMessage>) without type validation in both writeMsgpackArray and asJsonArray methods. This is a deliberate design decision to keep the dynamically-loaded class simple and let ClassCastException occur naturally for type mismatches.
Learnt from: sacOO7
PR: #1085
File: lib/src/main/java/io/ably/lib/objects/LiveObjects.java:0-0
Timestamp: 2025-05-20T13:12:19.013Z
Learning: The LiveObjects interface does not currently include public API methods for resource management (dispose) or change listeners, as these features are not yet implemented.
live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsPool.kt (1)
Learnt from: sacOO7
PR: #1095
File: live-objects/src/test/kotlin/io/ably/lib/objects/integration/setup/IntegrationTest.kt:87-89
Timestamp: 2025-06-06T09:28:12.298Z
Learning: The Sandbox.kt file in ably-java live-objects module already has comprehensive HTTP retry mechanism using HttpRequestRetry with 5 retries, exponential backoff, and automatic retry on non-success responses and timeout exceptions.
live-objects/src/main/kotlin/io/ably/lib/objects/type/livemap/LiveMapEntry.kt (2)
Learnt from: sacOO7
PR: #1106
File: live-objects/src/main/kotlin/io/ably/lib/objects/serialization/Serialization.kt:25-29
Timestamp: 2025-06-23T14:18:25.315Z
Learning: In the ably-java codebase, the DefaultLiveObjectSerializer class methods like writeMsgpackArray will have their type signatures updated to be non-nullable since the calling sites ensure objects are never null when passed to these methods.
Learnt from: sacOO7
PR: #1092
File: live-objects/src/test/kotlin/io/ably/lib/objects/TestUtils.kt:21-32
Timestamp: 2025-06-03T09:15:15.338Z
Learning: In test utility code for the Ably Java Live Objects module, the team prefers to keep reflection-based field access utilities simple without additional error handling, allowing tests to fail fast if incorrect field names are used.
live-objects/src/test/kotlin/io/ably/lib/objects/unit/type/livecounter/LiveCounterManagerTest.kt (1)
Learnt from: sacOO7
PR: #1092
File: live-objects/src/test/kotlin/io/ably/lib/objects/TestUtils.kt:21-32
Timestamp: 2025-06-03T09:15:15.338Z
Learning: In test utility code for the Ably Java Live Objects module, the team prefers to keep reflection-based field access utilities simple without additional error handling, allowing tests to fail fast if incorrect field names are used.
🧬 Code Graph Analysis (3)
live-objects/src/test/kotlin/io/ably/lib/objects/unit/type/BaseLiveObjectTest.kt (1)
live-objects/src/test/kotlin/io/ably/lib/objects/unit/TestHelpers.kt (1)
getDefaultLiveObjectsWithMockedDeps(79-97)
live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsManager.kt (1)
live-objects/src/main/kotlin/io/ably/lib/objects/Utils.kt (1)
clientError(33-33)
live-objects/src/test/kotlin/io/ably/lib/objects/unit/type/livecounter/LiveCounterManagerTest.kt (1)
live-objects/src/test/kotlin/io/ably/lib/objects/unit/TestHelpers.kt (1)
getDefaultLiveCounterWithMockedDeps(113-124)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: check (21)
- GitHub Check: check (29)
- GitHub Check: check (24)
- GitHub Check: check (19)
- GitHub Check: check-liveobjects
- GitHub Check: check-rest
- GitHub Check: check-realtime
- GitHub Check: check-rest-okhttp
- GitHub Check: check-realtime-okhttp
- GitHub Check: check
- GitHub Check: build
🔇 Additional comments (39)
live-objects/src/main/kotlin/io/ably/lib/objects/type/livemap/LiveMapEntry.kt (4)
10-15: LGTM: Well-structured data class for live map entries.The data class appropriately models live map entry state with optional tombstone metadata and data payload. Default values and nullable types are correctly applied.
21-33: LGTM: Robust tombstone checking logic.The extension function correctly implements the tombstone checking logic per RTLM14 specification, handling both direct tombstoning and reference tombstoning with proper null safety.
39-53: LGTM: Comprehensive value resolution with tombstone awareness.The value resolution logic correctly handles all scenarios including tombstones, primitive values, and object references with proper null safety and tombstone filtering.
58-61: LGTM: Correct GC eligibility implementation.The GC eligibility check correctly validates tombstone status and grace period using current system time. The logic properly handles null tombstone timestamps.
live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsManager.kt (6)
12-23: LGTM: Well-structured manager with clear responsibilities.The class properly encapsulates sync data pooling and message buffering with clear documentation referencing specifications. The mutable collections are appropriately scoped as private.
29-42: LGTM: Correct buffering logic for non-synced states.The message handling properly buffers operations during non-synced states per RTO7/RTO8 specifications, with appropriate logging and immediate application when synced.
164-186: LGTM: Robust operation application with comprehensive validation.The method correctly handles missing operations, unknown actions, and creates zero-value objects for unknown IDs per RTO9 specification. The logging for skipped messages provides good debugging information.
193-208: LGTM: Proper sync message validation and collection.The sync message handling correctly validates object state presence and content, with appropriate logging for invalid messages. The validation ensures either counter or map data is present.
215-221: LGTM: Type-safe object creation from state.The factory method correctly creates objects based on state type with appropriate error handling using the established
clientErrorutility for protocol violations.
223-227: LGTM: Proper resource cleanup in dispose method.The dispose method correctly clears both internal collections, ensuring no memory leaks.
live-objects/src/main/kotlin/io/ably/lib/objects/type/livemap/DefaultLiveMap.kt (5)
18-22: LGTM: Well-structured class with proper inheritance.The class correctly implements
LiveMapand extendsBaseLiveObjectwith appropriate constructor parameters and default semantics. The private constructor with companion factory method is a good pattern.
29-29: LGTM: Thread-safe data storage choice.Using
ConcurrentHashMapis appropriate for thread-safe access from both public APIs and internal manager operations.
76-84: LGTM: Proper delegation to manager for core operations.The delegation pattern to
LiveMapManagerfor validation, state application, and operation handling is well-implemented and maintains separation of concerns.
86-89: LGTM: Efficient data clearing with diff calculation.The
clearDatamethod efficiently calculates updates from current state to empty state before clearing, enabling proper change notifications.
100-103: LGTM: Standard zero-value factory implementation.The factory method follows the established pattern for creating zero-value live objects as seen in the codebase.
live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsPool.kt (7)
14-23: LGTM: Well-defined configuration constants.The GC configuration constants are appropriately defined with clear documentation explaining the 24-hour grace period rationale for avoiding serial ordering issues.
35-57: LGTM: Proper initialization with root object and GC setup.The pool correctly initializes with a root object and starts the GC coroutine. The use of
SupervisorJobensures GC failures don't affect the parent scope.
77-80: LGTM: Safe pool reset preserving root object.The reset logic correctly preserves the root object while clearing others, maintaining object reference stability as documented.
106-119: LGTM: Robust zero-value object creation.The method correctly handles existing objects, parses object IDs for type determination, and creates appropriate zero-value objects with proper pool registration.
124-132: LGTM: Safe garbage collection with eligibility checks.The GC interval handler correctly removes eligible objects and calls per-object GC methods on retained objects.
137-148: LGTM: Robust GC coroutine with error handling.The GC coroutine properly handles exceptions without terminating the loop and uses
isActivefor clean cancellation. The exception logging provides good debugging information.
154-159: LGTM: Complete resource cleanup in dispose method.The disposal method correctly cancels the GC job, cancels the coroutine scope, and clears the pool, ensuring no resource leaks.
live-objects/src/test/kotlin/io/ably/lib/objects/unit/TestHelpers.kt (6)
3-10: LGTM! Import structure is clear and appropriate.The combination of wildcard and specific imports provides good clarity for the test helper dependencies.
21-45: LGTM! Well-structured channel mock setup.The function creates a realistic channel mock with proper state management and flexible configuration options.
47-58: LGTM! Simple and effective mock factory functions.The functions provide clean abstractions for creating test dependencies, and the size extension follows the established pattern for reflection-based field access.
65-97: LGTM! Comprehensive DefaultLiveObjects mocking setup.The helper provides flexible mocking options with clear access to internal dependencies, enabling thorough testing of DefaultLiveObjects behavior.
109-124: LGTM! Consistent LiveCounter mocking pattern.The helper maintains the same flexible mocking approach as other components, enabling controlled testing of DefaultLiveCounter behavior.
136-151: LGTM! Consistent LiveMap mocking pattern.The helper follows the established pattern, providing uniform mocking capabilities across all live object types.
live-objects/src/test/kotlin/io/ably/lib/objects/unit/type/livecounter/LiveCounterManagerTest.kt (11)
1-9: LGTM! Appropriate imports for LiveCounterManager testing.All necessary dependencies are imported for comprehensive testing of the LiveCounterManager component.
12-32: LGTM! Comprehensive test for state override functionality.The test correctly validates RTLC6 specification requirements, including proper data override and update calculation.
35-62: LGTM! Correct test for create operation merging.The test properly validates the merging of create operations during state synchronization according to RTLC6d requirements.
65-85: LGTM! Proper error handling test for unsupported actions.The test correctly validates that unsupported operations throw appropriate exceptions with the right error codes.
87-103: LGTM! Correct test for counter create operation.The test properly validates the application of counter create operations and the setting of the merged flag.
128-150: LGTM! Correct test for applying unmerged create operations.The test properly validates the application of create operations when the merged flag is false, including proper data accumulation.
152-172: LGTM! Proper test for null count handling in create operations.The test correctly validates that null counts default to 0 and the merged flag is properly set.
174-192: LGTM! Correct test for counter increment operations.The test properly validates the application of counter increment operations according to RTLC specification requirements.
194-214: LGTM! Proper error handling test for missing payloads.The test correctly validates that increment operations with missing payloads throw appropriate exceptions.
217-235: LGTM! Focused test for RTLC9b increment behavior.The test properly validates the specific requirements of RTLC9b for counter increment operations.
237-255: LGTM! Proper test for null amount handling in increments.The test correctly validates that null amounts in increment operations are treated as 0, resulting in no change to the counter value.
e72b521 to
529efd8
Compare
- Removed unnecessary `encoding` field used to detect json values
ad0ef62 to
4b084f8
Compare
…ad of checking type at runtime
b206815 to
32b1a36
Compare
|
closing in favor of #1137 |
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Refactor