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

   ## What is the purpose of the change?
   
   Fix three bugs in `ServletHttpRequestAdapter` (and its generated Jakarta 
Servlet counterpart in `dubbo-triple-servlet`):
   
   1. **`getRemoteHost()` returned the remote port instead of the host**: 
`getRemoteHost()` called `String.valueOf(remotePort())` instead of 
`remoteHost()`, returning e.g. `"54321"` instead of the peer host name/address.
   2. **`getRequestURL()` appended `: -1` when no port is specified in `Host` / 
`:authority`**: `DefaultHttpRequest.serverPort()` returns `-1` when the `Host` 
header omits a port (as verified in 
`DefaultHttpRequestTest.parsesHostAuthority`), so `port != 80` / `port != 443` 
evaluated to `true` and produced URLs like `http://example.com:-1/orders/1`. 
Guarding with `port > 0` omits unspecified ports while keeping non-default 
ports.
   3. **`HttpInputStream` overrode `readLine(byte[], int, int)` instead of 
`read(byte[], int, int)`**: Overriding `ServletInputStream.readLine(byte[], 
int, int)` with `is.read(b, off, len)` bypassed the Servlet specification's 
newline-delimited `readLine()` implementation (reading across multiple lines) 
and left bulk offset reads (`read(byte[], int, int)`) falling back to 
`InputStream`'s single-byte loop. Replacing the override with `read(byte[], 
int, int)` fixes both.
   
   ### Verification
   - Confirmed all three issues fail with the new tests in 
`ServletHttpRequestAdapterTest` before the fix.
   - Ran `./mvnw test -pl dubbo-plugin/dubbo-triple-servlet -am 
-Dtest=ServletHttpRequestAdapterTest,ServletHttpResponseAdapterTest 
-Dsurefire.failIfNoSpecifiedTests=false` (including `spotless:check`, 
`checkstyle`, and JDK 17 Jakarta source generation): 13/13 tests pass.
   
   ## Checklist
   - [x] Write a pull request description that is detailed enough to understand 
what the pull request does, how, and why.
   - [x] Write necessary unit-test to verify your logic correction.
   - [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]

  • [PR] fix(triple): fix get... flush921 (via GitHub) via notifications

Reply via email to