8325302: Files.move(REPLACE_EXISTING) throws NoSuchFileException on deleted target
Reviewed-by: alanb
This commit is contained in:
parent
3a1f4d0f48
commit
299a8ee68d
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2024, Oracle and/or its affiliates. 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
|
||||
@ -930,12 +930,14 @@ abstract class UnixFileSystem
|
||||
} catch (UnixException x) {
|
||||
// target is non-empty directory that can't be replaced.
|
||||
if (targetAttrs.isDirectory() &&
|
||||
(x.errno() == EEXIST || x.errno() == ENOTEMPTY))
|
||||
{
|
||||
(x.errno() == EEXIST || x.errno() == ENOTEMPTY)) {
|
||||
throw new DirectoryNotEmptyException(
|
||||
target.getPathForExceptionMessage());
|
||||
}
|
||||
x.rethrowAsIOException(target);
|
||||
// ignore file not found otherwise rethrow
|
||||
if (x.errno() != ENOENT) {
|
||||
x.rethrowAsIOException(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1061,12 +1063,14 @@ abstract class UnixFileSystem
|
||||
} catch (UnixException x) {
|
||||
// target is non-empty directory that can't be replaced.
|
||||
if (targetAttrs.isDirectory() &&
|
||||
(x.errno() == EEXIST || x.errno() == ENOTEMPTY))
|
||||
{
|
||||
(x.errno() == EEXIST || x.errno() == ENOTEMPTY)) {
|
||||
throw new DirectoryNotEmptyException(
|
||||
target.getPathForExceptionMessage());
|
||||
}
|
||||
x.rethrowAsIOException(target);
|
||||
// ignore file not found otherwise rethrow
|
||||
if (x.errno() != ENOENT) {
|
||||
x.rethrowAsIOException(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2024, Oracle and/or its affiliates. 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
|
||||
@ -177,7 +177,11 @@ class WindowsFileCopy {
|
||||
target.getPathForExceptionMessage());
|
||||
}
|
||||
}
|
||||
x.rethrowAsIOException(target);
|
||||
// ignore file not found otherwise rethrow
|
||||
if (x.lastError() != ERROR_FILE_NOT_FOUND &&
|
||||
x.lastError() != ERROR_PATH_NOT_FOUND) {
|
||||
x.rethrowAsIOException(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -400,7 +404,11 @@ class WindowsFileCopy {
|
||||
target.getPathForExceptionMessage());
|
||||
}
|
||||
}
|
||||
x.rethrowAsIOException(target);
|
||||
// ignore file not found otherwise rethrow
|
||||
if (x.lastError() != ERROR_FILE_NOT_FOUND &&
|
||||
x.lastError() != ERROR_PATH_NOT_FOUND) {
|
||||
x.rethrowAsIOException(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user