Wicket
  1. Wicket
  2. WICKET-1383

MiniMap IndexOutOfBoundsException when empty

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.1
    • Fix Version/s: 1.3.2
    • Component/s: wicket
    • Labels:
      None

      Description

      findKey() assumes that there is at least one entry in the map

      This checks first:

      Index: /Users/John/Development/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/collections/MiniMap.java
      ===================================================================
      — /Users/John/Development/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/collections/MiniMap.java (revision 614519)
      +++ /Users/John/Development/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/collections/MiniMap.java (working copy)
      @@ -118,13 +118,16 @@
      */
      public Object get(final Object key)
      {

      • // Search for key
      • final int index = findKey(key);
        -
      • if (index != -1)
        + if (size > 0)
        {
      • // Return value
      • return values[index];
        + // Search for key
        + final int index = findKey(key);
        +
        + if (index != -1)
        + { + // Return value + return values[index]; + }

        }

      // Failed to find key

        Activity

        Hide
        John Patterson added a comment -

        Oh actually the problem was in findKey() so the fix should go in there

        Show
        John Patterson added a comment - Oh actually the problem was in findKey() so the fix should go in there

          People

          • Assignee:
            Igor Vaynberg
            Reporter:
            John Patterson
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development