Skip to content

Commit 8a70265

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 ca93cb6 commit 8a70265

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-2016 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.
@@ -159,7 +159,7 @@ public Principal getPrincipal() {
159159

160160
@Override
161161
public InetSocketAddress getLocalAddress() {
162-
return new InetSocketAddress(this.servletRequest.getLocalName(), this.servletRequest.getLocalPort());
162+
return new InetSocketAddress(this.servletRequest.getLocalAddr(), this.servletRequest.getLocalPort());
163163
}
164164

165165
@Override
@@ -180,7 +180,10 @@ public InputStream getBody() throws IOException {
180180
@Override
181181
public ServerHttpAsyncRequestControl getAsyncRequestControl(ServerHttpResponse response) {
182182
if (this.asyncRequestControl == null) {
183-
Assert.isInstanceOf(ServletServerHttpResponse.class, response);
183+
if (!(response instanceof ServletServerHttpResponse)) {
184+
throw new IllegalArgumentException(
185+
"Response must be a ServletServerHttpResponse: " + response.getClass());
186+
}
184187
ServletServerHttpResponse servletServerResponse = (ServletServerHttpResponse) response;
185188
this.asyncRequestControl = new ServletServerHttpAsyncRequestControl(this, servletServerResponse);
186189
}

0 commit comments

Comments
 (0)