Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.1 RC1
-
None
-
Operating System: All
Platform: All
-
18991
Description
When returning from the validate() function, Javadoc lists either null or an
empty list of ActionErrors to be valid return types; however, when creating a
superclass chain stemming from ActionForm a peculiar NullPointerException will
show up.
The problem appears to be in that the add(ActionMessages) function in the
ActionErrors class cannot handle null as an input. So the call
someActionErrsObj.add(super.validate(...)) when the superclass returns null
(prescribed as valid return for that function) throws a NullPointerException
that in my opinion should not happen given that an empty ActionErrors object or
null is listed in the doc as a valid return.
A workaround for it is this:
ActionErrors errors = new ActionErrors();
ActionErrors parentErrors = super.validate(mapping, request);
if (parentErrors != null)
errors.add(parentErrors);
However, the code without the exception could look like this:
ActionErrors errors = new ActionErrors();
errors.add(super.validate(mapping, request));