lymerin opened a new pull request, #7481:
URL: https://github.com/apache/shenyu/pull/7481

   Fixes #7473
   
   ### Problem
   
   On cache misses, `CachePlugin.CacheHttpResponse.writeWith()` joins the 
response body and copies its bytes into a byte array without releasing the 
joined `DataBuffer`.
   
   The subsequent cache and response operations use the copied byte array, so 
they do not take ownership of the original buffer.
   
   ### Impact
   
   Responses are returned successfully, but pooled Netty buffers remain 
unreleased, increasing direct-memory pressure under cache-miss traffic.
   
   Both single-buffer and multi-buffer responses are affected. Cache hits 
bypass this response decorator.
   
   ### Changes
   
   - Release the joined buffer in a local `try/finally` around the byte-copy 
operation, before caching and writing the response.
   - Keep a single release point.
   - Add four regression cases using real pooled Netty buffers, covering 
single-buffer and multi-buffer responses, with and without an additional 
retained reference.
   - Verify that exactly one reference is released and that the response body, 
content length, cached body, and cached content type remain correct.
   
   ### Validation
   
   - Before the fix, all four new regression cases failed because the buffer 
reference counts remained unchanged.
   
     - 11 tests passed, with no failures or errors.
     - Checkstyle reported 0 violations.
   
   ### Checklist
   
   - [x] You have read the [[contribution 
guidelines](https://shenyu.apache.org/community/contributor-guide)](https://shenyu.apache.org/community/contributor-guide).
   - [x] You submit test cases (unit or integration tests) that back your 
changes.
   - [x] Your local test passed `./mvnw clean install 
-Dmaven.javadoc.skip=true`.


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

Reply via email to