491955
diff --git a/src/java/org/apache/commons/collections/functors/CloneTransformer.java b/src/java/org/apache/commons/collections/functors/CloneTransformer.java
491955
index 7200402..3df18ff 100644
491955
--- a/src/java/org/apache/commons/collections/functors/CloneTransformer.java
491955
+++ b/src/java/org/apache/commons/collections/functors/CloneTransformer.java
491955
@@ -16,6 +16,9 @@
491955
  */
491955
 package org.apache.commons.collections.functors;
491955
 
491955
+import java.io.IOException;
491955
+import java.io.ObjectInputStream;
491955
+import java.io.ObjectOutputStream;
491955
 import java.io.Serializable;
491955
 
491955
 import org.apache.commons.collections.Transformer;
491955
@@ -24,6 +27,16 @@ import org.apache.commons.collections.Transformer;
491955
  * Transformer implementation that returns a clone of the input object.
491955
  * 

491955
  * Clone is performed using PrototypeFactory.getInstance(input).create().
491955
+ * 

491955
+ * WARNING: This class will throw an
491955
+ * {@link UnsupportedOperationException} when trying to serialize or
491955
+ * de-serialize an instance to prevent potential remote code execution exploits.
491955
+ * 

491955
+ * In order to re-enable serialization support for {@code CloneTransformer}
491955
+ * the following system property can be used (via -Dproperty=true):
491955
+ * 
491955
+ * org.apache.commons.collections.enableUnsafeSerialization
491955
+ * 
491955
  * 
491955
  * @since Commons Collections 3.0
491955
  * @version $Revision: 646777 $ $Date: 2008-04-10 13:33:15 +0100 (Thu, 10 Apr 2008) $
491955
@@ -68,4 +81,21 @@ public class CloneTransformer implements Transformer, Serializable {
491955
         return PrototypeFactory.getInstance(input).create();
491955
     }
491955
 
491955
+    /**
491955
+     * Overrides the default writeObject implementation to prevent
491955
+     * serialization (see COLLECTIONS-580).
491955
+     */
491955
+    private void writeObject(ObjectOutputStream os) throws IOException {
491955
+        FunctorUtils.checkUnsafeSerialization(CloneTransformer.class);
491955
+        os.defaultWriteObject();
491955
+    }
491955
+
491955
+    /**
491955
+     * Overrides the default readObject implementation to prevent
491955
+     * de-serialization (see COLLECTIONS-580).
491955
+     */
491955
+    private void readObject(ObjectInputStream is) throws ClassNotFoundException, IOException {
491955
+        FunctorUtils.checkUnsafeSerialization(CloneTransformer.class);
491955
+        is.defaultReadObject();
491955
+    }
491955
 }
491955
diff --git a/src/java/org/apache/commons/collections/functors/ForClosure.java b/src/java/org/apache/commons/collections/functors/ForClosure.java
491955
index f0355c4..e15475c 100644
491955
--- a/src/java/org/apache/commons/collections/functors/ForClosure.java
491955
+++ b/src/java/org/apache/commons/collections/functors/ForClosure.java
491955
@@ -16,12 +16,25 @@
491955
  */
491955
 package org.apache.commons.collections.functors;
491955
 
491955
+import java.io.IOException;
491955
+import java.io.ObjectInputStream;
491955
+import java.io.ObjectOutputStream;
491955
 import java.io.Serializable;
491955
 
491955
 import org.apache.commons.collections.Closure;
491955
 
491955
 /**
491955
  * Closure implementation that calls another closure n times, like a for loop.
491955
+ * 

491955
+ * WARNING: This class will throw an
491955
+ * {@link UnsupportedOperationException} when trying to serialize or
491955
+ * de-serialize an instance to prevent potential remote code execution exploits.
491955
+ * 

491955
+ * In order to re-enable serialization support for {@code ForClosure}
491955
+ * the following system property can be used (via -Dproperty=true):
491955
+ * 
491955
+ * org.apache.commons.collections.enableUnsafeSerialization
491955
+ * 
491955
  * 
491955
  * @since Commons Collections 3.0
491955
  * @version $Revision: 646777 $ $Date: 2008-04-10 13:33:15 +0100 (Thu, 10 Apr 2008) $
491955
@@ -102,4 +115,22 @@ public class ForClosure implements Closure, Serializable {
491955
         return iCount;
491955
     }
491955
 
491955
+    /**
491955
+     * Overrides the default writeObject implementation to prevent
491955
+     * serialization (see COLLECTIONS-580).
491955
+     */
491955
+    private void writeObject(ObjectOutputStream os) throws IOException {
491955
+        FunctorUtils.checkUnsafeSerialization(ForClosure.class);
491955
+        os.defaultWriteObject();
491955
+    }
491955
+
491955
+    /**
491955
+     * Overrides the default readObject implementation to prevent
491955
+     * de-serialization (see COLLECTIONS-580).
491955
+     */
491955
+    private void readObject(ObjectInputStream is) throws ClassNotFoundException, IOException {
491955
+        FunctorUtils.checkUnsafeSerialization(ForClosure.class);
491955
+        is.defaultReadObject();
491955
+    }
491955
+
491955
 }
