Source: commons-io Version: 2.8.0 Severity: normal Tags: patch Hi,
Since version 2.8.0, commons-io fails at deleting a symlink when it points to nothing. Such situation was met in some tests of libsis-base-java (temporarily deactivated in order to face this issue), leading to bug #976490. This issue is well-documented on the Apache issue tracker [0] and I'm proposing the enclosed patch by Bernd Rinn to get around it in version 2.8.0. Bye, Pierre [0] https://issues.apache.org/jira/browse/IO-692 -- System Information: Debian Release: bullseye/sid APT prefers testing APT policy: (500, 'testing'), (90, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 5.9.0-4-amd64 (SMP w/4 CPU threads) Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8), LANGUAGE not set Shell: /bin/sh linked to /usr/bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled
--- org/apache/commons/io/file/PathUtils.java.orig 2020-01-22 15:10:16.000000000 +0100 +++ org/apache/commons/io/file/PathUtils.java 2020-10-28 21:32:24.874024999 +0100 @@ -358,7 +358,8 @@ } final PathCounters pathCounts = Counters.longPathCounters(); final boolean exists = Files.exists(file, LinkOption.NOFOLLOW_LINKS); - final long size = exists ? Files.size(file) : 0; + final boolean existsFollowLink = Files.exists(file); + final long size = existsFollowLink ? Files.size(file) : 0; if (overrideReadOnly(options) && exists) { setReadOnly(file, false, LinkOption.NOFOLLOW_LINKS); }