A Struts user has pointed out that if you call something like:

  String name = PropertyUtils.getSimpleProperty(null, "name");

you will receive a somewhat misleading NoSuchMethodException with the text
"Unknown property 'name'".

The question is, what would be appropriate in this case (and can be
extended to the other cases where you might accidentally pass a null for
the bean you are trying to process).  I can think of several options:

(1) Leave it as is

(2) Throw IllegalArgumentException because bean is null

(3) Throw NullPointerException because bean is null

(4) Return a null value (which would be ambiguous if the real property
    can be null)

Right now, I'm leaning towards (2) for getSimpleProperty() and the other
methods that take a "bean" argument.  What do you think?

Craig


Reply via email to