ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 4752] Make Ant report an error when an undefined property is referenced.
Date Thu, 30 Oct 2008 14:47:16 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=4752





--- Comment #5 from Matt Benson <gudnabrsam@yahoo.com>  2008-10-30 07:47:15 PST ---
(In reply to comment #4)
> Thanks Matt, but we are not there yet.
> 
> The apidoc at
> 
> http://www.dpml.net/api/ant/1.6.4/org/apache/tools/ant/PropertyHelper.html#getUserProperty(java.lang.String,
> java.lang.String)
> 
> seems to point at the method responsible for resolving a property. But the
> contract seems to be to return null for undefined properties.
> 
> Maybe I should overrid this method like this:
> public java.lang.Object getUserProperty(java.lang.String ns,
>                                         java.lang.String name) {
>   Object retval = super.getUserProperty(ns,name);
>   if(retval == null) throw new SomeException();
>   else return retval;
> }
> 

That's pretty much what I suggest.  Note that you don't really need the else
once you've thrown the exception.  ;)

> How will this contract violation work (now and in the future)? What should
> SomeException be? Etc. Seems that it's the caller's responsibility to handle
> null in a different way.

Use a BuildException.  As for contract violation, you wanted the build to
break... after that, nothing else can happen anyway... seems fine to me.

> 
> Besides, the apidoc starts with "NOT FINAL. API MAY CHANGE". Doesn't sound like
> fun to customize this, does it :)
> 

I wondered if you'd point that out.  Those comments are really left over from
the beginnings of PropertyHelper, and sure enough, we did change it.  But I
like to think we put a lot of thought into it when we did so and that code has
been stable now for quite some time.  We probably should remove that warning,
at least before shipping 1.8.0, because I think the API we have now is good
enough--minus the (many) deprecated methods, of course.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Mime
View raw message