--- old/src/java.base/share/classes/sun/net/util/SocketExceptions.java 2018-07-20 12:32:54.000000000 +0100 +++ new/src/java.base/share/classes/sun/net/util/SocketExceptions.java 2018-07-20 12:32:53.000000000 +0100 @@ -44,7 +44,7 @@ * The property value is a comma separated list of * case insignificant category names. */ - private static final String enhancedTextPropname = "jdk.net.includeInExceptions"; + private static final String enhancedTextPropname = "jdk.includeInExceptions"; private static final boolean enhancedExceptionText = initTextProp(); @@ -59,7 +59,7 @@ } String[] tokens = val.split(","); for (String token : tokens) { - if (token.equalsIgnoreCase("hostinfo")) + if (token.trim().equalsIgnoreCase("hostinfo")) return true; } return false; --- old/src/java.base/share/conf/security/java.security 2018-07-20 12:32:57.000000000 +0100 +++ new/src/java.base/share/conf/security/java.security 2018-07-20 12:32:57.000000000 +0100 @@ -1060,15 +1060,25 @@ jceks.key.serialFilter = java.base/java.lang.Enum;java.base/java.security.KeyRep;\ java.base/java.security.KeyRep$Type;java.base/javax.crypto.spec.SecretKeySpec;!* + +# +# Enhanced exception message information +# +# By default, several exception messages do not include potentially sensitive +# information such as file names, host names, or port numbers. This property may +# be used to enable categories of enhanced information in exception messages. +# The property accepts one or more comma separated values, each of which +# represents a category of enhanced exception message information to enable. +# Values are case-insensitive. Leading and trailing whitespaces, surrounding +# each value, are ignored. Unknown values are ignored. +# +# The categories, to enable enhanced exception message information, are: +# +# hostInfo - IOExceptions thrown by java.net.Socket and also the socket types +# in the java.nio.channels package will contain enhanced exception +# message information # -# Enhanced exception message text +# The property setting in this file can be overridden by a system property of +# the same name, with the same syntax and possible values. # -# By default, socket exception messages do not include potentially sensitive -# information such as hostnames or port numbers. This property may be set to one -# or more values, separated by commas, and with no white-space. Each value -# represents a category of enhanced information. Currently, the only category defined -# is "hostInfo" which enables more detailed information in the IOExceptions -# thrown by java.net.Socket and also the socket types in the java.nio.channels package. -# The setting in this file can be overridden by a system property of the same name -# and with the same syntax and possible values. -#jdk.net.includeInExceptions=hostInfo +#jdk.includeInExceptions=hostInfo --- old/test/jdk/java/net/Socket/ExceptionText.java 2018-07-20 12:33:01.000000000 +0100 +++ new/test/jdk/java/net/Socket/ExceptionText.java 2018-07-20 12:33:00.000000000 +0100 @@ -25,18 +25,43 @@ * @test * @library /test/lib * @build jdk.test.lib.Utils - * @bug 8204233 + * @bug 8204233 8207846 * @summary Add configurable option for enhanced socket IOException messages - * @run main/othervm ExceptionText - * @run main/othervm -Djdk.net.includeInExceptions= ExceptionText - * @run main/othervm -Djdk.net.includeInExceptions=hostInfo ExceptionText - * @run main/othervm -Djdk.net.includeInExceptions=somethingElse ExceptionText + * @run main/othervm + * ExceptionText + * WITHOUT_Enhanced_Text + * @run main/othervm + * -Djdk.includeInExceptions= + * ExceptionText + * WITHOUT_Enhanced_Text + * @run main/othervm + * -Djdk.includeInExceptions=somethingElse + * ExceptionText + * WITHOUT_Enhanced_Text + * @run main/othervm + * -Djdk.includeInExceptions=blah,blah,blah, + * ExceptionText + * WITHOUT_Enhanced_Text + * @run main/othervm + * -Djdk.includeInExceptions=hostInfo + * ExceptionText + * expectEnhancedText + * @run main/othervm + * -Djdk.includeInExceptions=foo,hostinfo,bar + * ExceptionText + * expectEnhancedText + * @run main/othervm + * -Djdk.includeInExceptions=",HOSTINFO," + * ExceptionText + * expectEnhancedText */ -import java.net.*; import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.nio.channels.AsynchronousSocketChannel; import java.nio.channels.ClosedChannelException; -import java.nio.channels.*; +import java.nio.channels.SocketChannel; import java.util.concurrent.ExecutionException; import jdk.test.lib.Utils; @@ -44,16 +69,15 @@ enum TestTarget {SOCKET, CHANNEL, ASYNC_CHANNEL}; - static boolean propEnabled() { - String val = System.getProperty("jdk.net.includeInExceptions"); - if ("hostinfo".equalsIgnoreCase(val)) - return true; - return false; - } - public static void main(String args[]) throws Exception { - boolean prop = propEnabled(); - test(prop); + String passOrFail = args[0]; + boolean expectEnhancedText; + if (passOrFail.equals("expectEnhancedText")) { + expectEnhancedText = true; + } else { + expectEnhancedText = false; + } + test(expectEnhancedText); } static final InetSocketAddress dest = Utils.refusingEndpoint();