8217903: java/net/httpclient/Response204.java fails with 404
Summary: Fixed test to use loopback address - this looks like a port reuse issue.
Reviewed-by: chegar
--- a/test/jdk/java/net/httpclient/Response204.java Mon Jan 28 15:53:56 2019 +0100
+++ b/test/jdk/java/net/httpclient/Response204.java Mon Jan 28 18:45:34 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -55,14 +55,17 @@
logger.addHandler (c);
logger.setLevel (Level.WARNING);
Handler handler = new Handler();
- InetSocketAddress addr = new InetSocketAddress (0);
+ InetSocketAddress addr = new InetSocketAddress (InetAddress.getLoopbackAddress(), 0);
HttpServer server = HttpServer.create (addr, 0);
HttpContext ctx = server.createContext ("/test", handler);
ExecutorService executor = Executors.newCachedThreadPool();
server.setExecutor (executor);
server.start ();
- URI uri = new URI("http://localhost:"+server.getAddress().getPort()+"/test/foo.html");
+ URI uri = new URI("http", null,
+ server.getAddress().getHostString(),
+ server.getAddress().getPort(),
+ "/test/foo.html", null, null);
try {
HttpClient client = HttpClient.newHttpClient();