491955
diff --git a/src/java/org/apache/commons/collections/functors/FunctorUtils.java b/src/java/org/apache/commons/collections/functors/FunctorUtils.java
491955
index 75f8d9b..aa7bec3 100644
491955
--- a/src/java/org/apache/commons/collections/functors/FunctorUtils.java
491955
+++ b/src/java/org/apache/commons/collections/functors/FunctorUtils.java
491955
@@ -16,6 +16,8 @@
491955
  */
491955
 package org.apache.commons.collections.functors;
491955
 
491955
+import java.security.AccessController;
491955
+import java.security.PrivilegedAction;
491955
 import java.util.Collection;
491955
 import java.util.Iterator;
491955
 
491955
@@ -33,7 +35,11 @@ import org.apache.commons.collections.Transformer;
491955
  * @author Matt Benson
491955
  */
491955
 class FunctorUtils {
491955
-    
491955
+
491955
+    /** System property key to enable unsafe serialization */
491955
+    final static String UNSAFE_SERIALIZABLE_PROPERTY
491955
+        = "org.apache.commons.collections.enableUnsafeSerialization";
491955
+
491955
     /**
491955
      * Restricted constructor.
491955
      */
491955
@@ -152,4 +158,33 @@ class FunctorUtils {
491955
         }
491955
     }
491955
 
491955
+    /**
491955
+     * Package-private helper method to check if serialization support is
491955
+     * enabled for unsafe classes.
491955
+     *
491955
+     * @param clazz  the clazz to check for serialization support
491955
+     * @throws UnsupportedOperationException if unsafe serialization is disabled
491955
+     */
491955
+    static void checkUnsafeSerialization(Class clazz) {
491955
+        String unsafeSerializableProperty;
491955
+
491955
+        try {
491955
+            unsafeSerializableProperty = 
491955
+                (String) AccessController.doPrivileged(new PrivilegedAction() {
491955
+                    public Object run() {
491955
+                        return System.getProperty(UNSAFE_SERIALIZABLE_PROPERTY);
491955
+                    }
491955
+                });
491955
+        } catch (SecurityException ex) {
491955
+            unsafeSerializableProperty = null;
491955
+        }
491955
+
491955
+        if (!"true".equalsIgnoreCase(unsafeSerializableProperty)) {
491955
+            throw new UnsupportedOperationException(
491955
+                    "Serialization support for " + clazz.getName() + " is disabled for security reasons. " +
491955
+                    "To enable it set system property '" + UNSAFE_SERIALIZABLE_PROPERTY + "' to 'true', " +
491955
+                    "but you must ensure that your application does not de-serialize objects from untrusted sources.");
491955
+        }
491955
+    }
491955
+
491955
 }
491955
diff --git a/src/java/org/apache/commons/collections/functors/InstantiateFactory.java b/src/java/org/apache/commons/collections/functors/InstantiateFactory.java
491955
index 5d375de..938d6dc 100644
491955
--- a/src/java/org/apache/commons/collections/functors/InstantiateFactory.java
491955
+++ b/src/java/org/apache/commons/collections/functors/InstantiateFactory.java
491955
@@ -16,6 +16,9 @@
491955
  */
491955
 package org.apache.commons.collections.functors;
491955
 
491955
+import java.io.IOException;
491955
+import java.io.ObjectInputStream;
491955
+import java.io.ObjectOutputStream;
491955
 import java.io.Serializable;
491955
 import java.lang.reflect.Constructor;
491955
 import java.lang.reflect.InvocationTargetException;
