8217903: java/net/httpclient/Response204.java fails with 404
authordfuchs
Mon, 28 Jan 2019 18:45:34 +0000
changeset 53524 90865744493d
parent 53523 4c5184c56dc2
child 53525 c55508666f24
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
test/jdk/java/net/httpclient/Response204.java
--- 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();