changeset 55047:3131927311ee

8224761: Replace wildcard address with loopback or local host in tests - part 12 Summary: fixes a batch of intermittent failures. Reviewed-by: chegar, vtewari
author dfuchs
date Mon, 27 May 2019 19:24:42 +0100
parents 7f03c3e42628
children 812212323fb1
files test/jdk/com/sun/net/httpserver/Test6a.java test/jdk/java/net/MulticastSocket/UnreferencedMulticastSockets.java test/jdk/java/net/ProxySelector/ProxyTest.java test/jdk/java/net/ResponseCache/Test.java test/jdk/java/net/URLConnection/ZeroContentLength.java test/jdk/sun/net/www/http/HttpClient/B6726695.java test/jdk/sun/net/www/http/KeepAliveStream/InfiniteLoop.java test/jdk/sun/net/www/protocol/http/HttpOnly.java test/jdk/sun/net/www/protocol/https/HttpsURLConnection/HttpsCreateSockTest.java test/lib/jdk/test/lib/NetworkConfiguration.java
diffstat 10 files changed, 124 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/test/jdk/com/sun/net/httpserver/Test6a.java	Mon May 27 14:57:26 2019 +0200
+++ b/test/jdk/com/sun/net/httpserver/Test6a.java	Mon May 27 19:24:42 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -27,6 +27,7 @@
  * @library /test/lib
  * @build jdk.test.lib.net.SimpleSSLContext
  * @run main/othervm Test6a
+ * @run main/othervm -Djava.net.preferIPv6Addresses=true Test6a
  * @summary Light weight HTTP server
  */
 
@@ -38,6 +39,8 @@
 import javax.net.ssl.*;
 import jdk.test.lib.net.SimpleSSLContext;
 
+import jdk.test.lib.net.URIBuilder;
+
 /**
  * Test https POST large file via chunked encoding (unusually small chunks)
  */