491955
@@ -25,6 +28,16 @@ import org.apache.commons.collections.FunctorException;
491955
 
491955
 /**
491955
  * Factory implementation that creates a new object instance by reflection.
491955
+ * 

491955
+ * WARNING: This class will throw an
491955
+ * {@link UnsupportedOperationException} when trying to serialize or
491955
+ * de-serialize an instance to prevent potential remote code execution exploits.
491955
+ * 

491955
+ * In order to re-enable serialization support for {@code InstantiateTransformer}
491955
+ * the following system property can be used (via -Dproperty=true):
491955
+ * 
491955
+ * org.apache.commons.collections.enableUnsafeSerialization
491955
+ * 
491955
  * 
491955
  * @since Commons Collections 3.0
491955
  * @version $Revision: 646777 $ $Date: 2008-04-10 13:33:15 +0100 (Thu, 10 Apr 2008) $
491955
@@ -136,5 +149,22 @@ public class InstantiateFactory implements Factory, Serializable {
491955
             throw new FunctorException("InstantiateFactory: Constructor threw an exception", ex);
491955
         }
491955
     }
491955
-    
491955
+
491955
+    /**
491955
+     * Overrides the default writeObject implementation to prevent
491955
+     * serialization (see COLLECTIONS-580).
491955
+     */
491955
+    private void writeObject(ObjectOutputStream os) throws IOException {
491955
+        FunctorUtils.checkUnsafeSerialization(InstantiateFactory.class);
491955
+        os.defaultWriteObject();
491955
+    }
491955
+
491955
+    /**
491955
+     * Overrides the default readObject implementation to prevent
491955
+     * de-serialization (see COLLECTIONS-580).
491955
+     */
491955
+    private void readObject(ObjectInputStream is) throws ClassNotFoundException, IOException {
491955
+        FunctorUtils.checkUnsafeSerialization(InstantiateFactory.class);
491955
+        is.defaultReadObject();
491955
+    }
491955
 }
491955
diff --git a/src/java/org/apache/commons/collections/functors/InstantiateTransformer.java b/src/java/org/apache/commons/collections/functors/InstantiateTransformer.java
491955
index 73d6b2f..4927f05 100644
491955
--- a/src/java/org/apache/commons/collections/functors/InstantiateTransformer.java
491955
+++ b/src/java/org/apache/commons/collections/functors/InstantiateTransformer.java
491955
@@ -16,6 +16,9 @@
491955
  */
491955
 package org.apache.commons.collections.functors;
491955
 
491955
+import java.io.IOException;
491955
+import java.io.ObjectInputStream;
491955
+import java.io.ObjectOutputStream;
491955
 import java.io.Serializable;
491955
 import java.lang.reflect.Constructor;
491955
 import java.lang.reflect.InvocationTargetException;
491955
@@ -25,6 +28,16 @@ import org.apache.commons.collections.Transformer;
491955
 
491955
 /**
491955
  * Transformer implementation that creates a new object instance by reflection.
491955
+ * 

491955
+ * WARNING: This class will throw an
491955
+ * {@link UnsupportedOperationException} when trying to serialize or
491955
+ * de-serialize an instance to prevent potential remote code execution exploits.
491955
+ * 

491955
+ * In order to re-enable serialization support for {@code InstantiateTransformer}
491955
+ * the following system property can be used (via -Dproperty=true):
491955
+ * 
491955
+ * org.apache.commons.collections.enableUnsafeSerialization
491955
+ * 
491955
  * 
491955
  * @since Commons Collections 3.0
491955
  * @version $Revision: 646777 $ $Date: 2008-04-10 13:33:15 +0100 (Thu, 10 Apr 2008) $
491955
@@ -116,4 +129,22 @@ public class InstantiateTransformer implements Transformer, Serializable {
491955
         }
491955
     }
491955
 
491955
+    /**
491955
+     * Overrides the default writeObject implementation to prevent
491955
+     * serialization (see COLLECTIONS-580).
491955
+     */
491955
+    private void writeObject(ObjectOutputStream os) throws IOException {
491955
+        FunctorUtils.checkUnsafeSerialization(InstantiateTransformer.class);
491955
+        os.defaultWriteObject();
491955
+    }
491955
+
491955
+    /**
491955
+     * Overrides the default readObject implementation to prevent
491955
+     * de-serialization (see COLLECTIONS-580).
491955
+     */
491955
+    private void readObject(ObjectInputStream is) throws ClassNotFoundException, IOException {
491955
+        FunctorUtils.checkUnsafeSerialization(InstantiateTransformer.class);
491955
+        is.defaultReadObject();
491955
+    }
491955
+
491955
 }
491955
diff --git a/src/java/org/apache/commons/collections/functors/InvokerTransformer.java b/src/java/org/apache/commons/collections/functors/InvokerTransformer.java
491955
index 6f60961..75f48af 100644
491955
--- a/src/java/org/apache/commons/collections/functors/InvokerTransformer.java
491955
+++ b/src/java/org/apache/commons/collections/functors/InvokerTransformer.java
491955
@@ -16,6 +16,9 @@
491955
  */
491955
 package org.apache.commons.collections.functors;
491955
 
491955
+import java.io.IOException;
491955
+import java.io.ObjectInputStream;
491955
+import java.io.ObjectOutputStream;
491955
 import java.io.Serializable;
491955
 import java.lang.reflect.InvocationTargetException;
491955
 import java.lang.reflect.Method;
491955
@@ -25,6 +28,16 @@ import org.apache.commons.collections.Transformer;
491955
 
491955
 /**
491955
  * Transformer implementation that creates a new object instance by reflection.
491955
+ * 

491955
+ * WARNING: This class will throw an
491955
+ * {@link UnsupportedOperationException} when trying to serialize or
491955
+ * de-serialize an instance to prevent potential remote code execution exploits.
491955
+ * 

491955
+ * In order to re-enable serialization support for {@code InvokerTransformer}
491955
+ * the following system property can be used (via -Dproperty=true):
491955
+ * 
491955
+ * org.apache.commons.collections.enableUnsafeSerialization
491955
+ * 
491955
  * 
491955
  * @since Commons Collections 3.0
491955
  * @version $Revision: 646777 $ $Date: 2008-04-10 13:33:15 +0100 (Thu, 10 Apr 2008) $
491955
@@ -134,4 +147,21 @@ public class InvokerTransformer implements Transformer, Serializable {
491955
         }
491955
     }
491955
 
491955
+    /**
491955
+     * Overrides the default writeObject implementation to prevent
491955
+     * serialization (see COLLECTIONS-580).
491955
+     */
491955
+    private void writeObject(ObjectOutputStream os) throws IOException {
491955
+        FunctorUtils.checkUnsafeSerialization(InvokerTransformer.class);
491955
+        os.defaultWriteObject();
491955
+    }
491955
+
491955
+    /**
491955
+     * Overrides the default readObject implementation to prevent
491955
+     * de-serialization (see COLLECTIONS-580).
491955
+     */
491955
+    private void readObject(ObjectInputStream is) throws ClassNotFoundException, IOException {
491955
+        FunctorUtils.checkUnsafeSerialization(InvokerTransformer.class);
491955
+        is.defaultReadObject();
491955
+    }
491955
 }
