8227440: Implement fix to JDK-8224642 on all platforms
Reviewed-by: sspitsyn, clanger
--- a/src/jdk.attach/aix/classes/sun/tools/attach/VirtualMachineImpl.java Mon Jul 15 03:14:28 2019 +0000
+++ b/src/jdk.attach/aix/classes/sun/tools/attach/VirtualMachineImpl.java Tue Jul 16 13:57:13 2019 +0200
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2015, 2018, SAP SE. All rights reserved.
+ * Copyright (c) 2015, 2019, SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -254,8 +254,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);
+ }
}
}
--- a/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java Mon Jul 15 03:14:28 2019 +0000
+++ b/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java Tue Jul 16 13:57:13 2019 +0200
@@ -260,12 +260,11 @@
return VirtualMachineImpl.read(s, bs, off, len);
}
- public void close() throws IOException {
- synchronized (this) {
- if (s != -1) {
- VirtualMachineImpl.close(s);
- s = -1;
- }
+ public synchronized void close() throws IOException {
+ if (s != -1) {
+ int toClose = s;
+ s = -1;
+ VirtualMachineImpl.close(toClose);
}
}
}
--- a/src/jdk.attach/macosx/classes/sun/tools/attach/VirtualMachineImpl.java Mon Jul 15 03:14:28 2019 +0000
+++ b/src/jdk.attach/macosx/classes/sun/tools/attach/VirtualMachineImpl.java Tue Jul 16 13:57:13 2019 +0200
@@ -256,8 +256,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);
+ }
}
}
--- a/src/jdk.attach/solaris/classes/sun/tools/attach/VirtualMachineImpl.java Mon Jul 15 03:14:28 2019 +0000
+++ b/src/jdk.attach/solaris/classes/sun/tools/attach/VirtualMachineImpl.java Tue Jul 16 13:57:13 2019 +0200
@@ -204,8 +204,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);
+ }
}
}
--- a/src/jdk.attach/windows/classes/sun/tools/attach/VirtualMachineImpl.java Mon Jul 15 03:14:28 2019 +0000
+++ b/src/jdk.attach/windows/classes/sun/tools/attach/VirtualMachineImpl.java Tue Jul 16 13:57:13 2019 +0200
@@ -169,10 +169,11 @@
return VirtualMachineImpl.readPipe(hPipe, bs, off, len);
}
- public void close() throws IOException {
+ public synchronized void close() throws IOException {
if (hPipe != -1) {
- VirtualMachineImpl.closePipe(hPipe);
+ long toClose = hPipe;
hPipe = -1;
+ VirtualMachineImpl.closePipe(toClose);
}
}
}