Skip to content

Commit 9f7b025

Browse files
jhoellerBenjamin Reed
authored and
Benjamin Reed
committed
Consistent use of getLocalAddr() without DNS lookups in request adapters
Closes spring-projectsgh-28280
1 parent 07ae85f commit 9f7b025

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

spring-web/src/main/java/org/springframework/http/server/ServletServerHttpRequest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -148,7 +148,7 @@ public Principal getPrincipal() {
148148

149149
@Override
150150
public InetSocketAddress getLocalAddress() {
151-
return new InetSocketAddress(this.servletRequest.getLocalName(), this.servletRequest.getLocalPort());
151+
return new InetSocketAddress(this.servletRequest.getLocalAddr(), this.servletRequest.getLocalPort());
152152
}
153153

154154
@Override
@@ -169,7 +169,10 @@ public InputStream getBody() throws IOException {
169169
@Override
170170
public ServerHttpAsyncRequestControl getAsyncRequestControl(ServerHttpResponse response) {
171171
if (this.asyncRequestControl == null) {
172-
Assert.isInstanceOf(ServletServerHttpResponse.class, response);
172+
if (!(response instanceof ServletServerHttpResponse)) {
173+
throw new IllegalArgumentException(
174+
"Response must be a ServletServerHttpResponse: " + response.getClass());
175+
}
173176
ServletServerHttpResponse servletServerResponse = (ServletServerHttpResponse) response;
174177
this.asyncRequestControl = new ServletServerHttpAsyncRequestControl(this, servletServerResponse);
175178
}

0 commit comments

Comments
 (0)