You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Diane Holt <ho...@yahoo.com> on 2002/05/29 20:33:10 UTC

Possible bug fix for LoadFile.java

Because of this line, which sets the "text" var:

               String text = "";

I've made the following change to LoadFile.java:

  @@ -194,7 +194,7 @@
                   text = crh.readFully(instream);
               }

  -            if (text != null) {
  +            if (text.length() > 0) {
                   project.setNewProperty(property, text);
                   log("loaded " + text.length() + " characters",
                       Project.MSG_VERBOSE);

since a) I don't see "text" ever being null, and b) the way it is now,
it'll set the property to the empty string, which makes it useless for
using the property in 'if' on a target (since the property is set).

Or am I missing something?

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Possible bug fix for LoadFile.java

Posted by Magesh Umasankar <um...@apache.org>.
I see what you mean, now.  Yes, it would be
good, I think, to check for its length and
set it only if it is > 0.

Cheers,
Magesh

*********************************************
*  Early to bed, early to rise sounds great *
*  until the alarm goes off.                *
*********************************************
----- Original Message -----
From: "Diane Holt" <ho...@yahoo.com>
To: "Ant Developers List" <an...@jakarta.apache.org>
Sent: Wednesday, May 29, 2002 2:49 PM
Subject: Re: Possible bug fix for LoadFile.java


> --- Magesh Umasankar <um...@apache.org> wrote:
> > Is there any rule that currently states that
> > a property cannot exist with an empty value?
> > If so, then you are correct.  Otherwise, no harm
> > done.
>
> I'm not sure what you mean. You can set a property to the empty string --
> that's what it's doing now. And the harm is that it doing that guarantees
> that the property will always be set, even if <loadfile> didn't actually
> load anything from the file. IOW: I'm using <loadfile> in combination with
> <filterchain>/<linecontainsregexp>, and if the file doesn't contain a line
> that matches my regexp, then nothing's actually getting loaded from the
> file, and the property shouldn't get set. But the way it is currently, the
> property does get set -- to the empty string.
>
> Diane
>
> =====
> (holtdl@yahoo.com)
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! - Official partner of 2002 FIFA World Cup
> http://fifaworldcup.yahoo.com
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Possible bug fix for LoadFile.java

Posted by Diane Holt <ho...@yahoo.com>.
--- Magesh Umasankar <um...@apache.org> wrote:
> Is there any rule that currently states that
> a property cannot exist with an empty value?
> If so, then you are correct.  Otherwise, no harm
> done.

I'm not sure what you mean. You can set a property to the empty string --
that's what it's doing now. And the harm is that it doing that guarantees
that the property will always be set, even if <loadfile> didn't actually
load anything from the file. IOW: I'm using <loadfile> in combination with
<filterchain>/<linecontainsregexp>, and if the file doesn't contain a line
that matches my regexp, then nothing's actually getting loaded from the
file, and the property shouldn't get set. But the way it is currently, the
property does get set -- to the empty string.

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Possible bug fix for LoadFile.java

Posted by Magesh Umasankar <um...@apache.org>.
Is there any rule that currently states that
a property cannot exist with an empty value?
If so, then you are correct.  Otherwise, no harm
done.

Cheers,
Magesh

******************************************************
*  Tears: The hydraulic force by which masculine     *
*  will-power is subdued by feminine show of power.  *
******************************************************
----- Original Message ----- 
From: "Diane Holt" <ho...@yahoo.com>
To: "Ant Developers List" <an...@jakarta.apache.org>
Sent: Wednesday, May 29, 2002 2:39 PM
Subject: Re: Possible bug fix for LoadFile.java


> --- Magesh Umasankar <um...@apache.org> wrote:
> > What if crh.readFully(...) returns null?
> 
> Yeah -- it actually needs to be:
>   if( text != null ) {
>     if( text.length > 0 ) {
> ...
> 
> Right?
> 
> Diane 
> 
> 
> =====
> (holtdl@yahoo.com)
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! - Official partner of 2002 FIFA World Cup
> http://fifaworldcup.yahoo.com
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Possible bug fix for LoadFile.java

Posted by Steve Loughran <st...@iseran.com>.
----- Original Message ----- 
From: "Diane Holt" <ho...@yahoo.com>
To: "Ant Developers List" <an...@jakarta.apache.org>
Sent: Wednesday, May 29, 2002 11:39 AM
Subject: Re: Possible bug fix for LoadFile.java


> --- Magesh Umasankar <um...@apache.org> wrote:
> > What if crh.readFully(...) returns null?
> 
> Yeah -- it actually needs to be:
>   if( text != null ) {
>     if( text.length > 0 ) {

you can short cut it:
 if( text != null  && text.length > 0) {



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Possible bug fix for LoadFile.java

Posted by Diane Holt <ho...@yahoo.com>.
--- Magesh Umasankar <um...@apache.org> wrote:
> What if crh.readFully(...) returns null?

Yeah -- it actually needs to be:
  if( text != null ) {
    if( text.length > 0 ) {
...

Right?

Diane 


=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Possible bug fix for LoadFile.java

Posted by Magesh Umasankar <um...@apache.org>.
What if crh.readFully(...) returns null?

**************************************************
*  Opportunist: A person who starts taking bath  *
*  if he accidentally falls into a river.        *
**************************************************
----- Original Message ----- 
From: "Diane Holt" <ho...@yahoo.com>
To: <an...@jakarta.apache.org>
Sent: Wednesday, May 29, 2002 2:33 PM
Subject: Possible bug fix for LoadFile.java


> Because of this line, which sets the "text" var:
> 
>                String text = "";
> 
> I've made the following change to LoadFile.java:
> 
>   @@ -194,7 +194,7 @@
>                    text = crh.readFully(instream);
>                }
> 
>   -            if (text != null) {
>   +            if (text.length() > 0) {
>                    project.setNewProperty(property, text);
>                    log("loaded " + text.length() + " characters",
>                        Project.MSG_VERBOSE);
> 
> since a) I don't see "text" ever being null, and b) the way it is now,
> it'll set the property to the empty string, which makes it useless for
> using the property in 'if' on a target (since the property is set).
> 
> Or am I missing something?
> 
> Diane
> 
> =====
> (holtdl@yahoo.com)
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! - Official partner of 2002 FIFA World Cup
> http://fifaworldcup.yahoo.com
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>