diff --git a/src/main/java/org/apache/commons/lang3/SerializationUtils.java b/src/main/java/org/apache/commons/lang3/SerializationUtils.java index 6b3f58df2..b63725503 100644 --- a/src/main/java/org/apache/commons/lang3/SerializationUtils.java +++ b/src/main/java/org/apache/commons/lang3/SerializationUtils.java @@ -77,9 +77,15 @@ public class SerializationUtils { * @return the cloned object * @throws SerializationException (runtime) if the serialization fails */ - @SuppressWarnings("unchecked") public static 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