cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <>
Subject Re: PropertyUtils.getProperty handling of nulls in intermediate / nested paths
Date Wed, 09 Oct 2013 19:02:11 GMT
I am totally familiar with the issue. BTW here is the current Tapestry approach to optional
relationships (which IIRC evolved after trying different things over the years) [1] :  // NPE is thrown
user?.name // Null is returned



On Oct 9, 2013, at 2:29 PM, John Huss <> wrote:

> Currently if you call PropertyUtils.getProperty with a chain of properties,
> like "" and a part of the chain is null you get
> UnresolvablePathException("Null value in the middle of the path…").  I
> believe it was done this way to match
> org.apache.commons.beanutils.BeanUtils.getNestedProperty
> To me this is undesirable - I'd rather have it just return null and stop
> evaluation.  That's how key value coding works in WebObjects.  I just have
> trouble seeing where an exception would be preferable to returning null.
> I'd be interested in either changing the behavior or adding an optional
> boolean flag that controls whether an exception is thrown or not.  On the
> other hand, it's simple enough to create my own static method that wraps
> this call and catches the exception.
> Does anyone else have an opinion on this?
> John

View raw message