cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pier Fumagalli <>
Subject Re: [Kernel2.2] Remove nulls?
Date Wed, 31 Mar 2004 13:23:21 GMT

On 31 Mar 2004, at 13:34, Gianugo Rabellino wrote:
> Pier Fumagalli wrote:
>> On 31 Mar 2004, at 11:52, Gianugo Rabellino wrote:
>>> I've seen in the new API that in a number of places there are  
>>> contracts that return null if something isn't found: since these are  
>>> all perfect candidates for nasty NPEs, how about switching to  
>>> NullObject pattern or throw Exceptions instead?
>> As far as I can see, "null"s are returned only when implementing the  
>> collections interfaces (Library, Parameters, Configuration) or when  
>> URLs are resolved (Resolver).
>> And even there (ex. Configuration and Parameters) when calling a  
>> method specifed in the interface, and not inherited from the  
>> Set/Map/Collection, it will throw specific exceptions (ex.  
>> ConfigurationException).
>> Where did you notice it?
> Well... there are 10 occurrences, but this are the most prominent:

o.a.c.kernel.configuration.Parameters implements java.util.Map;

there are a ton of "getParameter..." methods in there throwing the  
right exceptions. We could add a generic "getParameter" that behaves  
like you want and that breakes the "get" contract with Map


o.a.c.kernel.archival.Library implements java.util.Set:

as the set doesn't have a "get" method, we could throw an exception,  
but if it does I'd rather call the method "getDescriptor()" (to show  
that it is _really_ outside of the concerns of Java Collections)


This follows the "null" returned by the usual source resolution  
mechanism used by the platform. See: 

Only Avalon seems to be throwing an IOException: 

Which is my very own opinion is wrong because an IOException signifies  
that there was an error in the I/O (the remote site was down, the  
process didn't have enough access to read from the disk). The correct  
Exception to throw would be 

I _really_ don't like reinventing wheels! :-P (whops, I just did)

> I haven't been through the code to see what exactly these things do,  
> but from a pure OOP POV (whatever that means :-)) there is some "code  
> that smells" ( It might make sense,  
> but in most cases it doesn't.

My armpits can smell pretty badly too at times...


View raw message