< prev index next >
src/java.base/share/classes/sun/net/util/SocketExceptions.java
Print this page
rev 55750 : UDS support, temporary commit
@@ -26,10 +26,11 @@
package sun.net.util;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.net.InetSocketAddress;
+import java.net.SocketAddress;
import java.security.AccessController;
import java.security.PrivilegedAction;
import sun.security.util.SecurityProperties;
@@ -49,21 +50,25 @@
* set or does not contain the category hostInfo,
* then the original exception is returned.
*
* Only specific IOException subtypes are supported.
*/
- public static IOException of(IOException e, InetSocketAddress address) {
+ public static IOException of(IOException e, SocketAddress address) {
if (!enhancedExceptionText || address == null)
return e;
- int port = address.getPort();
- String host = address.getHostString();
StringBuilder sb = new StringBuilder();
sb.append(e.getMessage());
sb.append(": ");
+ if (address instanceof InetSocketAddress) {
+ int port = ((InetSocketAddress) address).getPort();
+ String host = ((InetSocketAddress) address).getHostString();
sb.append(host);
sb.append(':');
sb.append(Integer.toString(port));
+ } else {
+ sb.append(address);
+ }
String enhancedMsg = sb.toString();
return create(e, enhancedMsg);
}
// return a new instance of the same type with the given detail
< prev index next >