8227440: Implement fix to JDK-8224642 on all platforms

Reviewed-by: sspitsyn, clanger
This commit is contained in:
Ralf Schmelter 2019-07-16 13:57:13 +02:00
parent 53635b436c
commit b0adbe8fcf
5 changed files with 27 additions and 15 deletions

View File

@ -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 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
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);
}
}
}

View File

@ -260,12 +260,11 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
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);
}
}
}

View File

@ -256,8 +256,12 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
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);
}
}
}

View File

@ -204,8 +204,12 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
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);
}
}
}

View File

@ -169,10 +169,11 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine {
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);
}
}
}