mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8316337: (bf) Concurrency issue in DirectByteBuffer.Deallocator
Reviewed-by: alanb, liach
This commit is contained in:
parent
4461eeb31d
commit
cf74b8c2a3
3 changed files with 31 additions and 45 deletions
|
@ -116,28 +116,33 @@ public abstract sealed class MappedByteBuffer
|
|||
}
|
||||
|
||||
UnmapperProxy unmapper() {
|
||||
return fd != null ?
|
||||
new UnmapperProxy() {
|
||||
@Override
|
||||
public long address() {
|
||||
return address;
|
||||
}
|
||||
return fd == null
|
||||
? null
|
||||
: new UnmapperProxy() {
|
||||
|
||||
@Override
|
||||
public FileDescriptor fileDescriptor() {
|
||||
return fd;
|
||||
}
|
||||
// Ensure safe publication as MappedByteBuffer.this.address is not final
|
||||
private final long addr = address;
|
||||
|
||||
@Override
|
||||
public boolean isSync() {
|
||||
return isSync;
|
||||
}
|
||||
@Override
|
||||
public long address() {
|
||||
return addr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unmap() {
|
||||
Unsafe.getUnsafe().invokeCleaner(MappedByteBuffer.this);
|
||||
}
|
||||
} : null;
|
||||
@Override
|
||||
public FileDescriptor fileDescriptor() {
|
||||
return fd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSync() {
|
||||
return isSync;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unmap() {
|
||||
Unsafe.getUnsafe().invokeCleaner(MappedByteBuffer.this);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue