From 2a4a11f370a76cccd4d6ce31cf122d1f4a7f5a3b Mon Sep 17 00:00:00 2001 From: iseki Date: Thu, 10 Aug 2023 11:26:49 +0800 Subject: [PATCH] Fix WindowsException allow ERROR_PRIVILEGE_NOT_HELD(1314) be converted to AccessDeniedException --- src/java.base/windows/classes/sun/nio/fs/WindowsException.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/java.base/windows/classes/sun/nio/fs/WindowsException.java b/src/java.base/windows/classes/sun/nio/fs/WindowsException.java index 1312d5a0938a5..b7388d593e390 100644 --- a/src/java.base/windows/classes/sun/nio/fs/WindowsException.java +++ b/src/java.base/windows/classes/sun/nio/fs/WindowsException.java @@ -85,7 +85,7 @@ private IOException translateToIOException(String file, String other) { return new NoSuchFileException(file, other, null); if (lastError() == ERROR_FILE_EXISTS || lastError() == ERROR_ALREADY_EXISTS) return new FileAlreadyExistsException(file, other, null); - if (lastError() == ERROR_ACCESS_DENIED) + if (lastError() == ERROR_ACCESS_DENIED || lastError() == ERROR_PRIVILEGE_NOT_HELD) return new AccessDeniedException(file, other, null); // fallback to the more general exception