ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject DO NOT REPLY [Bug 51110] New: Ambiguous behaviour of URLResource isExists(boolean)
Date Sat, 23 Apr 2011 02:07:32 GMT

           Summary: Ambiguous behaviour of URLResource isExists(boolean)
           Product: Ant
           Version: 1.8.2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core

= Overview =
When using a <url> as the nested resource the <resourceexists> condition, my
expectation is that the condition should evaluate to true if the remote file
referred to by the URL does not exist. However, the sample test case below
demonstrates otherwise. Looking at the URLResource code, it seems like
URLConnection.connect() is used for the evaluation. I've done some test and
notice that this method returns true as long as the connection to the server
can be made.

I am not sure whether this is by design, but I find that in order to truly
determine if the remote file exists, the URLConnection.getContent() method must
be called. It is when the method returns FileNotFoundException as expected (at
least for files . I assume that a call to conn.getContent() can be added to
isExists() in URLResource, but I am not sure what to do with the
UnknownServiceException that it throws. Perhaps someone can comment more on
this to determine what the best solution is.

= Steps to Reproduce =
Run the following sample Ant build file on a system with Internet access.

<project name="build" default="all">
  <target name="all">
    <fail message="Resource does not exist.">
            <url url="" />

= Actual Result =
Ant build fails with the message "Resource does not exist."

= Expected Result =
Ant build completes "successfully".

Configure bugmail:
------- You are receiving this mail because: -------
You are the assignee for the bug.

View raw message