equal
deleted
inserted
replaced
21 * questions. |
21 * questions. |
22 */ |
22 */ |
23 |
23 |
24 /* @test |
24 /* @test |
25 * @bug 6215885 |
25 * @bug 6215885 |
|
26 * @library /test/lib |
26 * @summary URLConnection.openConnection NPE if ProxySelector.setDefault is set to null |
27 * @summary URLConnection.openConnection NPE if ProxySelector.setDefault is set to null |
27 */ |
28 */ |
28 |
29 |
29 import java.net.*; |
30 import java.net.*; |
30 import java.io.*; |
31 import java.io.*; |
|
32 import jdk.test.lib.net.URIBuilder; |
31 |
33 |
32 public class NullSelector { |
34 public class NullSelector { |
33 public static void main(String[] args) throws Exception { |
35 public static void main(String[] args) throws Exception { |
34 URL url = new URL("http://127.0.0.1/"); |
36 URL url = URIBuilder.newBuilder() |
|
37 .scheme("http") |
|
38 .loopback() |
|
39 .path("/") |
|
40 .toURLUnchecked(); |
|
41 System.out.println("URL: " + url); |
35 ProxySelector.setDefault(null); |
42 ProxySelector.setDefault(null); |
36 URLConnection con = url.openConnection(); |
43 URLConnection con = url.openConnection(); |
37 con.setConnectTimeout(500); |
44 con.setConnectTimeout(500); |
38 try { |
45 try { |
39 // Will throw a NullPointerException if bug still there |
46 // Will throw a NullPointerException if bug still there |