-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix HttpServletRequest.getRemoteAddr for the HttpConnector mode #311
Conversation
Signed-off-by: Lachlan Roberts <[email protected]>
|
||
@Override | ||
public String getRemoteAddr() { | ||
return finalUserIp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] Why not just use userIp
directly. It doesn't mutate between these lines right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@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"; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] Would prefer to have these as String constants since they are repeated (similar to `WARMUP_IP)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Signed-off-by: Lachlan Roberts <[email protected]>
PiperOrigin-RevId: 697805351 Change-Id: Iad4396c3346c88f4bba8aa93a2648815fe358c85
Add
RemoteAddressTest
to testgetRemoteAddr
,getLocalAddr
,getServerPort
,getRemotePort
,getLocalPort
andgetServerName
for jetty94, EE8 and EE10 over both RPC and HTTP modes.Add fixes in
JettyRequestAPIData
implementations to fix this for the HTTP mode.