title: Bidirectional JavaFX Binding is destroyed by unrelated code
body: <p><strong>Update: Found a easier way to reproduce buggy behavior</strong></p>
  
  <p>When I setup a bidirectional JavaFX binding between three variables this binding is sometimes destroyed by unrelated code.</p>
  
  <p>I created a small example program which is capable of reproducing the buggy behavior:</p>
  
  <p>In the MainController the binding is setup and three listeners are added to output the new value of the variable:</p>
  
  <pre><code>package bug;
  
  import java.nio.file.Path;
  
  import javafx.beans.property.ObjectProperty;
  import javafx.beans.property.SimpleObjectProperty;
  import javafx.fxml.FXML;
  
  public class MainController {
  
      @FXML
      private Foo foo;
  
      @FXML
      private Bar bar;
  
      private ObjectProperty&lt;Path&gt; pathProperty = new SimpleObjectProperty&lt;&gt;();
  
      @FXML
      private void initialize() {
  
      pathProperty.addListener((observablePath, oldPath,
          newPath) -&gt; {
          System.out.println(newPath);
      });
  
      foo.pathProperty().addListener((observablePath, oldPath,
          newPath) -&gt; {
          System.out.println(newPath);
      });
  
      bar.pathProperty().addListener((observablePath, oldPath,
          newPath) -&gt; {
          System.out.println(newPath);
          });
  
      bar.pathProperty()
          .bindBidirectional(pathProperty);
      foo.pathProperty()
          .bindBidirectional(pathProperty);
      }
  
  }
  </code></pre>
  
  <p>The FooController changes one of the variables using a counter triggered by a button click. Pressing the button should output the same value three times because we setup three listeners. This works as expected as long the value of the DatePicker is not changed. But after that each number is only outputted once.</p>
  
  <pre><code>package bug;
  
  import java.nio.file.Paths;
  import java.time.LocalDate;
  
  import javafx.beans.value.ChangeListener;
  import javafx.event.ActionEvent;
  import javafx.fxml.FXML;
  import javafx.scene.control.DatePicker;
  
  public class FooController extends Base {
  
      int counter = 0;
  
      @FXML
      private DatePicker startDatePicker;
  
      private ChangeListener&lt;LocalDate&gt; breakThings;
  
      @FXML
      private void onBugClicked(ActionEvent event) {
      for (int i = 0; i &lt; 3; i++) {
          pathProperty.set(Paths.get(String.valueOf(counter++)));
      }
      }
  
      @FXML
      private void initialize() {
  
      breakThings = (observableDate, oldDate, newDate)-&gt;{
          System.out.println("Triggered");
      };  
  
      startDatePicker.valueProperty().addListener(breakThings);
      }
  }
  </code></pre>
  
  <p>Base class of the Foo and Bar controller</p>
  
  <pre><code>package bug;
  
  import java.nio.file.Path;
  
  import javafx.beans.property.ObjectProperty;
  import javafx.beans.property.SimpleObjectProperty;
  
  public abstract class Base {
  
      protected ObjectProperty&lt;Path&gt; pathProperty = new SimpleObjectProperty&lt;&gt;();
  
      public ObjectProperty&lt;Path&gt; pathProperty() {
      return pathProperty;
      }
  
  }
  </code></pre>
  
  <p>BarController:</p>
  
  <pre><code>package bug;
  
  public class BarController extends Base {
  
  }
  </code></pre>
  
  <p>Foo:</p>
  
  <pre><code>package bug;
  
  import java.io.IOException;
  import java.nio.file.Path;
  
  import javafx.beans.property.ObjectProperty;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.layout.BorderPane;
  
  public class Foo extends BorderPane {
  
      private final FooController controller;
  
      public Foo() {
      controller = new FooController();
      FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(
          "Foo.fxml"));
      fxmlLoader.setRoot(this);
      fxmlLoader.setController(controller);
      try {
          fxmlLoader.load();
      } catch (IOException exception) {
          throw new RuntimeException(exception);
      }
      }
  
      public ObjectProperty&lt;Path&gt; pathProperty() {
      return controller.pathProperty();
      }    
  
  }
  </code></pre>
  
  <p>Bar:</p>
  
  <pre><code>package bug;
  
  import java.nio.file.Path;
  
  import javafx.beans.property.ObjectProperty;
  import javafx.scene.layout.BorderPane;
  
  public class Bar extends BorderPane {
  
      private final BarController controller;
  
      public Bar() {
      controller = new BarController();
      }
  
      public ObjectProperty&lt;Path&gt; pathProperty() {
      return controller.pathProperty();
      }
  
  }
  </code></pre>
  
  <p>Expected Output (after four button clicks):</p>
  
  <pre><code>0
  0
  0
  1
  1
  1
  2
  2
  2
  3
  3
  3
  4
  4
  4
  5
  5
  5
  6
  6
  6
  7
  7
  7
  8
  8
  8
  9
  9
  9
  10
  10
  10
  11
  11
  11
  </code></pre>
  
  <p>Actual Output (after four button clicks):</p>
  
  <pre><code>0
  0
  0
  1
  1
  1
  2
  2
  2
  3
  3
  3
  4
  4
  4
  5
  5
  5
  6
  6
  6
  7
  7
  7
  8
  8
  8
  (Select date with DatePicker)
  9
  10
  11
  </code></pre>
  
  <p>Java Version:1.8.0_20</p>
  
  <p>JavaFX Version: 8.0.20-b26</p>