zhan7236 opened a new pull request, #2956:
URL: https://github.com/apache/fory/pull/2956

   ## What does this PR do?
   This PR fixes the race condition concern raised in PR #2955 review by 
maintainer @chaokunyang.
   
   ## Problem
   The original implementation calculated capacity using:
   ```java
   int capacity = abq.remainingCapacity() + abq.size();
   ```
   This could cause race conditions when the queue is being modified 
concurrently between the two calls.
   
   ## Solution
   Use reflection to directly read the capacity field:
   - For `ArrayBlockingQueue`: Read `items` array length (capacity is array 
length)
   - For `LinkedBlockingQueue`: Read `capacity` field directly
   
   This follows the same pattern used by `ArraysAsListSerializer` which uses 
`Platform.objectFieldOffset()` for safe field access.
   
   ## Related issues
   Follow-up to #2955 addressing: 
https://github.com/apache/fory/pull/2955#pullrequestreview-2508169408
   
   ## Does this PR introduce any user-facing change?
   No - this is an internal implementation fix.
   
   ## Benchmark
   N/A - no performance impact expected, both approaches are O(1).


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to