--- a/src/jdk.attach/solaris/classes/sun/tools/attach/VirtualMachineImpl.java Thu Oct 17 20:27:44 2019 +0100
+++ b/src/jdk.attach/solaris/classes/sun/tools/attach/VirtualMachineImpl.java Thu Oct 17 20:53:35 2019 +0100
@@ -60,8 +60,11 @@
int pid;
try {
pid = Integer.parseInt(vmid);
+ if (pid < 1) {
+ throw new NumberFormatException();
+ }
} catch (NumberFormatException x) {
- throw new AttachNotSupportedException("Invalid process identifier");
+ throw new AttachNotSupportedException("Invalid process identifier: " + vmid);
}
// Opens the door file to the target VM. If the file is not
@@ -204,8 +207,12 @@
return VirtualMachineImpl.read(s, bs, off, len);
}
- public void close() throws IOException {
- VirtualMachineImpl.close(s);
+ public synchronized void close() throws IOException {
+ if (s != -1) {
+ int toClose = s;
+ s = -1;
+ VirtualMachineImpl.close(toClose);
+ }
}
}