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

VetoableListDecorator: Indexes to remove are not aggregated

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_7

      Description

      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 ----------

        Attachments

          Activity

            People

            • Assignee:
              jdv Jayathirth D V
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: