[BUG] LogCollectUtils serializes headers to JSON on the request thread
- Dominant language
- Java
- Stars
- 8.8k
- Forks
- 3.1k
- Avg merge
- 7d 1h
- Merged PRs (30d)
- 85
Description
## Description
`getHeaders` runs on the request thread: `headers.entrySet().stream().collect(Collectors.toMap(...))` (HashMap), `String.join(",", entry.getValue())` per header, then `JsonUtils.toJson(map)` (Gson reflection) per request. The downstream `LogCollector.collect` is async (buffer queue), but the header capture/JSON is synchronous on the request path.
## Location
```
shenyu-plugin-logging-common/.../utils/LogCollectUtils.java:56-60 (from AbstractLoggingPlugin.java:108)
```
## Impact
Blocking CPU serialization on the Netty event loop for every logged request; non-trivial for requests with many headers.
## Suggested fix
Defer serialization to the consumer thread (enqueue the raw `HttpHeaders` reference and serialize in `AbstractLogCollector.consume`), or cache a precomputed header-name allowlist.
## Related existing issue(s)
#6512 (gzip per chunk) and #6511 (desensitization leak) are different defects in the logging plugin.
_Identified during the 2026-08-02 audit; full list in [`docs/issue-candidates-2026-08-02.md`](docs/issue-candidates-2026-08-02.md)._
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in shenyu-plugin-logging-common/.../utils/LogCollectUtils.java:56-60 and trace the call from AbstractLoggingPlugin.java:108 into the async LogCollector path. Read AbstractLogCollector.consume to understand where serialization can move without changing logging behavior. Done means header JSON work no longer runs synchronously on the request thread; run the existing logging tests, if present, to verify output remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100