Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8097154

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

    XMLWordPrintable

    Details

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

      Description

      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.

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:
              Imported: