8316337: (bf) Concurrency issue in DirectByteBuffer.Deallocator

Reviewed-by: alanb, liach
This commit is contained in:
Per Minborg 2023-09-19 13:10:51 +00:00
parent 4461eeb31d
commit cf74b8c2a3
3 changed files with 31 additions and 45 deletions

View file

@ -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);
}
};
}
/**