commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knych, Thomas [IT]" <thomas.kn...@citigroup.com>
Subject UnboundedFifoBuffer - serialization bug + fix
Date Wed, 13 Jul 2005 14:15:14 GMT
Commons Collections- 

We recently found a bug in the serialization of UnboundedFifoBuffer. Apparently when the object
is serialized and then read back in the tail variable is set to size; it should actually be
set to size - 1 because otherwise the tail element will be beyond the bounds of the internal
array. Among other things this will cause the iterator to infinitely loop.


Attached is our own local patch...

Thanks!

-TK & Citigroup Analytics Dev team




--- /home/tk53899/tmp/commons-colls/commons-collections-3.1/src/java/org/apache/commons/collections/buffer/UnboundedFifoBuffer.java
  2005-07-13 10:08:12.000000000 -0400
+++ org/apache/commons/collections/buffer/UnboundedFifoBuffer.java      2005-07-13 10:01:56.000000000
-0400
@@ -50,7 +50,7 @@
  * This class is Serializable from Commons Collections 3.1.
  *
  * @since Commons Collections 3.0 (previously in main package v2.1)
- * @version $Revision: 1.9 $ $Date: 2004/06/01 22:57:18 $
+ * @version $Revision: 1.1.2.1 $ $Date: 2005/07/13 14:01:56 $
  *
  * @author Avalon
  * @author Federico Barbieri
@@ -128,7 +128,7 @@
             buffer[i] = in.readObject();
         }
         head = 0;
-        tail = size;
+        tail = size - 1;
     }

     //-----------------------------------------------------------------------

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