diff --git a/src/main/java/org/apache/commons/lang3/SerializationUtils.java b/src/main/java/org/apache/commons/lang3/SerializationUtils.java index 34ee5c28c..6b3f58df2 100644 --- a/src/main/java/org/apache/commons/lang3/SerializationUtils.java +++ b/src/main/java/org/apache/commons/lang3/SerializationUtils.java @@ -77,8 +77,9 @@ public class SerializationUtils { * @return the cloned object * @throws SerializationException (runtime) if the serialization fails */ - public static Object clone(Serializable object) { - return deserialize(serialize(object)); + @SuppressWarnings("unchecked") + public static T clone(T object) { + return (T) deserialize(serialize(object)); } // Serialize diff --git a/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java b/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java index 88c431972..215ce261e 100644 --- a/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java @@ -340,7 +340,7 @@ public class SerializationUtilsTest extends TestCase { //----------------------------------------------------------------------- public void testClone() throws Exception { - Object test = SerializationUtils.clone(iMap); + HashMap test = SerializationUtils.clone(iMap); assertNotNull(test); assertTrue(test instanceof HashMap); assertTrue(test != iMap);