ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Reilly <>
Subject Re: Pb with <unzip>+<trycatch>+<delete>
Date Tue, 16 Mar 2004 16:13:58 GMT
Dominique Devienne wrote:

>I have 2 independent CruiseControl builds: one write help zip files
>to a server somewhere, while the other reads them when it detects changes
>when it wakes up. There a inherent concurrency issue / race condition in
>this scenario, which I try to address with the Ant code below.
>  <try>
>    <unzip src="helpzipfiles/" dest="built/image/help" />
>  </try>
>  <catch>
>    <!-- Bad/incomplete zip. Remove it, so its redownloaded by <get> -->
>    <delete quiet="true">
>      <fileset file="helpzipfiles/" />
>    </delete>
>    <fail>Failed to unzip helpzipfiles/</fail>
>  </catch>
>If I fail to unzip a file, I assume the file is bad, remove it, so that
>the next time CruiseControl fires the Ant build, <get> redownloads the
>zip file, hopefully complete by then.
>The problem is that the <delete> *silently* fails to delete the file, as
>the CruiseControl XML log shows! I checked the code of Expand, and it does
>have a try/finally block, closing the ZipFile instance... Maybe it should
>also attempt to close the InputStream it got from ZipFile directly too???
>ZipFile is supposed to do that, but apparently it doesn't work.
not having windows, i cannot test this. It may also be that another 
process has it's
grubby hands on the zip file.

>I'm on Win2K, JDK 1.4.2, Ant 1.6.0.
>Also, shouldn't the failure to remove a file be logged at WARNING level,
>when <delete> cannot delete a file, rather than at DEBUG level only?
According to the manual, setting quiet sets the waring level down, (and
sets failonerror to false), you should just set failonerror to false.


>And if the ZipFile.close() method really throws an exception, instead of
>simply ignoring it completely, shouldn't it be at least logged?!?!?!
>Thanks, --DD
><task location="C:\acme\build.xml:372: "
>      name="unzip" time="12 seconds">  <message priority="info"><![CDATA[
>    Expanding: C:\acme\helpzipfiles\
>          into C:\acme\built\image\help
>  ]]></message>
><task location="C:\acme\build.xml:376: " name="delete" time="0 seconds"> 
>  <message priority="info"><![CDATA[
>    Deleting 1 files from C:\acme\helpzipfiles
>  ]]></message>  <message priority="debug"><![CDATA[
>    Deleting C:\acme\helpzipfiles\
>  ]]></message>  <message priority="debug"><![CDATA[
>    Unable to delete file C:\acme\helpzipfiles\
>  ]]></message>
>To unsubscribe, e-mail:
>For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message