Sean-Walker0 opened a new pull request, #7434:
URL: https://github.com/apache/shenyu/pull/7434

   Fixes #6512
   
   ## Modifications
   
   `LoggingConsolePlugin` handled `Content-Encoding: gzip` responses by 
decompressing **each response `DataBuffer` chunk as an independent gzip 
stream**. A gzip stream that spans several chunks cannot be decompressed chunk 
by chunk: the per-chunk `GZIPInputStream` either yields truncated data (first 
chunk) or throws and writes the raw compressed bytes to the log (later chunks). 
Any gzipped response delivered in more than one buffer therefore produced 
unreadable response-body logs.
   
   The raw chunks are now assembled while streaming, and the whole gzip stream 
is decompressed **once** when the body completes:
   
   ```java
   if (gzipEncoded) {
       // a gzip stream can only be decompressed as a whole, so the raw
       // chunks are assembled first and decompressed once at the end
       byte[] chunk = new byte[readOnlyBuffer.remaining()];
       readOnlyBuffer.get(chunk);
       gzipBuffer.writeBytes(chunk);
   } else {
       writer.write(readOnlyBuffer);
   }
   ```
   
   The plain (non-gzip) path is byte-for-byte unchanged, single-buffer gzip 
responses produce the same output as before, and a failed decompression still 
falls back to the raw bytes with an ERROR log (previous fallback behavior).
   
   ## Verifying this change
   
   - [x] New 
`LoggingConsolePluginTest#testGzipResponseLoggedDecompressedAcrossChunks` — a 
gzip-compressed JSON payload is split across two `DataBuffer`s and the logged 
body must contain the decompressed text. Red on the pre-fix code (`the logged 
body should be the decompressed payload ==> expected: <true> but was: 
<false>`), green after.
   - [x] `./mvnw -pl 
shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-console -am test -B` 
— 9/9 module tests green (pre-existing desensitization cases unchanged), 
checkstyle clean.
   
   ## Notes
   
   - Behavior change: only for gzip responses spanning multiple buffers — the 
logged body is now the correctly decompressed payload instead of truncated/raw 
compressed bytes.
   - Byte-type responses (`[bytes]` short-circuit) and non-gzip bodies are 
untouched.
   - Orthogonality: no open PR modifies `shenyu-plugin-logging-console` 
(verified against the file lists of all 91 open PRs).
   
   Make sure that:
   
   - [x] You have read the [contribution 
guidelines](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` (module-scoped: 
`shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-console` with `-am`, 
tests + checkstyle green).


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