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

One and only one change listener works for MapPropertyBase<K,V>

    XMLWordPrintable

Details

    • x86
    • other

    Description

      FULL PRODUCT VERSION :
      java version "1.8.0_121"
      Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.14393]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Same on OpenSUSE Leap 42

      A DESCRIPTION OF THE PROBLEM :
      javafx.beans.property
      Class MapPropertyBase<K,V>

      public void addListener(ChangeListener<? super ObservableMap<K,V>> listener)

      If 2 or more listeners are added via this API nothing happens on any map change. Only single listener works properly.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the provided source code.

      If 2 listeners for "map" are commented then remaining single listener works.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Map Listener 1
      Map Listener 2
      Map Listener 3
      Boolean Listener 1
      Boolean Listener 2
      Boolean Listener 3
      ACTUAL -
      Boolean Listener 1
      Boolean Listener 2
      Boolean Listener 3

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package observabletest;

      import javafx.beans.property.SimpleBooleanProperty;
      import javafx.beans.property.SimpleMapProperty;
      import javafx.collections.FXCollections;

      public class ObservableTest {
          public static void main(String[] args) {
              SimpleMapProperty<String, String> map = new SimpleMapProperty<>(FXCollections.observableHashMap());
              SimpleBooleanProperty b = new SimpleBooleanProperty(false);

              map.addListener((x,y,z) -> System.out.println("Map Listener 1"));
              map.addListener((x,y,z) -> System.out.println("Map Listener 2"));
              map.addListener((x,y,z) -> System.out.println("Map Listener 3"));

              b.addListener((x,y,z) -> System.out.println("Boolean Listener 1"));
              b.addListener((x,y,z) -> System.out.println("Boolean Listener 2"));
              b.addListener((x,y,z) -> System.out.println("Boolean Listener 3"));

              map.put("1", "2");
              b.set(true);
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use another ObservableMap instance, bind to this one and add a single listener to each one. Both listeners work. It seems like any number of bindings works as long as only one listener is added per ObservableMap instance.

      Attachments

        Issue Links

          Activity

            People

              vadim Vadim Pakhnushev
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: