You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ServletServerHttpRequest.getRemoteAddress() may perform DNS lookup #35589
If the underlying jakarta.servlet.ServletRequest#getRemoteHost implementation does a DNS lookup (as it is allowed, but not required to do), then calling ServletServerHttpRequest#getRemoteAddress will also do a DNS lookup. ServletServerHttpRequest#getRemoteAddress is for example called by Spring's ForwardedHeaderFilter.
As the ServletServerHttpRequest#getRemoteAddress return type is InetSocketAddress it feels like doing DNS resolution is quite pointless in general.
I have been trying to extract a minimal reproducer but I'm having some trouble getting it reproduced in a minimal setting. It might involve WebSocket via JSR 356 using Atmosphere and Jetty as the servlet container.
and ServerHttpRequest uses constructor of InetSocketAddress, which performs DNS lookup:
@Override
public InetSocketAddress getLocalAddress() {
return new InetSocketAddress(this.servletRequest.getLocalAddr(), this.servletRequest.getLocalPort());
}
@Override
public InetSocketAddress getRemoteAddress() {
return new InetSocketAddress(this.servletRequest.getRemoteHost(), this.servletRequest.getRemotePort());
}
I've made an an adjustment to fall back remoteHost if the remoteAddress is null for any reason. We've run into internal test failures, and although I'm not sure if that can happen at runtime, it doesn't hurt to have a fallback since otherwise the null address results an IllegalArgumentException.
Activity
slovdahl commentedon Oct 9, 2025
Quoting #28280 (comment)
Use getRemoteAddr in ServletServerHttpRequest
github-actions commentedon Oct 10, 2025
Fixed via 2c83144
slovdahl commentedon Oct 10, 2025
Thanks a lot @rstoyanchev for fixing this so quickly, much appreciated!
Fall back on remoteHost if remoteAddress is null
rstoyanchev commentedon Oct 15, 2025
I've made an an adjustment to fall back remoteHost if the remoteAddress is null for any reason. We've run into internal test failures, and although I'm not sure if that can happen at runtime, it doesn't hurt to have a fallback since otherwise the null address results an IllegalArgumentException.