Re: Bug#973070: libsis-base-java: FTBFS: Could not delete the directory targets/unit-test-wd/ch.syst
Hi,
here is a suggested patch for commons-io that would prevent making the
test in libsis-base-java fail.
Kind regards
Andreas.
----- Forwarded message from Bernd Rinn <brinn@ethz.ch> -----
Date: Wed, 28 Oct 2020 21:40:29 +0100
From: Bernd Rinn <brinn@ethz.ch>
To: Andreas Tille <andreas@an3as.eu>
CC: 973070@bugs.debian.org
Subject: Re: Bug#973070: libsis-base-java: FTBFS: Could not delete the directory targets/unit-test-wd/ch.syst
Hi Andreas,
I can confirm that this bug is in commons-io 2.8.0 while commons-io 2.6 workes
fine.
The bug is in PathUtils.deleteFile(), line 360 and 361:
"""
final boolean exists = Files.exists(file, LinkOption.NOFOLLOW_LINKS);
final long size = exists ? Files.size(file) : 0;
"""
It determines "exists" based on not following the symlink by using
LinkOption.NOFOLLOW_LINKS, but then in the next line uses Files.size(file) to
determine the size which *does* follow the symlink. Kaboom. This will prevent
PathUtils.deleteFile() to delete any dangling symlink (which it has to in my
test case).
I have attached a patch for commons-io 2.8.0 which fixes this bug.
Cheers,
Bernd
On 10/28/20 8:29 PM, Andreas Tille wrote:
> Control: forwarded -1 Bernd Rinn <brinn@ethz.ch>
>
> Hi,
>
> I'd recommend reading the bug report log from here to get some hints
> about recommended changes in the code:
>
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=973070#17
>
> For the moment I've excluded the affected tests.
>
> Kind regards
>
> Andreas.
>
> ----- Forwarded message from Markus Koschany <apo@debian.org> -----
>
> Date: Wed, 28 Oct 2020 19:34:35 +0100
> From: Markus Koschany <apo@debian.org>
> To: Debian Java List <debian-java@lists.debian.org>
> Cc: 973070@bugs.debian.org
> Subject: Bug#973070: Bug#973070: Help needed: Bug#973070: libsis-base-java: FTBFS: Could not delete the directory
> targets/unit-test-wd/ch.systemsx.cisd.base.unix.UnixTests because: 1 exceptions: [java.io.IOException: Unable to delete file:
> targets/unit-test-wd/ch.systemsx.cisd.base.unix.UnixTests/someDanglingLink]
> X-Debian-PR-Message: followup 973070
> X-Debian-PR-Package: src:libsis-base-java
> X-Debian-PR-Keywords: bullseye ftbfs help sid
> X-Debian-PR-Source: libsis-base-java
>
>
>
> Am 28.10.20 um 16:01 schrieb olivier sallou:
> [...]
> > *dumb* patch would be to simply remove those tests from code...
>
> Either this or you can keep the override for dh_auto_test-arch empty.
>
> The test creates a broken symlink but then FileUtils.deleteDirectory
> fails to delete the file, obviously because it is not a directory but
> I'm not sure how it really handles symlinks within directories. See also
> [1]. Probably upstream should switch to the java.nio.file API (they
> still use java.io.File), test for the existence of symlinks and then try
> File.delete instead of FileUtils.deleteDirectory first. Not tested, just
> a guess.
>
> Markus
>
>
> [1] https://issues.apache.org/jira/browse/IO-576
>
>
>
>
>
> _______________________________________________
> Debian-med-packaging mailing list
> Debian-med-packaging@alioth-lists.debian.net
> https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/debian-med-packaging
>
>
> ----- End forwarded message -----
--- 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);
}
----- End forwarded message -----
--
http://fam-tille.de
Reply to: