Kallin Nagelberg | 16 Jul 22:03

[groovy-user] System.getproperty returns string 'false' instead of null.

I just discovered that calling System.getProperty(key) with a key that didn't exist is returning a String of value "false" instead of null.

This confuses my program as I do checks on the result like

if (result){
// do something
}

it actually does something, because "false" is not the same as empty string or null in groovy.

Has anyone experienced this?
Jim White | 16 Jul 22:58

Re: [groovy-user] System.getproperty returns string 'false' instead of null.

Kallin Nagelberg wrote:
> I just discovered that calling System.getProperty(key) with a key that 
> didn't exist is returning a String of value "false" instead of null.
> 
> This confuses my program as I do checks on the result like
> 
> if (result){
> // do something
> }
> 
> it actually does something, because "false" is not the same as empty 
> string or null in groovy.
> 
> Has anyone experienced this?

Nope.

 > groovy -e 'println System.getProperty("foobar")'
null

There is a System.getProperty(key, default), so perhaps you're using 
that by mistake.  But more likely (almost certainly) you're getting a 
property that is in fact defined with a value of "false".

In any case, Groovy doesn't impact this one way or the other since 
you're just dealing with Java API.

Jim

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Kallin Nagelberg | 16 Jul 23:08

Re: [groovy-user] System.getproperty returns string 'false' instead of null.

you're right, the property was being set to false somewhere.

Thanks :)

On Wed, Jul 16, 2008 at 4:58 PM, Jim White <jim-3x83HEs+8FyL7B8feK0ILA@public.gmane.org> wrote:
Kallin Nagelberg wrote:
I just discovered that calling System.getProperty(key) with a key that didn't exist is returning a String of value "false" instead of null.

This confuses my program as I do checks on the result like

if (result){
// do something
}

it actually does something, because "false" is not the same as empty string or null in groovy.

Has anyone experienced this?

Nope.

> groovy -e 'println System.getProperty("foobar")'
null

There is a System.getProperty(key, default), so perhaps you're using that by mistake.  But more likely (almost certainly) you're getting a property that is in fact defined with a value of "false".

In any case, Groovy doesn't impact this one way or the other since you're just dealing with Java API.

Jim

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email




Gmane