You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2003/04/14 13:59:36 UTC
DO NOT REPLY [Bug 18991] New: -
NullPointerException thrown by org.apache.struts.actions.ActionErrors in add(ActionMessages)
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18991>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18991
NullPointerException thrown by org.apache.struts.actions.ActionErrors in add(ActionMessages)
Summary: NullPointerException thrown by
org.apache.struts.actions.ActionErrors in
add(ActionMessages)
Product: Struts
Version: 1.1 RC1
Platform: All
OS/Version: All
Status: NEW
Severity: Minor
Priority: Other
Component: Standard Actions
AssignedTo: struts-dev@jakarta.apache.org
ReportedBy: stephen.cuppett@webmastersinc.net
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));
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org