ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [Bug 40641] UnknownElement.maybeConfigure() is really "always configure"
Date Wed, 27 Feb 2008 05:18:43 GMT

--- Comment #6 from Keith D Gregory <>  2006-09-29 15:53:52 ---
Although the documentation indicates that this method will only configure a task
if it has not already been configured, the actual code always creates a new
object, and always calls configure() with that new object.

Aside from not following the documentation, this makes any sort of parent-child
dependency injection impossible. Consider the following:

    for (Task child : _children) {
        if (child instanceof UnknownElement) {
            Object realThing = ((UnknownElement)child).getRealThing();
            if (realThing instanceof MyTask) {

When I explicitly call maybeConfigure() on the child, assuming that the parent
hasn't been executed already, I expect it to create an actual child instance. I
then inject the dependency (ugly though that may be), and perform the task. I
know that perform() will also call maybeConfigure(), but according to the
documentation, it should only do something "if it hasn't been done already".
Instead, it replaces the "real thing" with a new instance, and I get a NPE when
I try to access the parent.

One alternative is to create the children explicitly, via factory methods on the
parent. However, these children will be configured _before the parent is run_,
which means that I can't rely on property conversions (since they property is
still "${foo}" at this point, and have to explicitly convert the properties at

Another alternative (and I'll add an enhancement request for this if it's not in
the 1.7 beta docs) is to allow dependency injection as part of the Task interface.

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

View raw message