yykaue opened a new pull request, #6915:
URL: https://github.com/apache/shenyu/pull/6915
Fixes #6811
Thanks @Aias00 for reporting this issue.
## What this PR does
Use try-with-resources to manage `GZIPInputStream` and
`ByteArrayOutputStream` in `AiResponseTransformerPlugin`.
Previously, these streams were closed only after successful decompression.
If `GZIPInputStream.read()` threw an exception while processing a truncated or
corrupted gzip response, the stream was not closed and its native `Inflater`
resources could remain allocated until garbage collection.
With this change, both streams are closed automatically on successful and
exceptional paths.
## Tests
- Added a regression test that makes `GZIPInputStream.read()` throw an
`IOException`.
- Verified that `GZIPInputStream.close()` is called after decompression
fails.
- Passed the response transformer module tests:
```text
./mvnw -pl
shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-response-transformer test
Tests run: 47, Failures: 0, Errors: 0, Skipped: 0
--
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]