Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4126

Incorrect behavior for ELSupport.containsNulls()

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.14.3
    • Fix Version/s: 2.3.16
    • Component/s: Plugin - Embedded JSP
    • Labels:
    • Environment:

      any

    • Flags:
      Patch, Important

      Description

      The incorrect behavior appears in version 2.3.14.3 and in revision
      1495522. I attached a one-line patch (patch.diff) that fixes it.

      Method "ELSupport.containsNulls" checks if the "Object[] obj" array
      contains nulls like this:

      for (int i = 0; i < obj.length; i++) {
          if (obj[0] == null) {
              return true;
          }
      }
      return false;
      

      Instead of "obj[0]", the code should be "obj[i]", as in patch.diff.

      If indeed the code is intended to check only "obj[0]", then there is
      no need for a loop and the entire method body should be only "return
      obj[0] == null;" (I attached patch2.diff, though it's unlikely that
      this is the correct behavior).

      1. patch2.diff
        0.7 kB
        Adrian Nistor
      2. patch.diff
        0.6 kB
        Adrian Nistor

        Activity

        Hide
        hudson Hudson added a comment -

        SUCCESS: Integrated in Struts2-JDK6 #758 (See https://builds.apache.org/job/Struts2-JDK6/758/)
        WW-4126 - changed logic of is statement so that every element in the Object array is compared to null (bphillips: rev 1504168)

        • /struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/ELSupport.java
        Show
        hudson Hudson added a comment - SUCCESS: Integrated in Struts2-JDK6 #758 (See https://builds.apache.org/job/Struts2-JDK6/758/ ) WW-4126 - changed logic of is statement so that every element in the Object array is compared to null (bphillips: rev 1504168) /struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/ELSupport.java
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1504168 from Bruce Phillips in branch 'struts2/trunk'
        [ https://svn.apache.org/r1504168 ]

        WW-4126 - changed logic of is statement so that every element in the Object array is compared to null

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1504168 from Bruce Phillips in branch 'struts2/trunk' [ https://svn.apache.org/r1504168 ] WW-4126 - changed logic of is statement so that every element in the Object array is compared to null
        Hide
        bphillips Bruce Phillips added a comment -

        changed if statement from if (obj[0]... to if (obj[i]

        Show
        bphillips Bruce Phillips added a comment - changed if statement from if (obj [0] ... to if (obj [i]
        Hide
        bphillips Bruce Phillips added a comment -

        After reviewing the public method containsNulls of class struts2 plugins embeddedjsp struts2/plugins/embeddedjsp/ELSupport I'm not sure what the purpose of the method is. I don't see where any of the other classes in the embeddedjsp plugin call this method.

        But clearly there is an issue with the code.

        I've changed the if statement to if (obj[i] == null) - run the unit tests for the plugin and they all still pass.

        Show
        bphillips Bruce Phillips added a comment - After reviewing the public method containsNulls of class struts2 plugins embeddedjsp struts2/plugins/embeddedjsp/ELSupport I'm not sure what the purpose of the method is. I don't see where any of the other classes in the embeddedjsp plugin call this method. But clearly there is an issue with the code. I've changed the if statement to if (obj [i] == null) - run the unit tests for the plugin and they all still pass.

          People

          • Assignee:
            bphillips Bruce Phillips
            Reporter:
            adriannistor Adrian Nistor
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development