juzi050 opened a new pull request, #16412:
URL: https://github.com/apache/dubbo/pull/16412

   What is the purpose of the change?
   
   Closes #16403.
   
   When Triple REST parses an `application/x-www-form-urlencoded` or 
`multipart/form-data` request, `DefaultHttpRequest` lazily creates and caches 
an `HttpPostRequestDecoder`. The decoder was not destroyed after the request 
completed, so `DefaultHttpDataFactory` continued to retain the request and its 
form data.
   
   This change attaches decoder cleanup to the HTTP response termination 
lifecycle:
   
   - Add a dedicated method to destroy the decoder cached by 
`DefaultHttpRequest`.
   - Clean up the decoder when the HTTP/1.1 or HTTP/2 server response observer 
terminates.
   - Cover normal completion, error responses, and connection closure while 
ensuring cleanup runs only once when termination events race.
   - Delay cleanup until response termination so multipart data remains 
available to the service method during request processing.
   
   ## How was it tested?
   
   Added `HttpPostRequestDecoderLifecycleTest`, which sends a form request 
through the real Triple REST request path and compares the number of requests 
tracked by `DefaultHttpDataFactory` before and after the request.
   
   - Before the fix: the test consistently failed because one request increased 
the tracked count from `0` to `1`.
   - After the fix: `Tests run: 1, Failures: 0, Errors: 0, Skipped: 0`.
   
   Command:
   
   ```shell
   ./mvnw -pl dubbo-rpc/dubbo-rpc-triple -am 
-Dtest=HttpPostRequestDecoderLifecycleTest 
-Dsurefire.failIfNoSpecifiedTests=false test
   ```
   
   The changed files were also formatted with 
`codestyle/dubbo_codestyle_for_idea.xml`. Maven Checkstyle and Spotless checks 
passed.
   
   ## Checklist
   
   - [x] Make sure there is a 
[GitHub_issue](https://github.com/apache/dubbo/issues) field for the change.
   - [x] Write a pull request description that is detailed enough to understand 
what the pull request does, how it does it, and why it does it.
   - [x] Write necessary unit-test to verify the code.
   - [x] Make sure gitHub actions can pass.
   


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to