diff options
author | Egor Ushakov <egor.ushakov@jetbrains.com> | 2018-08-30 14:39:56 +0300 |
---|---|---|
committer | Egor Ushakov <egor.ushakov@jetbrains.com> | 2018-08-31 13:23:09 +0300 |
commit | e3cfa8c040914b1c42406ad44c7b066932d90c70 (patch) | |
tree | 49425c9434469f7c816ad97fc79c734b4d18d4c5 | |
parent | 027c4ce475652b1dc842c7267003060a1c485bb4 (diff) | |
download | jdk8u_jdk-e3cfa8c040914b1c42406ad44c7b066932d90c70.tar.gz |
JRE-924 Unable to attach with ProcessAttachingConnector to a java 9 processjb8u152-b1293.10
(cherry picked from commit d42536e5bd28895da83e1b7917d021fdaaffca44) (JR-CR-298)
-rw-r--r-- | src/share/classes/com/sun/tools/jdi/SocketTransportService.java | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/src/share/classes/com/sun/tools/jdi/SocketTransportService.java b/src/share/classes/com/sun/tools/jdi/SocketTransportService.java index 5585a00311..6236c6bc43 100644 --- a/src/share/classes/com/sun/tools/jdi/SocketTransportService.java +++ b/src/share/classes/com/sun/tools/jdi/SocketTransportService.java @@ -194,29 +194,15 @@ public class SocketTransportService extends TransportService { throw new IllegalArgumentException("timeout is negative"); } + InetSocketAddress sa; int splitIndex = address.indexOf(':'); - String host; - String portStr; if (splitIndex < 0) { - host = InetAddress.getLocalHost().getHostName(); - portStr = address; + sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), parsePort(address)); } else { - host = address.substring(0, splitIndex); - portStr = address.substring(splitIndex+1); - } - - int port; - try { - port = Integer.decode(portStr).intValue(); - } catch (NumberFormatException e) { - throw new IllegalArgumentException( - "unable to parse port number in address"); + sa = new InetSocketAddress(address.substring(0, splitIndex), parsePort(address.substring(splitIndex+1))); } - // open TCP connection to VM - - InetSocketAddress sa = new InetSocketAddress(host, port); Socket s = new Socket(); try { s.connect(sa, (int)attachTimeout); @@ -240,6 +226,14 @@ public class SocketTransportService extends TransportService { return new SocketConnection(s); } + private static int parsePort(String portStr) { + try { + return Integer.decode(portStr); + } catch (NumberFormatException e) { + throw new IllegalArgumentException("unable to parse port number in address"); + } + } + /* * Listen on the specified address and port. Return a listener * that encapsulates the ServerSocket. @@ -272,15 +266,7 @@ public class SocketTransportService extends TransportService { address = address.substring(splitIndex+1); } - int port; - try { - port = Integer.decode(address).intValue(); - } catch (NumberFormatException e) { - throw new IllegalArgumentException( - "unable to parse port number in address"); - } - - return startListening(localaddr, port); + return startListening(localaddr, parsePort(address)); } /** |