You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fory.apache.org by "zhan7236 (via GitHub)" <gi...@apache.org> on 2025/12/01 15:19:14 UTC
[PR] fix(java): fix race condition in blocking queue serializers [fory]
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: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [PR] fix(java): fix race condition in blocking queue serializers [fory]
Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang merged PR #2956:
URL: https://github.com/apache/fory/pull/2956
--
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: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org