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

ConcurrentModificationException in MediaPlayer

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • jfx23
    • 8u66, 9
    • javafx
    • b15
    • x86
    • os_x

      FULL PRODUCT VERSION :
      1.8.0u66

      ADDITIONAL OS VERSION INFORMATION :
      OSX 10.11.2

      A DESCRIPTION OF THE PROBLEM :
      MediaView.setMediaPlayer(...) called multiple times fill cause ConcurrentModificationException.

      The JavaFx code is modifying an an underlaying collection whilst iterating over. Although synchronized in each case, the issue is being caused on same thread. should be removing via collection iterator NOT the collection itself. issue in multiple places within MediaPlayer
      ...
          void removeView(MediaView view) {
              synchronized (viewRefs) {
                  for (WeakReference<MediaView> vref : viewRefs) {
                      MediaView v = vref.get();
                      if (v != null && v.equals(view)) {
                          viewRefs.remove(vref);
                      }
                  }
              }
          }
      ...



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create MediaView
      call setMedia with new MediaPlayer
      multiple times as in case of Next track function

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      excpecting next media item to play
      ACTUAL -
      Caused by: java.util.ConcurrentModificationException
      at java.util.HashMap$HashIterator.nextNode(HashMap.java:1429)
      at java.util.HashMap$KeyIterator.next(HashMap.java:1453)
      at javafx.scene.media.MediaPlayer.removeView(MediaPlayer.java:1712)
      at javafx.scene.media.MediaView$1.invalidated(MediaView.java:355)
      at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:111)
      at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:146)
      at javafx.scene.media.MediaView.setMediaPlayer(MediaView.java:328)

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Caused by: java.util.ConcurrentModificationException
      at java.util.HashMap$HashIterator.nextNode(HashMap.java:1429)
      at java.util.HashMap$KeyIterator.next(HashMap.java:1453)
      at javafx.scene.media.MediaPlayer.removeView(MediaPlayer.java:1712)
      at javafx.scene.media.MediaView$1.invalidated(MediaView.java:355)
      at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:111)
      at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:146)
      at javafx.scene.media.MediaView.setMediaPlayer(MediaView.java:328)

      REPRODUCIBILITY :
      This bug can be reproduced always.

            almatvee Alexander Matveev
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: