commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r989199 - in /commons/proper/lang/trunk/src: main/java/org/apache/commons/lang3/SerializationUtils.java test/java/org/apache/commons/lang3/SerializationUtilsTest.java
Date Wed, 25 Aug 2010 16:15:44 GMT
Author: mbenson
Date: Wed Aug 25 16:15:44 2010
New Revision: 989199

URL: http://svn.apache.org/viewvc?rev=989199&view=rev
Log:
make SerializationUtils.clone() type-safe

Modified:
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/SerializationUtils.java
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.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=989199&r1=989198&r2=989199&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 16:15:44 2010
@@ -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 extends Serializable> T clone(T object) {
+        return (T) deserialize(serialize(object));
     }
     
     // Serialize

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java?rev=989199&r1=989198&r2=989199&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java
Wed Aug 25 16:15:44 2010
@@ -340,7 +340,7 @@ public class SerializationUtilsTest exte
     //-----------------------------------------------------------------------
 
     public void testClone() throws Exception {
-        Object test = SerializationUtils.clone(iMap);
+        HashMap<?, ?> test = SerializationUtils.clone(iMap);
         assertNotNull(test);
         assertTrue(test instanceof HashMap<?,?>);
         assertTrue(test != iMap);



Mime
View raw message