This is an automated email from the ASF dual-hosted git repository. gary pushed a commit to branch release-1.8 in repository https://gitbox.apache.org/repos/asf/flink.git
commit 33e0ca7d7c052dde404f0cabc4e514a7be284501 Author: Gary Yao <[email protected]> AuthorDate: Tue Feb 26 11:21:19 2019 +0100 [FLINK-10585][tests] Explicitly bind testing RestServerEndpoint on loopback address If we do not bind on a loopback address, the wildcard address will be chosen. The downside of that is it can happen that the server will be only available via either IPv4 or IPv6 (but not both). This can happen, for example, if another application chose to bind on the same (random) port but only using the IPv4 stack. In this case, the bind operation in the RestServerEndpoint will only succeed for IPv6 and silently fail for IPv4. --- .../apache/flink/runtime/rest/RestServerEndpointITCase.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerEndpointITCase.java b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerEndpointITCase.java index 3fe7168..5e2f853 100644 --- a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerEndpointITCase.java +++ b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerEndpointITCase.java @@ -81,6 +81,7 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.net.HttpURLConnection; +import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.URL; import java.nio.charset.StandardCharsets; @@ -171,9 +172,12 @@ public class RestServerEndpointITCase extends TestLogger { } private static Configuration getBaseConfig() { + final String loopbackAddress = InetAddress.getLoopbackAddress().getHostAddress(); + final Configuration config = new Configuration(); config.setString(RestOptions.BIND_PORT, "0"); - config.setString(RestOptions.ADDRESS, "localhost"); + config.setString(RestOptions.BIND_ADDRESS, loopbackAddress); + config.setString(RestOptions.ADDRESS, loopbackAddress); config.setInteger(RestOptions.SERVER_MAX_CONTENT_LENGTH, TEST_REST_MAX_CONTENT_LENGTH); config.setInteger(RestOptions.CLIENT_MAX_CONTENT_LENGTH, TEST_REST_MAX_CONTENT_LENGTH); return config; @@ -194,14 +198,12 @@ public class RestServerEndpointITCase extends TestLogger { RestServerEndpointConfiguration serverConfig = RestServerEndpointConfiguration.fromConfiguration(config); RestClientConfiguration clientConfig = RestClientConfiguration.fromConfiguration(config); - final String restAddress = "http://localhost:1234"; RestfulGateway mockRestfulGateway = mock(RestfulGateway.class); final GatewayRetriever<RestfulGateway> mockGatewayRetriever = () -> CompletableFuture.completedFuture(mockRestfulGateway); testHandler = new TestHandler( - CompletableFuture.completedFuture(restAddress), mockGatewayRetriever, RpcUtils.INF_TIMEOUT); @@ -636,10 +638,7 @@ public class RestServerEndpointITCase extends TestLogger { private Function<Integer, CompletableFuture<TestResponse>> handlerBody; - TestHandler( - CompletableFuture<String> localAddressFuture, - GatewayRetriever<RestfulGateway> leaderRetriever, - Time timeout) { + TestHandler(GatewayRetriever<RestfulGateway> leaderRetriever, Time timeout) { super( leaderRetriever, timeout,
