8292279: (fs) Use try-with-resources to release NativeBuffer

Reviewed-by: alanb
This commit is contained in:
Andrey Turbanov 2022-08-17 07:18:29 +00:00
parent a25e1dc53c
commit 1d9c2f7a6e
13 changed files with 61 additions and 168 deletions

View file

@ -55,11 +55,8 @@ class BsdNativeDispatcher extends UnixNativeDispatcher {
* returns buf->f_mntonname (directory on which mounted)
*/
static byte[] getmntonname(UnixPath path) throws UnixException {
NativeBuffer pathBuffer = copyToNativeBuffer(path);
try {
try (NativeBuffer pathBuffer = copyToNativeBuffer(path)) {
return getmntonname0(pathBuffer.address());
} finally {
pathBuffer.release();
}
}
static native byte[] getmntonname0(long pathAddress) throws UnixException;