1 /* |
1 /* |
2 * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
23 |
23 |
24 /** |
24 /** |
25 * @test |
25 * @test |
26 * @bug 6648001 |
26 * @bug 6648001 |
27 * @modules jdk.httpserver |
27 * @modules jdk.httpserver |
|
28 * @library /test/lib |
28 * @run main/othervm/timeout=20 -ea:sun.net.www.protocol.http.AuthenticationInfo -Dhttp.auth.serializeRequests=true Deadlock |
29 * @run main/othervm/timeout=20 -ea:sun.net.www.protocol.http.AuthenticationInfo -Dhttp.auth.serializeRequests=true Deadlock |
|
30 * @run main/othervm/timeout=20 -Djava.net.preferIPv6Addresses=true |
|
31 * -ea:sun.net.www.protocol.http.AuthenticationInfo -Dhttp.auth.serializeRequests=true Deadlock |
29 * @summary cancelling HTTP authentication causes deadlock |
32 * @summary cancelling HTTP authentication causes deadlock |
30 */ |
33 */ |
31 |
34 |
32 import java.util.concurrent.Executors; |
35 import java.util.concurrent.Executors; |
33 import java.util.concurrent.ExecutorService; |
36 import java.util.concurrent.ExecutorService; |
34 import java.io.InputStream; |
37 import java.io.InputStream; |
35 import java.io.IOException; |
38 import java.io.IOException; |
36 import java.net.HttpURLConnection; |
39 import java.net.HttpURLConnection; |
|
40 import java.net.InetAddress; |
37 import java.net.InetSocketAddress; |
41 import java.net.InetSocketAddress; |
38 import java.net.PasswordAuthentication; |
42 import java.net.PasswordAuthentication; |
|
43 import java.net.Proxy; |
39 import java.net.URL; |
44 import java.net.URL; |
40 import com.sun.net.httpserver.BasicAuthenticator; |
45 import com.sun.net.httpserver.BasicAuthenticator; |
41 import com.sun.net.httpserver.Headers; |
46 import com.sun.net.httpserver.Headers; |
42 import com.sun.net.httpserver.HttpContext; |
47 import com.sun.net.httpserver.HttpContext; |
43 import com.sun.net.httpserver.HttpExchange; |
48 import com.sun.net.httpserver.HttpExchange; |
44 import com.sun.net.httpserver.HttpHandler; |
49 import com.sun.net.httpserver.HttpHandler; |
45 import com.sun.net.httpserver.HttpPrincipal; |
50 import com.sun.net.httpserver.HttpPrincipal; |
46 import com.sun.net.httpserver.HttpServer; |
51 import com.sun.net.httpserver.HttpServer; |
|
52 import jdk.test.lib.net.URIBuilder; |
47 |
53 |
48 public class Deadlock { |
54 public class Deadlock { |
49 |
55 |
50 public static void main (String[] args) throws Exception { |
56 public static void main (String[] args) throws Exception { |
51 Handler handler = new Handler(); |
57 Handler handler = new Handler(); |
52 InetSocketAddress addr = new InetSocketAddress (0); |
58 InetAddress loopback = InetAddress.getLoopbackAddress(); |
|
59 InetSocketAddress addr = new InetSocketAddress (loopback, 0); |
53 HttpServer server = HttpServer.create(addr, 0); |
60 HttpServer server = HttpServer.create(addr, 0); |
54 HttpContext ctx = server.createContext("/test", handler); |
61 HttpContext ctx = server.createContext("/test", handler); |
55 BasicAuthenticator a = new BasicAuthenticator("foobar@test.realm") { |
62 BasicAuthenticator a = new BasicAuthenticator("foobar@test.realm") { |
56 @Override |
63 @Override |
57 public boolean checkCredentials (String username, String pw) { |
64 public boolean checkCredentials (String username, String pw) { |