You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ps...@apache.org on 2005/01/15 23:47:41 UTC

cvs commit: jakarta-commons/collections RELEASE-NOTES.html

psteitz     2005/01/15 14:47:41

  Modified:    collections/src/java/org/apache/commons/collections/buffer
                        BoundedFifoBuffer.java
               collections/src/test/org/apache/commons/collections/buffer
                        TestBoundedFifoBuffer.java
               collections RELEASE-NOTES.html
  Log:
  Fixed bug in iterator remove. Shift operation was not incrementing indexes
  properly.  Also improved documentation.
  BZ #33071
  Reported by: Amir Tahvildaran
  
  Revision  Changes    Path
  1.10      +17 -3     jakarta-commons/collections/src/java/org/apache/commons/collections/buffer/BoundedFifoBuffer.java
  
  Index: BoundedFifoBuffer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/buffer/BoundedFifoBuffer.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- BoundedFifoBuffer.java	16 Oct 2004 22:23:40 -0000	1.9
  +++ BoundedFifoBuffer.java	15 Jan 2005 22:47:40 -0000	1.10
  @@ -67,10 +67,24 @@
       /** Serialization version */
       private static final long serialVersionUID = 5603722811189451017L;
   
  +    /** Underlying storage array */
       private transient Object[] elements;
  +    
  +    /** Array index of first (oldest) buffer element */
       private transient int start = 0;
  +    
  +    /** 
  +     * Index mod maxElements of the array position following the last buffer
  +     * element.  Buffer elements start at elements[start] and "wrap around"
  +     * elements[maxElements-1], ending at elements[decrement(end)].  
  +     * For example, elements = {c,a,b}, start=1, end=1 corresponds to 
  +     * the buffer [a,b,c].
  +     */
       private transient int end = 0;
  +    
       private transient boolean full = false;
  +    
  +    /** Capacity of the buffer */
       private final int maxElements;
   
       /**
  @@ -348,8 +362,8 @@
                           elements[i - 1] = elements[0];
                           i = 0;
                       } else {
  -                        elements[i - 1] = elements[i];
  -                        i++;
  +                        elements[decrement(i)] = elements[i];
  +                        i = increment(i);
                       }
                   }
   
  
  
  
  1.5       +12 -1     jakarta-commons/collections/src/test/org/apache/commons/collections/buffer/TestBoundedFifoBuffer.java
  
  Index: TestBoundedFifoBuffer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/buffer/TestBoundedFifoBuffer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestBoundedFifoBuffer.java	2 Jun 2004 23:12:45 -0000	1.4
  +++ TestBoundedFifoBuffer.java	15 Jan 2005 22:47:40 -0000	1.5
  @@ -168,6 +168,17 @@
       public String getCompatibilityVersion() {
           return "3.1";
       }
  +    
  +    // BZ 33071 -- gets start=end=1 before removal of interior element
  +    public void testShift() {
  +        BoundedFifoBuffer fifo = new BoundedFifoBuffer(3);
  +        fifo.add("a");
  +        fifo.add("b");
  +        fifo.add("c");
  +        fifo.remove();
  +        fifo.add("e");
  +        fifo.remove("c");
  +    }
   
   //    public void testCreate() throws Exception {
   //        resetEmpty();
  
  
  
  1.77      +2 -1      jakarta-commons/collections/RELEASE-NOTES.html
  
  Index: RELEASE-NOTES.html
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/RELEASE-NOTES.html,v
  retrieving revision 1.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- RELEASE-NOTES.html	4 Jan 2005 00:13:25 -0000	1.76
  +++ RELEASE-NOTES.html	15 Jan 2005 22:47:41 -0000	1.77
  @@ -52,6 +52,7 @@
   <ul>
   <li>FastArrayList - Fix iterators and views to work better in multithreaded environments</li>
   <li>BoundedFifoBuffer/CircularFifoBuffer - Fix serialization to work in case where buffer serialized when full [31433]</li>
  +<li>BoundedFifoBuffer - Fix iterator remove bug causing ArrayIndexOutOfBounds error [33071]
   <li>MultiHashMap.remove(key, item) - Was returning the item even when nothing was removed [32366]</li>
   </ul>
   
  @@ -61,4 +62,4 @@
   <li>ListOrderedSet.decorate(List) - Better comment [32073]</li>
   </ul>
   </body>
  -</html>
  \ No newline at end of file
  +</html>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org