Author: mbenson
Date: Wed Aug 25 22:22:55 2010
New Revision: 989390
URL: http://svn.apache.org/viewvc?rev=989390&view=rev
Log:
explain why it is safe to suppress the cast warning on
SerializationUtils.clone()
Modified:
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/SerializationUtils.java
Modified:
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/SerializationUtils.java
URL:
http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/SerializationUtils.java?rev=989390&r1=989389&r2=989390&view=diff
==============================================================================
---
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/SerializationUtils.java
(original)
+++
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/SerializationUtils.java
Wed Aug 25 22:22:55 2010
@@ -77,9 +77,15 @@ public class SerializationUtils {
* @return the cloned object
* @throws SerializationException (runtime) if the serialization fails
*/
- @SuppressWarnings("unchecked")
public static <T extends Serializable> T clone(T object) {
- return (T) deserialize(serialize(object));
+ /*
+ * when we serialize and deserialize an object,
+ * it is reasonable to assume the deserialized object
+ * is of the same type as the original serialized object
+ */
+ @SuppressWarnings("unchecked")
+ final T result = (T) deserialize(serialize(object));
+ return result;
}
// Serialize