avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Turner <j...@socialchange.net.au>
Subject Configuration getChild() never returns null
Date Sat, 10 Nov 2001 10:22:22 GMT

The javadocs for Configuration state:

  "The contract surrounding the Configuration is that once it is
  created, information never changes."

There are two variants of getChild:

Configuration getChild(java.lang.String child)
Configuration getChild(java.lang.String child, boolean createNew);

Now I'm wondering, what's the "createNew" attribute for? Why would you
want to create a new Configuration, when you can't do anything with it
(it's read-only).

Even more surprising is that for the single arg version, "createNew" is
true. So getChild("foo") won't return null even if no child "foo"
exists. I suppose this prevents inadvertent NPEs, but also prevents
useful tests like:

if (conf.getChild("foo") != null) {
	// ..

Is there a reason for returning an empty child Configuration, or is this
a bug?


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

View raw message