This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-io.git
commit 644870b748e432d107c759e35c847ffc905fbeb3 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Thu Nov 14 10:56:20 2024 -0500 FileUtils.forceDelete(File) does not chain the exception cause --- src/main/java/org/apache/commons/io/FileUtils.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/commons/io/FileUtils.java b/src/main/java/org/apache/commons/io/FileUtils.java index 63345f113..f65b4f6f6 100644 --- a/src/main/java/org/apache/commons/io/FileUtils.java +++ b/src/main/java/org/apache/commons/io/FileUtils.java @@ -1420,11 +1420,13 @@ public class FileUtils { final Counters.PathCounters deleteCounters; try { deleteCounters = PathUtils.delete(file.toPath(), PathUtils.EMPTY_LINK_OPTION_ARRAY, StandardDeleteOption.OVERRIDE_READ_ONLY); - } catch (final NoSuchFileException ex) { + } catch (final NoSuchFileException e) { // Map NIO to IO exception - throw new FileNotFoundException("Cannot delete file: " + file); - } catch (final IOException ex) { - throw new IOException("Cannot delete file: " + file, ex); + final FileNotFoundException nioEx = new FileNotFoundException("Cannot delete file: " + file); + nioEx.initCause(e); + throw nioEx; + } catch (final IOException e) { + throw new IOException("Cannot delete file: " + file, e); } if (deleteCounters.getFileCounter().get() < 1 && deleteCounters.getDirectoryCounter().get() < 1) { // didn't find a file to delete.