Fix HttpServletRequest.getRemoteAddr for the HttpConnector mode - #311
Merged
Conversation
Signed-off-by: Lachlan Roberts <lachlan.p.roberts@gmail.com>
maigovannon
approved these changes
Nov 18, 2024
|
|
||
| @Override | ||
| public String getRemoteAddr() { | ||
| return finalUserIp; |
Collaborator
There was a problem hiding this comment.
[nit] Why not just use userIp directly. It doesn't mutate between these lines right?
Collaborator
Author
There was a problem hiding this comment.
Not possible because it is reassigned above and the variable has to be "effectively final", the compiler will give the error:
Variable 'userIp' is accessed from within inner class, needs to be final or effectively final
Comment on lines
+336
to
+359
| @Override | ||
| public String getServerName() { | ||
| return "0.0.0.0"; | ||
| } | ||
|
|
||
| @Override | ||
| public String getRemoteHost() { | ||
| return finalUserIp; | ||
| } | ||
|
|
||
| @Override | ||
| public int getRemotePort() { | ||
| return 0; | ||
| } | ||
|
|
||
| @Override | ||
| public String getLocalName() { | ||
| return "0.0.0.0"; | ||
| } | ||
|
|
||
| @Override | ||
| public String getLocalAddr() { | ||
| return "0.0.0.0"; | ||
| } |
Collaborator
There was a problem hiding this comment.
[nit] Would prefer to have these as String constants since they are repeated (similar to `WARMUP_IP)
Signed-off-by: Lachlan Roberts <lachlan.p.roberts@gmail.com>
ludoch
pushed a commit
that referenced
this pull request
Nov 22, 2024
PiperOrigin-RevId: 697805351 Change-Id: Iad4396c3346c88f4bba8aa93a2648815fe358c85
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
RemoteAddressTestto testgetRemoteAddr,getLocalAddr,getServerPort,getRemotePort,getLocalPortandgetServerNamefor jetty94, EE8 and EE10 over both RPC and HTTP modes.Add fixes in
JettyRequestAPIDataimplementations to fix this for the HTTP mode.