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 40641] New: - UnknownElement.maybeConfigure() is really "always configure"
Date Fri, 29 Sep 2006 15:53:52 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40641>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40641

           Summary: UnknownElement.maybeConfigure() is really "always
                    configure"
           Product: Ant
           Version: 1.6.5
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: major
          Priority: P2
         Component: Core
        AssignedTo: dev@ant.apache.org
        ReportedBy: kgregory@healthmarketscience.com


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) {
        child.maybeConfigure();
        if (child instanceof UnknownElement) {
            Object realThing = ((UnknownElement)child).getRealThing();
            if (realThing instanceof MyTask) {
                ((MyTask)realThing).injectParent(this);
            }
        }
        child.perform();
    }

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
runtime.

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: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


Mime
View raw message