From 5461726dcc1996ffe02f779a71f348e47348531b Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Mon, 27 May 2019 19:24:42 +0100 Subject: [PATCH] 8224761: Replace wildcard address with loopback or local host in tests - part 12 Fixes a batch of intermittent failures. Reviewed-by: chegar, vtewari --- test/jdk/com/sun/net/httpserver/Test6a.java | 21 ++++++++++++---- .../UnreferencedMulticastSockets.java | 9 ++++--- .../jdk/java/net/ProxySelector/ProxyTest.java | 25 ++++++++----------- test/jdk/java/net/ResponseCache/Test.java | 23 ++++++++++++----- .../net/URLConnection/ZeroContentLength.java | 21 +++++++++++----- .../sun/net/www/http/HttpClient/B6726695.java | 25 +++++++++++++------ .../http/KeepAliveStream/InfiniteLoop.java | 5 ++-- .../sun/net/www/protocol/http/HttpOnly.java | 24 ++++++++++++------ .../HttpsCreateSockTest.java | 20 ++++++++++++--- .../jdk/test/lib/NetworkConfiguration.java | 7 +++++- 10 files changed, 124 insertions(+), 56 deletions(-) diff --git a/test/jdk/com/sun/net/httpserver/Test6a.java b/test/jdk/com/sun/net/httpserver/Test6a.java index 18b5dfe395..73daf0a5f1 100644 --- a/test/jdk/com/sun/net/httpserver/Test6a.java +++ b/test/jdk/com/sun/net/httpserver/Test6a.java @@ -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 java.net.*; 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 class Test6a extends Test { 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 @@ public class Test6a extends Test { 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 diff --git a/test/jdk/java/net/MulticastSocket/UnreferencedMulticastSockets.java b/test/jdk/java/net/MulticastSocket/UnreferencedMulticastSockets.java index babbae750d..f4240d33c9 100644 --- a/test/jdk/java/net/MulticastSocket/UnreferencedMulticastSockets.java +++ b/test/jdk/java/net/MulticastSocket/UnreferencedMulticastSockets.java @@ -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.DatagramPacket; 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 @@ public class UnreferencedMulticastSockets { 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 @@ public class UnreferencedMulticastSockets { } InetAddress getHost() throws UnknownHostException { - InetAddress localhost = InetAddress.getByName("localhost"); //.getLocalHost(); + InetAddress localhost = InetAddress.getLoopbackAddress(); return localhost; } diff --git a/test/jdk/java/net/ProxySelector/ProxyTest.java b/test/jdk/java/net/ProxySelector/ProxyTest.java index d2cb56617d..8debe93146 100644 --- a/test/jdk/java/net/ProxySelector/ProxyTest.java +++ b/test/jdk/java/net/ProxySelector/ProxyTest.java @@ -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 class ProxyTest implements HttpCallback { 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 @@ public class ProxyTest implements HttpCallback { static public class MyProxySelector extends ProxySelector { private static volatile URI lastURI; - private final ArrayList noProxy; - - public MyProxySelector() { - noProxy = new ArrayList(1); - noProxy.add(Proxy.NO_PROXY); - } + private final static List NO_PROXY = List.of(Proxy.NO_PROXY); public java.util.List 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 @@ public class ProxyTest implements HttpCallback { 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 + "/")) { diff --git a/test/jdk/java/net/ResponseCache/Test.java b/test/jdk/java/net/ResponseCache/Test.java index e3f7afbbce..660f72e0fe 100644 --- a/test/jdk/java/net/ResponseCache/Test.java +++ b/test/jdk/java/net/ResponseCache/Test.java @@ -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.net.*; import java.io.*; import java.util.*; +import jdk.test.lib.net.URIBuilder; + public class Test { @@ -51,14 +56,15 @@ public class Test } 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> rqstHeaders) + ResponseCache.setDefault(new ResponseCache() { + public CacheResponse get(URI uri, String rqstMethod, Map> rqstHeaders) throws IOException { return null; } @@ -68,8 +74,13 @@ public class Test } }); - 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(); diff --git a/test/jdk/java/net/URLConnection/ZeroContentLength.java b/test/jdk/java/net/URLConnection/ZeroContentLength.java index b778c487ab..b0ae4a6608 100644 --- a/test/jdk/java/net/URLConnection/ZeroContentLength.java +++ b/test/jdk/java/net/URLConnection/ZeroContentLength.java @@ -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 @@ public class ZeroContentLength { */ 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 @@ public class ZeroContentLength { 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; diff --git a/test/jdk/sun/net/www/http/HttpClient/B6726695.java b/test/jdk/sun/net/www/http/HttpClient/B6726695.java index 5726868ce2..b23690880c 100644 --- a/test/jdk/sun/net/www/http/HttpClient/B6726695.java +++ b/test/jdk/sun/net/www/http/HttpClient/B6726695.java @@ -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 class B6726695 extends Thread { 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 @@ public class B6726695 extends Thread { * 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 @@ public class B6726695 extends Thread { } // 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 @@ public class B6726695 extends Thread { 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); diff --git a/test/jdk/sun/net/www/http/KeepAliveStream/InfiniteLoop.java b/test/jdk/sun/net/www/http/KeepAliveStream/InfiniteLoop.java index 106d4ffffa..fee02fb370 100644 --- a/test/jdk/sun/net/www/http/KeepAliveStream/InfiniteLoop.java +++ b/test/jdk/sun/net/www/http/KeepAliveStream/InfiniteLoop.java @@ -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 @@ import jdk.test.lib.net.URIBuilder; 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 { diff --git a/test/jdk/sun/net/www/protocol/http/HttpOnly.java b/test/jdk/sun/net/www/protocol/http/HttpOnly.java index d377ebf7c1..523e68ee1a 100644 --- a/test/jdk/sun/net/www/protocol/http/HttpOnly.java +++ b/test/jdk/sun/net/www/protocol/http/HttpOnly.java @@ -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.CookieManager; 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.HttpExchange; 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 @@ public class HttpOnly { 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 @@ public class HttpOnly { } 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 @@ public class HttpOnly { } // 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 @@ public class HttpOnly { // 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 @@ public class HttpOnly { System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} } - diff --git a/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/HttpsCreateSockTest.java b/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/HttpsCreateSockTest.java index 68b20803ae..e9e4206307 100644 --- a/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/HttpsCreateSockTest.java +++ b/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/HttpsCreateSockTest.java @@ -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 javax.net.ssl.SSLSocketFactory; 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.HttpExchange; 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 @@ public class HttpsCreateSockTest 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 @@ public class HttpsCreateSockTest * 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(); diff --git a/test/lib/jdk/test/lib/NetworkConfiguration.java b/test/lib/jdk/test/lib/NetworkConfiguration.java index b659962788..94d55853f7 100644 --- a/test/lib/jdk/test/lib/NetworkConfiguration.java +++ b/test/lib/jdk/test/lib/NetworkConfiguration.java @@ -37,6 +37,8 @@ import java.util.List; 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 @@ public class NetworkConfiguration { /** Prints all the system interface information to the give stream. */ public static void printSystemConfiguration(PrintStream out) { + PrivilegedAction 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); } }