Uploaded image for project: 'Struts 1'
  1. Struts 1
  2. STR-1395

NullPointerException thrown by org.apache.struts.actions.ActionErrors in add(ActionMessages)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.1 RC1
    • 1.1 Family
    • Extras
    • 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));

      Attachments

        Activity

          People

            dgraham@apache.org David Graham
            stephen.cuppett@webmastersinc.net Stephen Cuppett
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: