8224642: Test sun/tools/jcmd/TestJcmdSanity.java fails: Bad file descriptor

Reviewed-by: cjplummer, rschmelter, clanger
This commit is contained in:
Gary Adams 2019-06-20 07:13:06 -04:00
parent 8d4f4b0491
commit 3c29fa1203

View File

@ -233,7 +233,7 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
* InputStream for the socket connection to get target VM
*/
private class SocketInputStream extends InputStream {
int s;
int s = -1;
public SocketInputStream(int s) {
this.s = s;
@ -261,7 +261,12 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
}
public void close() throws IOException {
VirtualMachineImpl.close(s);
synchronized (this) {
if (s != -1) {
VirtualMachineImpl.close(s);
s = -1;
}
}
}
}