ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 10404] New: - The way in which property values are used can at times be very unintuitive
Date Tue, 02 Jul 2002 12:37:43 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10404>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10404

The way in which property values are used can at times be very unintuitive

           Summary: The way in which property values are used can at times
                    be very unintuitive
           Product: Ant
           Version: unspecified
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Core tasks
        AssignedTo: ant-dev@jakarta.apache.org
        ReportedBy: wtff@freenet.de


I would like to do a very simple thing:
Test network conditions (socket, http) and generate a report that tells me if 
every network resource is up or not.

I found that doing this can be very complicated because of some interrelating 
issues.
- property values can be true, false or NOT SET, also a property can be set 
only once and is then like a constant.
- the waitfor/condition tasks set a property to true or leave it unset.

Now, if I wanted to test whether a socket is active and report this, I would 
like to do it like this:

<target name="socketcheck" depends="">
    <condition property="socket.server1.3302">
        <socket server="1.1.1.1" port="3302"/>
    </condition>
</target>
<target name="all" depends="socketcheck">
    <echo>
        Port 3302 on Server 1 available : ${socket.server1.3302}
    </echo>
</target>

However, the first issue is that within the <condition> task, it is
not possible to specify, how much time is allotted to the sub expressions to be 
evaluated. Instead, for this I have to take the <waitFor> task.
First of all, there shouldn't be a waitfor tasks at all because instead, one 
should rather include the timout capabilities into the condition task.
Second, the logik of the waitfor task is an inverted one: a property can be set 
(to true in the default case), if a timeout is reached. The notion of the 
condition task is better: if the condition is true, the property will be set to 
true. If a timout occurs, then the logical notion to maintain, would be to set 
the property value to false.
The second problem is, that properties set from any of these two tasks are 
either set to a value or they are not being set at all!! This is awkward in the 
case of reporting, because the echo statement in the above example will either 
output "Port 3302 on Server 1 available : true" or, "Port 3302 on Server 1 
available : ${socket.server1.3302}"

Therefore, in order to achieve just a simple socket test, not waiting for hours 
for its timeout in case if it should fail, AND at the same time achieving a 
pretty output, I would have to write s.th. like this:

<target name="socketcheck" depends="">

<echo>w1</echo>

<waitfor timeoutproperty="socket.unavail.3302" maxwait="5000000">
<not><socket server="1.1.1.1" port="3302"/></not>
</waitfor>

<echo>w2</echo>

</target>

<target name="all" depends="socketcheck">
<echo>

</echo>
</target>

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message