491955
diff --git a/src/java/org/apache/commons/collections/functors/PrototypeFactory.java b/src/java/org/apache/commons/collections/functors/PrototypeFactory.java
491955
index 4fa4150..d9908fa 100644
491955
--- a/src/java/org/apache/commons/collections/functors/PrototypeFactory.java
491955
+++ b/src/java/org/apache/commons/collections/functors/PrototypeFactory.java
491955
@@ -49,6 +49,16 @@ public class PrototypeFactory {
491955
      * 
  • public copy constructor
  • 491955
          * 
  • serialization clone
  • 491955
          * 
    491955
    +     * 

    491955
    +     * WARNING: This method will return a {@code Factory}
    
    491955
    +     * that will throw an {@link UnsupportedOperationException} when trying to serialize
    
    491955
    +     * or de-serialize it to prevent potential remote code execution exploits.
    
    491955
    +     * 

    491955
    +     * In order to re-enable serialization support the following system property
    
    491955
    +     * can be used (via -Dproperty=true):
    
    491955
    +     * 
    491955
    +     * org.apache.commons.collections.enableUnsafeSerialization
    
    491955
    +     * 
    
    491955
          *
    
    491955
          * @param prototype  the object to clone each time in the factory
    
    491955
          * @return the prototype factory
    
    491955
    @@ -144,6 +154,24 @@ public class PrototypeFactory {
    491955
                     throw new FunctorException("PrototypeCloneFactory: Clone method threw an exception", ex);
    
    491955
                 }
    
    491955
             }
    
    491955
    +
    
    491955
    +        /**
    
    491955
    +         * Overrides the default writeObject implementation to prevent
    
    491955
    +         * serialization (see COLLECTIONS-580).
    
    491955
    +         */
    
    491955
    +        private void writeObject(ObjectOutputStream os) throws IOException {
    
    491955
    +            FunctorUtils.checkUnsafeSerialization(PrototypeCloneFactory.class);
    
    491955
    +            os.defaultWriteObject();
    
    491955
    +        }
    
    491955
    +
    
    491955
    +        /**
    
    491955
    +         * Overrides the default readObject implementation to prevent
    
    491955
    +         * de-serialization (see COLLECTIONS-580).
    
    491955
    +         */
    
    491955
    +        private void readObject(ObjectInputStream is) throws ClassNotFoundException, IOException {
    
    491955
    +            FunctorUtils.checkUnsafeSerialization(PrototypeCloneFactory.class);
    
    491955
    +            is.defaultReadObject();
    
    491955
    +        }
    
    491955
         }
    
    491955
     
    
    491955
         // PrototypeSerializationFactory
    
    491955
    @@ -204,6 +232,24 @@ public class PrototypeFactory {
    491955
                     }
    
    491955
                 }
    
    491955
             }
    
    491955
    +
    
    491955
    +        /**
    
    491955
    +         * Overrides the default writeObject implementation to prevent
    
    491955
    +         * serialization (see COLLECTIONS-580).
    
    491955
    +         */
    
    491955
    +        private void writeObject(ObjectOutputStream os) throws IOException {
    
    491955
    +            FunctorUtils.checkUnsafeSerialization(PrototypeSerializationFactory.class);
    
    491955
    +            os.defaultWriteObject();
    
    491955
    +        }
    
    491955
    +
    
    491955
    +        /**
    
    491955
    +         * Overrides the default readObject implementation to prevent
    
    491955
    +         * de-serialization (see COLLECTIONS-580).
    
    491955
    +         */
    
    491955
    +        private void readObject(ObjectInputStream is) throws ClassNotFoundException, IOException {
    
    491955
    +            FunctorUtils.checkUnsafeSerialization(PrototypeSerializationFactory.class);
    
    491955
    +            is.defaultReadObject();
    
    491955
    +        }
    
    491955
         }
    
    491955
     
    
    491955
     }
    
    491955
    diff --git a/src/java/org/apache/commons/collections/functors/WhileClosure.java b/src/java/org/apache/commons/collections/functors/WhileClosure.java
    491955
    index 853e83a..596afc8 100644
    491955
    --- a/src/java/org/apache/commons/collections/functors/WhileClosure.java
    491955
    +++ b/src/java/org/apache/commons/collections/functors/WhileClosure.java
    491955
    @@ -16,6 +16,9 @@
    491955
      */
    
    491955
     package org.apache.commons.collections.functors;
    
    491955
     
    
    491955
    +import java.io.IOException;
    
    491955
    +import java.io.ObjectInputStream;
    
    491955
    +import java.io.ObjectOutputStream;
    
    491955
     import java.io.Serializable;
    
    491955
     
    
    491955
     import org.apache.commons.collections.Closure;
    
    491955
    @@ -24,6 +27,16 @@ import org.apache.commons.collections.Predicate;
    491955
     /**
    
    491955
      * Closure implementation that executes a closure repeatedly until a condition is met,
    
    491955
      * like a do-while or while loop.
    
    491955
    + * 

    491955
    + * WARNING: This class will throw an
    
    491955
    + * {@link UnsupportedOperationException} when trying to serialize or
    
    491955
    + * de-serialize an instance to prevent potential remote code execution exploits.
    
    491955
    + * 

    491955
    + * In order to re-enable serialization support for {@code WhileClosure}
    
    491955
    + * the following system property can be used (via -Dproperty=true):
    
    491955
    + * 
    491955
    + * org.apache.commons.collections.enableUnsafeSerialization
    
    491955
    + * 
    
    491955
      * 
    
    491955
      * @since Commons Collections 3.0
    
    491955
      * @version $Revision: 646777 $ $Date: 2008-04-10 13:33:15 +0100 (Thu, 10 Apr 2008) $
    
    491955
    @@ -120,4 +133,22 @@ public class WhileClosure implements Closure, Serializable {
    491955
             return iDoLoop;
    
    491955
         }
    
    491955
     
    
    491955
    +    /**
    
    491955
    +     * Overrides the default writeObject implementation to prevent
    
    491955
    +     * serialization (see COLLECTIONS-580).
    
    491955
    +     */
    
    491955
    +    private void writeObject(ObjectOutputStream os) throws IOException {
    
    491955
    +        FunctorUtils.checkUnsafeSerialization(WhileClosure.class);
    
    491955
    +        os.defaultWriteObject();
    
    491955
    +    }
    
    491955
    +
    
    491955
    +    /**
    
    491955
    +     * Overrides the default readObject implementation to prevent
    
    491955
    +     * de-serialization (see COLLECTIONS-580).
    
    491955
    +     */
    
    491955
    +    private void readObject(ObjectInputStream is) throws ClassNotFoundException, IOException {
    
    491955
    +        FunctorUtils.checkUnsafeSerialization(WhileClosure.class);
    
    491955
    +        is.defaultReadObject();
    
    491955
    +    }
    
    491955
    +
    
    491955
     }
    
    491955
    diff --git a/src/test/org/apache/commons/collections/TestFactoryUtils.java b/src/test/org/apache/commons/collections/TestFactoryUtils.java
    491955
    index 0895903..bc7d729 100644
    491955
    --- a/src/test/org/apache/commons/collections/TestFactoryUtils.java
    491955
    +++ b/src/test/org/apache/commons/collections/TestFactoryUtils.java
    491955
    @@ -136,15 +136,6 @@ public class TestFactoryUtils extends junit.framework.TestCase {
    491955
             Object created = factory.create();
    
    491955
             assertTrue(proto != created);
    
    491955
             assertEquals(proto, created);
    
    491955
    -        
    
    491955
    -        // check serialisation works
    
    491955
    -        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    
    491955
    -        ObjectOutputStream out = new ObjectOutputStream(buffer);
    
    491955
    -        out.writeObject(factory);
    
    491955
    -        out.close();
    
    491955
    -        ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    
    491955
    -        Object dest = in.readObject();
    
    491955
    -        in.close();
    
    491955
         }
    
    491955
     
    
    491955
         public void testPrototypeFactoryPublicCopyConstructor() throws Exception {
    
    491955
    @@ -154,23 +145,6 @@ public class TestFactoryUtils extends junit.framework.TestCase {
    491955
             Object created = factory.create();
    
    491955
             assertTrue(proto != created);
    
    491955
             assertEquals(proto, created);
    
    491955
    -        
    
    491955
    -        // check serialisation works
    
    491955
    -        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    
    491955
    -        ObjectOutputStream out = new ObjectOutputStream(buffer);
    
    491955
    -        try {
    
    491955
    -            out.writeObject(factory);
    
    491955
    -        } catch (NotSerializableException ex) {
    
    491955
    -            out.close();
    
    491955
    -        }
    
    491955
    -        factory = FactoryUtils.prototypeFactory(new Mock2("S"));
    
    491955
    -        buffer = new ByteArrayOutputStream();
    
    491955
    -        out = new ObjectOutputStream(buffer);
    
    491955
    -        out.writeObject(factory);
    
    491955
    -        out.close();
    
    491955
    -        ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    
    491955
    -        Object dest = in.readObject();
    
    491955
    -        in.close();
    
    491955
         }
    
    491955
     
    
    491955
         public void testPrototypeFactoryPublicSerialization() throws Exception {
    
    491955
    @@ -180,15 +154,6 @@ public class TestFactoryUtils extends junit.framework.TestCase {
    491955
             Object created = factory.create();
    
    491955
             assertTrue(proto != created);
    
    491955
             assertEquals(proto, created);
    
    491955
    -        
    
    491955
    -        // check serialisation works
    
    491955
    -        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    
    491955
    -        ObjectOutputStream out = new ObjectOutputStream(buffer);
    
    491955
    -        out.writeObject(factory);
    
    491955
    -        out.close();
    
    491955
    -        ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
    
    491955
    -        Object dest = in.readObject();
    
    491955
    -        in.close();
    
    491955
         }
    
    491955
     
    
    491955
         public void testPrototypeFactoryPublicSerializationError() {