ConcurrentModificationException if an attempt is made to remove an accelerator whilst an accelerator callback is being processed

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 8u40
    • Affects Version/s: 8u5
    • Component/s: javafx
    • None

      In com.sun.javafx.scene.KeyboardShortcutsHandler.processAccelerators we iterate over the accelerators with a for statement. This means an accelerator cannot remove itself in its own callback. For example, this crops up if you have a "back" keyboard shortcut that is bound when a new part of the UI appears and wants to remove itself once the user has pressed it.

      A simple fix would be to duplicate the entrySet before starting the for loop. Alternatively and more ambitiously ObservableEntrySet/ObservableMap could be upgraded to make iterators survive modification a la CopyOnWriteArrayList.

      In a library I maintain we use COW lists for all event listener registrations, exactly for this reason.

            Assignee:
            Martin Sládeček
            Reporter:
            Mike Hearn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: