[jdom-interest] Bug in ContentList.addAll(int,Collection)

Bradley S. Huffman hip at a.cs.okstate.edu
Thu Apr 17 19:15:05 PDT 2003


Patch to fix two bugs in ContentList, one the bug found recently by Rolf Lear
in addAll, the other one in FilterIterator found by John Kammer back in Feb.

Brad

*** ContentList.java	Thu Apr 17 21:00:53 2003
--- ContentList.new	Thu Apr 17 20:55:01 2003
***************
*** 480,486 ****
          }
          catch (RuntimeException exception) {
              for (int i = 0; i < count; i++) {
!                 remove(index + i);
              }
              throw exception;
          }
--- 480,486 ----
          }
          catch (RuntimeException exception) {
              for (int i = 0; i < count; i++) {
!                 remove(index);
              }
              throw exception;
          }
***************
*** 982,990 ****
              checkConcurrentModification();
  
              switch(lastOperation) {
!             case CREATE:  cursor = initialCursor;
                            if (cursor >= ContentList.this.size()) {
!                                cursor = moveBackward(initialCursor);
                            }
                            break;
              case PREV:
--- 982,990 ----
              checkConcurrentModification();
  
              switch(lastOperation) {
!             case CREATE:  cursor = initialCursor - 1;
                            if (cursor >= ContentList.this.size()) {
!                                cursor = moveBackward(initialCursor - 1);
                            }
                            break;
              case PREV:
***************
*** 1074,1080 ****
              checkConcurrentModification();
  
              if (filter.matches(obj)) {
!                 last++;
                  ContentList.this.add(last, obj);
              }
              else {
--- 1074,1080 ----
              checkConcurrentModification();
  
              if (filter.matches(obj)) {
!                 last = cursor + 1;
                  ContentList.this.add(last, obj);
              }
              else {



More information about the jdom-interest mailing list