glazedlists
  1. glazedlists
  2. GLAZEDLISTS-472

IndexOutOfBoundsException in ThreadProxyEventList

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: current
    • Fix Version/s: milestone 1
    • Component/s: swing
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      472

      Description

      Here's a tasty concurrency bug.

      I get an IndexOutOfBoundsException from ThreadProxyEventList when a filtered list is displayed in a
      JList via EventListModel. When the filter criteria changes and there are fewer items in the list, the
      previously selected index may be greater than the number of items now in the list. If you then call
      getSelectedValue() on the JList, it asks the underlying list for an index that doesn't exist and you get the
      exception. I'm not doing any locking myself under the assumption that EventListModel is supposed to
      be doing that behind the scenes.

      Possibly related to: <a href="https://glazedlists.dev.java.net/servlets/ReadMsg?
      listName=dev&msgNo=1066">IndexOutOfBoundsException in ThreadProxyEventList</a>

      Verified to happen on Mac OSX and WinXP.

        Activity

        Hide
        cbare added a comment -

        Created an attachment (id=45)
        Reproduce IndexOutOfBoundsException

        Show
        cbare added a comment - Created an attachment (id=45) Reproduce IndexOutOfBoundsException
        Hide
        jplemieux added a comment -

        Please use an EventSelectionModel. Interaction between GL models and normal
        Swing models isn't always elegant because of eccentricities in controller code.

        Specifically, this code will fix your exception:

        listBox.setSelectionModel(new EventSelectionModel<String>(filteredFruits));

        Show
        jplemieux added a comment - Please use an EventSelectionModel. Interaction between GL models and normal Swing models isn't always elegant because of eccentricities in controller code. Specifically, this code will fix your exception: listBox.setSelectionModel(new EventSelectionModel<String>(filteredFruits));
        Hide
        cbare added a comment -

        Oops, my bad. I verified that using EventSelectionModel works as expected (on OS X and Windows).
        Thanks.

        Show
        cbare added a comment - Oops, my bad. I verified that using EventSelectionModel works as expected (on OS X and Windows). Thanks.

          People

          • Assignee:
            jessewilson
            Reporter:
            cbare
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: