From d4b4a8f7bf33bc2020f844d683b529e7fbf6b4bb Mon Sep 17 00:00:00 2001 From: Stephen Colebourne Date: Sat, 20 Sep 2003 14:03:57 +0000 Subject: [PATCH] Fix problem with Serialization and Cursors hidden from original tests. Reported by Rodney git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131170 13f79535-47bb-0310-9956-ffa450edef68 --- .../collections/CursorableLinkedList.java | 21 ++++++++----- .../collections/TestCursorableLinkedList.java | 31 ++++++++++++++++--- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/src/java/org/apache/commons/collections/CursorableLinkedList.java b/src/java/org/apache/commons/collections/CursorableLinkedList.java index a60e7eba3..035cca4e1 100644 --- a/src/java/org/apache/commons/collections/CursorableLinkedList.java +++ b/src/java/org/apache/commons/collections/CursorableLinkedList.java @@ -1,5 +1,5 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/CursorableLinkedList.java,v 1.16 2003/08/31 17:26:43 scolebourne Exp $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/CursorableLinkedList.java,v 1.17 2003/09/20 14:03:57 scolebourne Exp $ * ==================================================================== * * The Apache Software License, Version 1.1 @@ -84,13 +84,16 @@ import java.util.NoSuchElementException; * * @see java.util.LinkedList * @since Commons Collections 1.0 - * @version $Revision: 1.16 $ $Date: 2003/08/31 17:26:43 $ + * @version $Revision: 1.17 $ $Date: 2003/09/20 14:03:57 $ * * @author Rodney Waldhoff * @author Janek Bogucki */ public class CursorableLinkedList implements List, Serializable { // TODO: use weak references to cursors in case they aren't closed directly + + /** Ensure serialization compatability */ + private static final long serialVersionUID = 8836393098519411393L; //--- public methods --------------------------------------------- @@ -897,7 +900,7 @@ public class CursorableLinkedList implements List, Serializable { out.defaultWriteObject(); out.writeInt(_size); Listable cur = _head.next(); - while(cur != null) { + while (cur != null) { out.writeObject(cur.value()); cur = cur.next(); } @@ -906,9 +909,11 @@ public class CursorableLinkedList implements List, Serializable { private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); _size = 0; + _modCount = 0; + _cursors = new ArrayList(); _head = new Listable(null,null,null); int size = in.readInt(); - for(int i=0;i