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.

<trycatch>
  <try>
    <unzip src="helpzipfiles/foo.zip" dest="built/image/help" />
  </try>
  <catch>
    <!-- Bad/incomplete zip. Remove it, so its redownloaded by <get> -->
    <delete quiet="true">
      <fileset file="helpzipfiles/foo.zip" />
    </delete>
    <fail>Failed to unzip helpzipfiles/foo.zip</fail>
  </catch>
</trycatch>

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.

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?

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\foo.zip
          into C:\acme\built\image\help
  ]]></message>
</task>
<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\foo.zip
  ]]></message>  <message priority="debug"><![CDATA[
    Unable to delete file C:\acme\helpzipfiles\foo.zip
  ]]></message>
</task>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to