commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections/buffer TestCircularFifoBuffer.java
Date Sat, 16 Oct 2004 22:23:41 GMT
scolebourne    2004/10/16 15:23:41

  Modified:    collections/src/java/org/apache/commons/collections/buffer
                        BoundedFifoBuffer.java
               collections RELEASE-NOTES.html
               collections/src/test/org/apache/commons/collections/buffer
                        TestCircularFifoBuffer.java
  Log:
  BoundedFifoBuffer/CircularFifoBuffer - Fix serialization to work in case where buffer serialized
when full
  bug 31433, from Kalle Gustafsson
  
  Revision  Changes    Path
  1.9       +6 -2      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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- BoundedFifoBuffer.java	2 Jun 2004 23:12:44 -0000	1.8
  +++ BoundedFifoBuffer.java	16 Oct 2004 22:23:40 -0000	1.9
  @@ -139,8 +139,12 @@
               elements[i] = in.readObject();
           }
           start = 0;
  -        end = size;
           full = (size == maxElements);
  +        if (full) {
  +            end = 0;
  +        } else {
  +            end = size;
  +        }
       }
   
       //-----------------------------------------------------------------------
  
  
  
  1.72      +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.71
  retrieving revision 1.72
  diff -u -r1.71 -r1.72
  --- RELEASE-NOTES.html	22 Sep 2004 23:35:03 -0000	1.71
  +++ RELEASE-NOTES.html	16 Oct 2004 22:23:41 -0000	1.72
  @@ -29,7 +29,7 @@
   (Checks performed using JDiff and Clirr, thanks).
   </p>
   <p>
  -The only new deprecations are ................
  +There are no new deprecations.
   </p>
   
   <center><h3>NEW CLASSES</h3></center>
  @@ -47,6 +47,7 @@
   <center><h3>BUG FIXES</h3></center>
   <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>
   </ul>
   
   <center><h3>JAVADOC</h3></center>
  
  
  
  1.5       +40 -1     jakarta-commons/collections/src/test/org/apache/commons/collections/buffer/TestCircularFifoBuffer.java
  
  Index: TestCircularFifoBuffer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/buffer/TestCircularFifoBuffer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestCircularFifoBuffer.java	2 Jun 2004 23:12:45 -0000	1.4
  +++ TestCircularFifoBuffer.java	16 Oct 2004 22:23:41 -0000	1.5
  @@ -15,6 +15,10 @@
    */
   package org.apache.commons.collections.buffer;
   
  +import java.io.ByteArrayInputStream;
  +import java.io.ByteArrayOutputStream;
  +import java.io.ObjectInputStream;
  +import java.io.ObjectOutputStream;
   import java.util.ArrayList;
   import java.util.Collection;
   import java.util.Iterator;
  @@ -192,6 +196,41 @@
               return;
           }
           fail();
  +    }
  +    
  +    public void testRepeatedSerialization() throws Exception {
  +        // bug 31433
  +        CircularFifoBuffer b = new CircularFifoBuffer(2);
  +        b.add("a");
  +        assertEquals(1, b.size());
  +        assertEquals(true, b.contains("a"));
  +        
  +        ByteArrayOutputStream bos = new ByteArrayOutputStream();
  +        new ObjectOutputStream(bos).writeObject(b);
  +        
  +        CircularFifoBuffer b2 = (CircularFifoBuffer) new ObjectInputStream(
  +            new ByteArrayInputStream(bos.toByteArray())).readObject();
  +        
  +        assertEquals(1, b2.size());
  +        assertEquals(true, b2.contains("a"));
  +        b2.add("b");
  +        assertEquals(2, b2.size());
  +        assertEquals(true, b2.contains("a"));
  +        assertEquals(true, b2.contains("b"));
  +        
  +        bos = new ByteArrayOutputStream();
  +        new ObjectOutputStream(bos).writeObject(b2);
  +        
  +        CircularFifoBuffer b3 = (CircularFifoBuffer) new ObjectInputStream(
  +            new ByteArrayInputStream(bos.toByteArray())).readObject();
  +        
  +        assertEquals(2, b3.size());
  +        assertEquals(true, b3.contains("a"));
  +        assertEquals(true, b3.contains("b"));
  +        b3.add("c");
  +        assertEquals(2, b3.size());
  +        assertEquals(true, b3.contains("b"));
  +        assertEquals(true, b3.contains("c"));
       }
   
       public String getCompatibilityVersion() {
  
  
  

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


Mime
View raw message