Author: tn
Date: Sun Feb 24 18:17:27 2013
New Revision: 1449519

URL: http://svn.apache.org/r1449519
Log:
[COLLECTIONS-441] Cleanup MultiKeyMap, remove duplicated field map.

Added:
    
commons/proper/collections/trunk/src/test/resources/data/test/MultiKeyMap.emptyCollection.version4.0.obj
   (with props)
    
commons/proper/collections/trunk/src/test/resources/data/test/MultiKeyMap.fullCollection.version4.0.obj
   (with props)
Removed:
    
commons/proper/collections/trunk/src/test/resources/data/test/MultiKeyMap.emptyCollection.version3.1.obj
    
commons/proper/collections/trunk/src/test/resources/data/test/MultiKeyMap.fullCollection.version3.1.obj
Modified:
    commons/proper/collections/trunk/src/changes/changes.xml
    
commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/MultiKeyMap.java
    
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/MultiKeyMapTest.java

Modified: commons/proper/collections/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/changes/changes.xml?rev=1449519&r1=1449518&r2=1449519&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/changes/changes.xml (original)
+++ commons/proper/collections/trunk/src/changes/changes.xml Sun Feb 24 
18:17:27 2013
@@ -22,6 +22,9 @@
   <body>
 
   <release version="4.0" date="TBA" description="Next release">
+    <action issue="COLLECTIONS-441" dev="tn" type="fix" due-to="Thomas Vahrst">
+      MultiKeyMap.clone() now correctly calls super.clone().
+    </action>
     <action issue="COLLECTIONS-312" dev="tn" type="fix" due-to="Peter Lawrey, 
Gary Gregory">
       Use of final keyword where applicable, minor performance improvements by 
properly
       initializing the capacity of newly created collections when known in 
advance.

Modified: 
commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/MultiKeyMap.java
URL: 
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/MultiKeyMap.java?rev=1449519&r1=1449518&r2=1449519&view=diff
==============================================================================
--- 
commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/MultiKeyMap.java
 (original)
+++ 
commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/MultiKeyMap.java
 Sun Feb 24 18:17:27 2013
@@ -16,6 +16,9 @@
  */
 package org.apache.commons.collections.map;
 
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.io.Serializable;
 import java.util.Map;
 
@@ -78,10 +81,6 @@ public class MultiKeyMap<K, V> extends A
     /** Serialisation version */
     private static final long serialVersionUID = -1788199231038721040L;
 
-    /** The decorated map */
-    //keep this member around for serialization BC with older Collections 
releases assuming we want to do that
-    protected AbstractHashedMap<MultiKey<? extends K>, V> map;
-
     //-----------------------------------------------------------------------
     /**
      * Decorates the specified map to add the MultiKeyMap API and fast query.
@@ -819,9 +818,14 @@ public class MultiKeyMap<K, V> extends A
      *
      * @return a shallow clone
      */
+    @SuppressWarnings("unchecked")
     @Override
     public MultiKeyMap<K, V> clone() {
-        return new MultiKeyMap<K, V>(decorated().clone());
+        try {
+            return (MultiKeyMap<K, V>) super.clone();
+        } catch (CloneNotSupportedException e) {
+            throw new InternalError();
+        }
     }
 
     /**
@@ -867,6 +871,32 @@ public class MultiKeyMap<K, V> extends A
      */
     @Override
     protected AbstractHashedMap<MultiKey<? extends K>, V> decorated() {
-        return map;
+        return (AbstractHashedMap<MultiKey<? extends K>, V>) super.decorated();
+    }
+    
+    //-----------------------------------------------------------------------
+    /**
+     * Write the map out using a custom routine.
+     * 
+     * @param out  the output stream
+     * @throws IOException
+     */
+    private void writeObject(final ObjectOutputStream out) throws IOException {
+        out.defaultWriteObject();
+        out.writeObject(map);
+    }
+
+    /**
+     * Read the map in using a custom routine.
+     * 
+     * @param in  the input stream
+     * @throws IOException
+     * @throws ClassNotFoundException
+     */
+    @SuppressWarnings("unchecked")
+    private void readObject(final ObjectInputStream in) throws IOException, 
ClassNotFoundException {
+        in.defaultReadObject();
+        map = (Map<MultiKey<? extends K>, V>) in.readObject();
     }
+    
 }

Modified: 
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/MultiKeyMapTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/MultiKeyMapTest.java?rev=1449519&r1=1449518&r2=1449519&view=diff
==============================================================================
--- 
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/MultiKeyMapTest.java
 (original)
+++ 
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections/map/MultiKeyMapTest.java
 Sun Feb 24 18:17:27 2013
@@ -441,18 +441,18 @@ public class MultiKeyMapTest<K, V> exten
     //-----------------------------------------------------------------------
     @Override
     public String getCompatibilityVersion() {
-        return "3.1";
+        return "4.0";
     }
 
 //    public void testCreate() throws Exception {
 //        resetEmpty();
 //        writeExternalFormToDisk(
 //            (java.io.Serializable) map,
-//            
"D:/dev/collections/data/test/MultiKeyMap.emptyCollection.version3.1.obj");
+//            
"src/test/resources/data/test/MultiKeyMap.emptyCollection.version4.0.obj");
 //        resetFull();
 //        writeExternalFormToDisk(
 //            (java.io.Serializable) map,
-//            
"D:/dev/collections/data/test/MultiKeyMap.fullCollection.version3.1.obj");
+//            
"src/test/resources/data/test/MultiKeyMap.fullCollection.version4.0.obj");
 //    }
 
     /**

Added: 
commons/proper/collections/trunk/src/test/resources/data/test/MultiKeyMap.emptyCollection.version4.0.obj
URL: 
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/resources/data/test/MultiKeyMap.emptyCollection.version4.0.obj?rev=1449519&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
commons/proper/collections/trunk/src/test/resources/data/test/MultiKeyMap.emptyCollection.version4.0.obj
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: 
commons/proper/collections/trunk/src/test/resources/data/test/MultiKeyMap.fullCollection.version4.0.obj
URL: 
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/resources/data/test/MultiKeyMap.fullCollection.version4.0.obj?rev=1449519&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
commons/proper/collections/trunk/src/test/resources/data/test/MultiKeyMap.fullCollection.version4.0.obj
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream


Reply via email to