3pacccccc opened a new pull request, #25104: URL: https://github.com/apache/pulsar/pull/25104
Fixes https://github.com/apache/pulsar/issues/25103 ### Motivation The `ManagedCursorImpl.removeProperty` method contains a thread safety vulnerability where it directly modifies the shared `properties` Map without proper synchronization. This can lead to: 1. **ConcurrentModificationException** when `putProperty` creates a new HashMap copy while `removeProperty` modifies the original Map 2. **Data corruption** in the internal HashMap structure under concurrent access 3. **Inconsistent state** where one thread's modifications may not be visible to others ### Modifications 1. **Fixed `removeProperty` method** in `ManagedCursorImpl.java`: - Changed from direct Map modification (`properties.remove(key)`) to creating a new Map copy - Updated implementation to match the thread-safe pattern already used in `putProperty` - Maintains atomicity through `LAST_MARK_DELETE_ENTRY_UPDATER.updateAndGet()` 2. **Added concurrency test** in `ManagedCursorTest.java`: - 100-thread stress test with mixed put/remove/get operations - 5-second duration to simulate sustained concurrent access - Verifies no `ConcurrentModificationException` or data inconsistencies - Validates final state matches expected results ### Verifying this change - [x] Make sure that the change passes the CI checks. *If the box was checked, please highlight the changes* - [ ] Dependencies (add or upgrade a dependency) - [ ] The public API - [ ] The schema - [ ] The default values of configurations - [ ] The threading model - [ ] The binary protocol - [ ] The REST endpoints - [ ] The admin CLI options - [ ] The metrics - [ ] Anything that affects deployment ### Documentation <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. --> - [ ] `doc` <!-- Your PR contains doc changes. --> - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later --> - [x] `doc-not-needed` <!-- Your PR changes do not impact docs --> - [ ] `doc-complete` <!-- Docs have been already added --> ### Matching PR in forked repository PR in forked repository: https://github.com/3pacccccc/pulsar/pull/37 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
