Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-2337

IndexOutOfBoundsException when PropertyResolver is using an invalid list index

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.6
    • Fix Version/s: 1.3.7, 1.4-RC7
    • Component/s: wicket
    • Labels:
      None

      Description

      When using PropertyResolver.getValue("myList[1]", myBean), the PropertyResolver$ListGetSet.getValue() (line 762) unconditionally does:
      return ((List)object).get(index);
      which throws an java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 if the backing list contains only one element (at index 0).
      Shouldn't the implementation rather return null like with every other property not found? Like when using "bla.bli.blo" as a lookup string and there is no bla field and no getBla() method?

      So this method should rather be:

      org.apache.wicket.util.lang.PropertyResolver$ListGetSet.getValue():

      /**

      • @see org.apache.wicket.util.lang.PropertyResolver.IGetAndSet#getValue(java.lang.Object)
        */
        public Object getValue(Object object)
        Unknown macro: { List list = (List) object; if (index >= list.size()) { return null; } return list.get(index); }

        Attachments

          Activity

            People

            • Assignee:
              jcompagner Johan Compagner
              Reporter:
              tapter Matthias Keller
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: