apache / apache/shenyu

[BUG] Non-atomic check-then-add on buffer queue can throw IllegalStateException

Closed Beginner friendly
#6,762 1 comment 0 reactions 0 assignees View on GitHub
priority: medium type: bug
Dominant language
Java
Stars
8.8k
Forks
3.1k
Avg merge
7d 1h
Merged PRs (30d)
85

Description

- severity: Medium
- files: `shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/.../AbstractLogCollector.java:94-96,98-100`
- description: `collect()` checks `bufferQueue.size() < bufferSize` then calls `bufferQueue.add(log)`. Not atomic. Multiple concurrent threads can all pass the size check, then all call `add()`. `add()` on a full `LinkedBlockingDeque` throws `IllegalStateException` (not `offer()` which returns false).
- impact: Under high concurrency near capacity, request threads receive uncaught `IllegalStateException`, potentially failing HTTP requests.
- suggested_fix: Replace `bufferQueue.add(log)` with `bufferQueue.offer(log)`.
- confidence: High
- related_existing: none

---
_Identified during the 2026-08-02 deep re-scan; full list in [`docs/scan2-2026-08-02/06-medium-tiers.md`](docs/scan2-2026-08-02/06-medium-tiers.md)._

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/.../AbstractLogCollector.java around lines 94-100 and inspect collect() with the LinkedBlockingDeque capacity check. Verify the queue operation remains safe when concurrent calls reach capacity, then run the relevant logging tests if available; done means a full queue no longer throws IllegalStateException to request threads.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
82/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.