Merge branch '1.5.x'
This commit is contained in:
commit
cebe6579d1
|
|
@ -161,7 +161,7 @@ public class JettyReactiveWebServerFactory extends AbstractReactiveWebServerFact
|
|||
private AbstractConnector createConnector(InetSocketAddress address, Server server) {
|
||||
ServerConnector connector = new ServerConnector(server, this.acceptors,
|
||||
this.selectors);
|
||||
connector.setHost(address.getHostName());
|
||||
connector.setHost(address.getHostString());
|
||||
connector.setPort(address.getPort());
|
||||
for (ConnectionFactory connectionFactory : connector.getConnectionFactories()) {
|
||||
if (connectionFactory instanceof HttpConfiguration.ConnectionFactory) {
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ public class JettyServletWebServerFactory extends AbstractServletWebServerFactor
|
|||
private AbstractConnector createConnector(InetSocketAddress address, Server server) {
|
||||
ServerConnector connector = new ServerConnector(server, this.acceptors,
|
||||
this.selectors);
|
||||
connector.setHost(address.getHostName());
|
||||
connector.setHost(address.getHostString());
|
||||
connector.setPort(address.getPort());
|
||||
for (ConnectionFactory connectionFactory : connector.getConnectionFactories()) {
|
||||
if (connectionFactory instanceof HttpConfiguration.ConnectionFactory) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -16,15 +16,19 @@
|
|||
|
||||
package org.springframework.boot.web.embedded.jetty;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InOrder;
|
||||
|
||||
import org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFactoryTests;
|
||||
import org.springframework.http.server.reactive.HttpHandler;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.inOrder;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
|
@ -76,4 +80,17 @@ public class JettyReactiveWebServerFactoryTests
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void specificIPAddressNotReverseResolved() throws Exception {
|
||||
JettyReactiveWebServerFactory factory = getFactory();
|
||||
InetAddress localhost = InetAddress.getLocalHost();
|
||||
factory.setAddress(InetAddress.getByAddress(localhost.getAddress()));
|
||||
this.webServer = factory.getWebServer(mock(HttpHandler.class));
|
||||
this.webServer.start();
|
||||
Connector connector = ((JettyWebServer) this.webServer).getServer()
|
||||
.getConnectors()[0];
|
||||
assertThat(((ServerConnector) connector).getHost())
|
||||
.isEqualTo(localhost.getHostAddress());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package org.springframework.boot.web.embedded.jetty;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.nio.charset.Charset;
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
|
|
@ -23,6 +24,7 @@ import java.util.Locale;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.jasper.servlet.JspServlet;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
|
|
@ -273,6 +275,19 @@ public class JettyServletWebServerFactoryTests
|
|||
factory.getWebServer().start();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void specificIPAddressNotReverseResolved() throws Exception {
|
||||
JettyServletWebServerFactory factory = getFactory();
|
||||
InetAddress localhost = InetAddress.getLocalHost();
|
||||
factory.setAddress(InetAddress.getByAddress(localhost.getAddress()));
|
||||
this.webServer = factory.getWebServer();
|
||||
this.webServer.start();
|
||||
Connector connector = ((JettyWebServer) this.webServer).getServer()
|
||||
.getConnectors()[0];
|
||||
assertThat(((ServerConnector) connector).getHost())
|
||||
.isEqualTo(localhost.getHostAddress());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JspServlet getJspServlet() throws Exception {
|
||||
WebAppContext context = (WebAppContext) ((JettyWebServer) this.webServer)
|
||||
|
|
|
|||
Loading…
Reference in New Issue