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

VetoableListDecorator: Indexes to remove are not aggregated

XMLWordPrintable

    • b02
    • x86_64
    • windows_7

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

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      The VetoableListDecorator dokcumentation says:

      If something is going to be removed, the <code>indexes</code> are paired by two:
           * from(inclusive)-to(exclusive) and are pointing to the current list.
      ....

      But this is not the case, the indexes are not paired correct, for every index a new pair is created.



      REGRESSION. Last worked in version 8u112

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Source code for an executable test case is provided, just run it and compare the actual result with the expected result.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      proposed remove: range 2 to 7
      ACTUAL -
      proposed remove: range 2 to 3
      proposed remove: range 3 to 4
      proposed remove: range 4 to 5
      proposed remove: range 5 to 6
      proposed remove: range 6 to 7

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      ObservableList<String> list = FXCollections.observableArrayList();

              for (int i = 0; i < 10; i++) {
                  list.add("TEST" + i);
              }
              
              List<String> toRemove = new ArrayList<>(list.subList(2, 7));
              
              VetoableListDecorator<String> vetoableList = new VetoableListDecorator<String>(list) {
                  @Override
                  protected void onProposedChange(List<String> toBeAdded, int... indexes) {
                      for (int i = 0; i < indexes.length; i += 2) {
                          System.out.println("proposed remove: range " + indexes[i] + " to " + indexes[i + 1]);
                      }
                  }
              };
              
              vetoableList.removeAll(toRemove);
      ---------- END SOURCE ----------

            mstrauss Michael Strauß
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: