ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <ste...@apache.org>
Subject Re: FileSet with copy fails with NPE..
Date Fri, 12 Dec 2008 12:57:23 GMT
Raja Nagendra Kumar wrote:
> Pl. find the fix for the same in ProjectComponent
> 
> We are defining a GOBAL_DEFAULT_PROJECT which would be same as the first non
> null setProject call parameter.
> 
> getProject() value on any tag if null, the non null GOBAL_DEFAULT_PROJECT
> value is assumed with debug log message saying about this assumption.
> 

No, this is lethal. This code encodes a static variable with the 
assumption that its ok to hold a long-lived project instance. Every IDE 
that uses Ant, everything else that embeds ant will come and tell us off.

An NPE is a validity check to ensure that every task has an owning 
project. Not a friendly one, but one that certainly halts the app with a 
stack trace.  Its something the developers get to see, usually the first 
time a task tries to log something. by the time the end users get to see 
it, it should have been fixed. That's the one nice thing about NPEs: 
they are hard to ignore.

Tasks that create other tasks should bind them with 
bindToOwner(ProjectComponent). This ensures that not only is project 
picked up, the child task even picks up the same name in the logs.

-steve

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


Mime
View raw message