TimurMahammadov / google-collections

Automatically exported from code.google.com/p/google-collections
Apache License 2.0
0 stars 0 forks source link

Static factory methods can return non-serializable predicates #94

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello

Some of the static factory methods, for instance Predicates.isEqualTo(),
can return non-serializable predicates when called with a parameter that
doesn't implement Serializable. 

Example:
---------------------------------------------------------
Object predicateObj = Predicates.isEqualTo(new Object());
ObjectOutput objectOut = new ObjectOutputStream(new
FileOutputStream("predicate.ser"));
objectOut.writeObject(predicateObj);

Exception in thread "main" java.io.NotSerializableException: java.lang.Object
---------------------------------------------------------

In my opinion this should at least be mentioned in the javadocs...

Bye, Thomas

Original issue reported on code.google.com by marti...@gmail.com on 21 Aug 2008 at 4:51

GoogleCodeExporter commented 9 years ago
Thanks for pointing this out.

I'll keep the current behavior of returning instances that aren't serializable 
but
satisfy the Serializable interface. However, documenting that behavior is a good
idea. That approach is consistent with JDK methods like
Collections.unmodifiableCollection().

Original comment by jared.l....@gmail.com on 21 Aug 2008 at 6:17

GoogleCodeExporter commented 9 years ago
The factory method Javadoc now explains when the generated instances are 
serializable.

Original comment by jared.l....@gmail.com on 12 Sep 2008 at 5:48