@@ -46,7 +49,8 @@
 
     public static void main (String[] args) throws Exception {
         Handler handler = new Handler();
-        InetSocketAddress addr = new InetSocketAddress (0);
+        InetAddress loopback = InetAddress.getLoopbackAddress();
+        InetSocketAddress addr = new InetSocketAddress (loopback, 0);
         HttpsServer server = HttpsServer.create (addr, 0);
         HttpContext ctx = server.createContext ("/test", handler);
         ExecutorService executor = Executors.newCachedThreadPool();
@@ -55,9 +59,16 @@
         server.setHttpsConfigurator(new HttpsConfigurator (ssl));
         server.start ();
 
-        URL url = new URL ("https://localhost:"+server.getAddress().getPort()+"/test/foo.html");
-        System.out.print ("Test6a: " );
-        HttpsURLConnection urlc = (HttpsURLConnection)url.openConnection ();
+        URL url = URIBuilder.newBuilder()
+                  .scheme("https")
+                  .host(server.getAddress().getAddress())
+                  .port(server.getAddress().getPort())
+                  .path("/test/foo.html")
+                  .toURL();
+
+        System.out.println("Test6a: URL=" + url);
+        System.out.print("Test6a: ");
+        HttpsURLConnection urlc = (HttpsURLConnection)url.openConnection(Proxy.NO_PROXY);
         urlc.setDoOutput (true);
         urlc.setRequestMethod ("POST");
         urlc.setChunkedStreamingMode (32); // small chunks
--- a/test/jdk/java/net/MulticastSocket/UnreferencedMulticastSockets.java	Mon May 27 14:57:26 2019 +0200
+++ b/test/jdk/java/net/MulticastSocket/UnreferencedMulticastSockets.java	Mon May 27 19:24:42 2019 +0100
@@ -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
@@ -41,6 +41,7 @@
 import java.net.DatagramSocket;
 import java.net.DatagramSocketImpl;
 import java.net.InetAddress;
+import java.net.InetSocketAddress;
 import java.net.MulticastSocket;
 import java.net.UnknownHostException;
 import java.nio.file.Files;
@@ -73,7 +74,9 @@
         MulticastSocket ss;
 
         Server() throws IOException {
-            ss = new MulticastSocket(0);
+            InetSocketAddress serverAddress =
+                new InetSocketAddress(InetAddress.getLoopbackAddress(), 0);
+            ss = new MulticastSocket(serverAddress);
             System.out.printf("  DatagramServer addr: %s: %d%n",
                     this.getHost(), this.getPort());
             pendingSockets.add(new NamedWeak(ss, pendingQueue, "serverMulticastSocket"));
@@ -81,7 +84,7 @@
         }
 
         InetAddress getHost() throws UnknownHostException {
-            InetAddress localhost = InetAddress.getByName("localhost"); //.getLocalHost();
+            InetAddress localhost = InetAddress.getLoopbackAddress();
             return localhost;
         }
 
--- a/test/jdk/java/net/ProxySelector/ProxyTest.java	Mon May 27 14:57:26 2019 +0200
+++ b/test/jdk/java/net/ProxySelector/ProxyTest.java	Mon May 27 19:24:42 2019 +0100
@@ -34,7 +34,7 @@
 
 import java.net.*;
 import java.io.*;
-import java.util.ArrayList;
+import java.util.List;
 import jdk.test.lib.net.URIBuilder;
 
 public class ProxyTest implements HttpCallback {
@@ -43,10 +43,10 @@
     public ProxyTest() {
     }
 
-    public void request (HttpTransaction req) {
-        req.setResponseEntityBody ("Hello .");
+    public void request(HttpTransaction req) {
+        req.setResponseEntityBody("Hello .");
         try {
-            req.sendResponse (200, "Ok");
+            req.sendResponse(200, "Ok");
             req.orderlyClose();
         } catch (IOException e) {
         }
@@ -54,17 +54,12 @@
 
     static public class MyProxySelector extends ProxySelector {
         private static volatile URI lastURI;
-        private final ArrayList<Proxy> noProxy;
-
-        public MyProxySelector() {
-            noProxy = new ArrayList<Proxy>(1);
-            noProxy.add(Proxy.NO_PROXY);
-        }
+        private final static List<Proxy> NO_PROXY = List.of(Proxy.NO_PROXY);
 
         public java.util.List<Proxy> select(URI uri) {
             System.out.println("Selecting no proxy for " + uri);
             lastURI = uri;
-            return noProxy;
+            return NO_PROXY;
         }
 
         public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
@@ -80,15 +75,15 @@
         ProxySelector.setDefault(new MyProxySelector());
         try {
             InetAddress loopback = InetAddress.getLoopbackAddress();
-            server = new TestHttpServer (new ProxyTest(), 1, 10, 0);
+            server = new TestHttpServer(new ProxyTest(), 1, 10, loopback, 0);
             URL url = URIBuilder.newBuilder()
                       .scheme("http")
                       .loopback()
                       .port(server.getLocalPort())
                       .toURL();
-            System.out.println ("client opening connection to: " + url);
-            HttpURLConnection urlc = (HttpURLConnection)url.openConnection ();
-            InputStream is = urlc.getInputStream ();
+            System.out.println("client opening connection to: " + url);
+            HttpURLConnection urlc = (HttpURLConnection)url.openConnection();
+            InputStream is = urlc.getInputStream();
             is.close();
             URI lastURI = MyProxySelector.lastURI();
             if (!String.valueOf(lastURI).equals(url + "/")) {
--- a/test/jdk/java/net/ResponseCache/Test.java	Mon May 27 14:57:26 2019 +0200
+++ b/test/jdk/java/net/ResponseCache/Test.java	Mon May 27 19:24:42 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -25,6 +25,9 @@
  * @summary Fixed a potential NullPointerException when setting a ResponseCache that returns a null CacheRequest
  * @bug 4837267
  * @modules jdk.httpserver
+ * @library /test/lib
+ * @run main Test
+ * @run main/othervm -Djava.net.preferIPv6Addresses=true Test
  * @author Michael McMahon
  */
 
@@ -33,6 +36,8 @@
 import java.io.*;
 import java.util.*;
 
+import jdk.test.lib.net.URIBuilder;
+
 public class Test
 {
 
@@ -51,14 +56,15 @@
     }
 
     public static void main(String args[])  throws Exception {
-        HttpServer server = HttpServer.create(new InetSocketAddress(0), 0);
+        InetAddress loopback = InetAddress.getLoopbackAddress();
+        HttpServer server = HttpServer.create(new InetSocketAddress(loopback, 0), 0);
         server.createContext("/", new MyHandler());
         server.start();
         ResponseCache bak = ResponseCache.getDefault();
 
         try {
-            ResponseCache.setDefault (new ResponseCache() {
-                public CacheResponse get (URI uri, String rqstMethod, Map<String,List<String>> rqstHeaders)
+            ResponseCache.setDefault(new ResponseCache() {
+                public CacheResponse get(URI uri, String rqstMethod, Map<String,List<String>> rqstHeaders)
                     throws IOException {
                     return null;
                 }
@@ -68,8 +74,13 @@
                 }
             });
 
-            URL url = new URL ("http://localhost:" + server.getAddress().getPort() + "/");
-            URLConnection urlc = url.openConnection ();
+            URL url = URIBuilder.newBuilder()
+                      .scheme("http")
+                      .host(server.getAddress().getAddress())
+                      .port(server.getAddress().getPort())
+                      .path("/")
+                      .toURL();
+            URLConnection urlc = url.openConnection(Proxy.NO_PROXY);
             InputStream is = urlc.getInputStream();
             while (is.read() != -1) ;
             is.close();
--- a/test/jdk/java/net/URLConnection/ZeroContentLength.java	Mon May 27 14:57:26 2019 +0200
+++ b/test/jdk/java/net/URLConnection/ZeroContentLength.java	Mon May 27 19:24:42 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -30,9 +30,14 @@
  *          connection.
  *          Check that a content-length of 0 results in an
  *          empty input stream.
+ * @library /test/lib
+ * @run main ZeroContentLength
+ * @run main/othervm -Djava.net.preferIPv6Addresses=true ZeroContentLength
  */
+
 import java.net.*;
 import java.io.*;
+import jdk.test.lib.net.URIBuilder;
 
 public class ZeroContentLength {
 
@@ -231,7 +236,7 @@
      */
     int doRequest(String uri) throws Exception {
         URL url = new URL(uri);
-        HttpURLConnection http = (HttpURLConnection)url.openConnection();
+        HttpURLConnection http = (HttpURLConnection)url.openConnection(Proxy.NO_PROXY);
 
         int cl = http.getContentLength();
 
@@ -264,13 +269,17 @@
     ZeroContentLength() throws Exception {
 
         /* start the server */
-        ServerSocket ss = new ServerSocket(0);
+        ServerSocket ss = new ServerSocket();
+        ss.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
         Server svr = new Server(ss);
         svr.start();
 
-        String uri = "http://localhost:" +
-                     Integer.toString(ss.getLocalPort()) +
-                     "/foo.html";
+        String uri = URIBuilder.newBuilder()
+                     .scheme("http")
+                     .host(ss.getInetAddress())
+                     .port(ss.getLocalPort())
+                     .path("/foo.html")
+                     .build().toString();
 
         int expectedTotal = 0;
         int actualTotal = 0;
--- a/test/jdk/sun/net/www/http/HttpClient/B6726695.java	Mon May 27 14:57:26 2019 +0200
+++ b/test/jdk/sun/net/www/http/HttpClient/B6726695.java	Mon May 27 19:24:42 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -24,12 +24,17 @@
 /*
  * @test
  * @bug 6726695 6993490
- * @summary HttpURLConnection shoul support 'Expect: 100-contimue' headers for PUT
+ * @summary HttpURLConnection should support 'Expect: 100-contimue' headers for PUT
+ * @library /test/lib
+ * @run main B6726695
+ * @run main/othervm -Djava.net.preferIPv6Addresses=true B6726695
 */
 
 import java.net.*;
 import java.io.*;
 
+import jdk.test.lib.net.URIBuilder;
+
 public class B6726695 extends Thread {
     private ServerSocket server = null;
     private int port = 0;
@@ -48,7 +53,8 @@
 
     public B6726695() {
         try {
-            server = new ServerSocket(0);
+            server = new ServerSocket();
+            server.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
             port = server.getLocalPort();
         } catch (IOException e) {
             e.printStackTrace();
@@ -64,10 +70,15 @@
          * the Expect: 100-Continue header. So the POST should proceed after
          * a timeout.
          */
-        URL url = new URL("http://localhost:" + port + "/foo");
+        URL url = URIBuilder.newBuilder()
+                  .scheme("http")
+                  .loopback()
+                  .port(port)
+                  .path("/foo")
+                  .toURL();
 
         // 1st Connection. Should be rejected. I.E. get a ProtocolException
-        URLConnection con = url.openConnection();
+        URLConnection con = url.openConnection(Proxy.NO_PROXY);
         HttpURLConnection http = (HttpURLConnection) con;
         http.setRequestMethod("POST");
         http.setRequestProperty("Expect", "100-Continue");
@@ -86,7 +97,7 @@
         }
 
         // 2nd connection. Should be accepted by server.
-        http = (HttpURLConnection) url.openConnection();
+        http = (HttpURLConnection) url.openConnection(Proxy.NO_PROXY);
         http.setRequestMethod("POST");
         http.setRequestProperty("Expect", "100-Continue");
         http.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
@@ -109,7 +120,7 @@
         out.close();
 
         // 3rd connection. Simulate a server that doesn't implement 100-continue
-        http = (HttpURLConnection) url.openConnection();
+        http = (HttpURLConnection) url.openConnection(Proxy.NO_PROXY);
         http.setRequestMethod("POST");
         http.setRequestProperty("Expect", "100-Continue");
         http.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
--- a/test/jdk/sun/net/www/http/KeepAliveStream/InfiniteLoop.java	Mon May 27 14:57:26 2019 +0200
+++ b/test/jdk/sun/net/www/http/KeepAliveStream/InfiniteLoop.java	Mon May 27 19:24:42 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -51,7 +51,8 @@
 public class InfiniteLoop {
 
     public static void main(String[] args) throws Exception {
-        HttpServer server = HttpServer.create(new InetSocketAddress(0), 0);
+        InetAddress loopback = InetAddress.getLoopbackAddress();
+        HttpServer server = HttpServer.create(new InetSocketAddress(loopback, 0), 0);
         server.createContext("/test/InfiniteLoop", new RespHandler());
         server.start();
         try {
--- a/test/jdk/sun/net/www/protocol/http/HttpOnly.java	Mon May 27 14:57:26 2019 +0200
+++ b/test/jdk/sun/net/www/protocol/http/HttpOnly.java	Mon May 27 19:24:42 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -24,8 +24,11 @@
  * @test
  * @bug 7095980 8007315
  * @modules jdk.httpserver
+ * @library /test/lib
  * @summary Ensure HttpURLConnection (and supporting APIs) don't expose
  *          HttpOnly cookies
+ * @run main HttpOnly
+ * @run main/othervm -Djava.net.preferIPv6Addresses=true HttpOnly
  */
 
 import java.io.IOException;
@@ -34,6 +37,7 @@
 import java.net.CookiePolicy;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
+import java.net.Proxy;
 import java.net.URI;
 import java.net.HttpURLConnection;
 import java.util.ArrayList;
@@ -46,6 +50,8 @@
 import com.sun.net.httpserver.HttpHandler;
 import com.sun.net.httpserver.HttpServer;
 
+import jdk.test.lib.net.URIBuilder;
+
 /*
  * 1) start the HTTP server
  * 2) populate cookie store with HttpOnly cookies
@@ -67,8 +73,12 @@
         CookieHandler previousHandler = CookieHandler.getDefault();
         try {
             InetSocketAddress address = server.getAddress();
-            URI uri = new URI("http://" + InetAddress.getLocalHost().getHostAddress()
-                              + ":" + address.getPort() + URI_PATH);
+            URI uri = URIBuilder.newBuilder()
+                                .scheme("http")
+                                .host(address.getAddress())
+                                .port(address.getPort())
+                                .path(URI_PATH)
+                                .build();
             populateCookieStore(uri);
             doClient(uri);
         } finally {
@@ -92,7 +102,7 @@
     }
 
     void doClient(URI uri) throws Exception {
-        HttpURLConnection uc = (HttpURLConnection) uri.toURL().openConnection();
+        HttpURLConnection uc = (HttpURLConnection) uri.toURL().openConnection(Proxy.NO_PROXY);
         int resp = uc.getResponseCode();
         check(resp == 200,
               "Unexpected response code. Expected 200, got " + resp);
@@ -157,7 +167,7 @@
         }
 
         // Now add some user set cookies into the mix.
-        uc = (HttpURLConnection) uri.toURL().openConnection();
+        uc = (HttpURLConnection) uri.toURL().openConnection(Proxy.NO_PROXY);
         uc.addRequestProperty("Cookie", "CUSTOMER_ID=CHEGAR;");
         resp = uc.getResponseCode();
         check(resp == 200,
@@ -214,7 +224,8 @@
 
     // HTTP Server
     HttpServer startHttpServer() throws IOException {
-        HttpServer httpServer = HttpServer.create(new InetSocketAddress(0), 0);
+        InetAddress localhost = InetAddress.getLocalHost();
+        HttpServer httpServer = HttpServer.create(new InetSocketAddress(localhost, 0), 0);
         httpServer.createContext(URI_PATH, new SimpleHandler());
         httpServer.start();
         return httpServer;
@@ -272,4 +283,3 @@
         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
         if (failed > 0) throw new AssertionError("Some tests failed");}
 }
-
--- a/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/HttpsCreateSockTest.java	Mon May 27 14:57:26 2019 +0200
+++ b/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/HttpsCreateSockTest.java	Mon May 27 19:24:42 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -27,7 +27,9 @@
  * @summary createSocket() - smpatch fails using 1.6.0_10 because of
  *     "Unconnected sockets not implemented"
  * @modules jdk.httpserver
+ * @library /test/lib
  * @run main/othervm HttpsCreateSockTest
+ * @run main/othervm -Djava.net.preferIPv6Addresses=true HttpsCreateSockTest
  *
  *     SunJSSE does not support dynamic system properties, no way to re-use
  *     system properties in samevm/agentvm mode.
@@ -42,6 +44,7 @@
 import java.security.NoSuchAlgorithmException;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
+import java.net.Proxy;
 import java.net.Socket;
 import java.net.URL;
 import java.io.BufferedWriter;
@@ -51,6 +54,8 @@
 import com.sun.net.httpserver.HttpHandler;
 import com.sun.net.httpserver.HttpsConfigurator;
 
+import jdk.test.lib.net.URIBuilder;
+
 /*
  * This class tests that the HTTPS protocol handler is using its socket factory for
  * creating new Sockets. It does this by wrapping the default SSLSocketFactory with
@@ -104,10 +109,15 @@
     void doClient() throws IOException {
         InetSocketAddress address = httpsServer.getAddress();
 
-        URL url = new URL("https://localhost:" + address.getPort() + "/");
+        URL url = URIBuilder.newBuilder()
+                  .scheme("https")
+                  .host(address.getAddress())
+                  .port(address.getPort())
+                  .path("/")
+                  .toURLUnchecked();
         System.out.println("trying to connect to " + url + "...");
 
-        HttpsURLConnection uc = (HttpsURLConnection) url.openConnection();
+        HttpsURLConnection uc = (HttpsURLConnection) url.openConnection(Proxy.NO_PROXY);
         uc.setHostnameVerifier(new AllHostnameVerifier());
         if (uc instanceof javax.net.ssl.HttpsURLConnection) {
             ((javax.net.ssl.HttpsURLConnection) uc).setSSLSocketFactory(new SimpleSSLSocketFactory());
@@ -123,7 +133,9 @@
      * Https Server
      */
     public void startHttpsServer() throws IOException, NoSuchAlgorithmException  {
-        httpsServer = com.sun.net.httpserver.HttpsServer.create(new InetSocketAddress(0), 0);
+        InetAddress loopback = InetAddress.getLoopbackAddress();
+        InetSocketAddress address = new InetSocketAddress(loopback, 0);
+        httpsServer = com.sun.net.httpserver.HttpsServer.create(address, 0);
         httpsServer.createContext("/", new MyHandler());
         httpsServer.setHttpsConfigurator(new HttpsConfigurator(SSLContext.getDefault()));
         httpsServer.start();
--- a/test/lib/jdk/test/lib/NetworkConfiguration.java	Mon May 27 14:57:26 2019 +0200
+++ b/test/lib/jdk/test/lib/NetworkConfiguration.java	Mon May 27 19:24:42 2019 +0100
@@ -37,6 +37,8 @@
 import java.util.Map;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 import static java.net.NetworkInterface.getNetworkInterfaces;
 import static java.util.Collections.list;
@@ -380,14 +382,17 @@
 
     /** Prints all the system interface information to the give stream. */
     public static void printSystemConfiguration(PrintStream out) {
+        PrivilegedAction<Void> pa = () -> {
         try {
             out.println("*** all system network interface configuration ***");
             for (NetworkInterface nif : list(getNetworkInterfaces())) {
                 out.print(interfaceInformation(nif));
             }
             out.println("*** end ***");
+            return null;
         } catch (IOException e) {
             throw new UncheckedIOException(e);
-        }
+        }};
+        AccessController.doPrivileged(pa);
     }
 }