--- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/SocketTransportService.java Tue Aug 01 08:56:42 2017 -0700
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/SocketTransportService.java Thu Aug 03 13:46:04 2017 +0000
@@ -275,6 +275,12 @@
sa = new InetSocketAddress(localaddress, port);
}
ServerSocket ss = new ServerSocket();
+ if (port == 0) {
+ // Only need SO_REUSEADDR if we're using a fixed port. If we
+ // start seeing EADDRINUSE due to collisions in free ports
+ // then we should retry the bind() a few times.
+ ss.setReuseAddress(false);
+ }
ss.bind(sa);
return new SocketListenKey(ss);
}