[PATCH] 7164256 : EnumMap.clone doesn't clear the entrySet field, keeping a reference to the original Map

Diego Belfer dbelfer at gmail.com
Mon May 28 19:31:20 UTC 2012


Hi,

The patch seems to have been removed by the mailer. I am adding it inline.

Best,
Diego Belfer
[muralx]


# HG changeset patch
# User muralx
# Date 1338059940 10800
# Node ID 05cb9ae575a6fb4262d46dcd4d4c56c23594cdcb
# Parent  9b8c96f96a0f9a5801b55530a387fefbe50482a3
PATCH 7164256 : EnumMap.clone does not clear the instance field entrySet

diff --git a/src/share/classes/java/util/EnumMap.java
b/src/share/classes/java/util/EnumMap.java
--- a/src/share/classes/java/util/EnumMap.java
+++ b/src/share/classes/java/util/EnumMap.java
@@ -721,6 +721,7 @@
             throw new AssertionError();
         }
         result.vals = result.vals.clone();
+        result.entrySet = null;
         return result;
     }





---------- Forwarded message ----------
From: Diego Belfer <dbelfer at gmail.com>
Date: Sat, May 26, 2012 at 4:30 PM
Subject: [PATCH] 7164256 : EnumMap.clone doesn't clear the entrySet field,
keeping a reference to the original Map
To: core-libs-dev at openjdk.java.net


Hello,

I have reported a bug in the implementation of the clone method of the
EnumMap class.
The instance field entrySet is not being cleared, so the entrySet field of
the new instance references to the original EnumMap.

I am providing a simple patch for review. It adds one line to the clone
method that sets the entrySet field to null.

This is my first contribution to the OpenJDK, so let me know if I am
missing some step of the process.

Thanks,
Diego Belfer
[muralx]


More information about the core-libs-dev mailing list