diff options
author | Paul Phillips <paulp@improving.org> | 2012-11-23 19:40:44 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-11-23 19:51:03 -0800 |
commit | d0de367e72ba695777cfec31d796f5972ae18601 (patch) | |
tree | dfd9c008124b086c6ff938a8bccab712728ddf1b /src/library | |
parent | 5b498a2612f967c944fa1ed4f63a09d6acc41791 (diff) | |
download | scala-d0de367e72ba695777cfec31d796f5972ae18601.tar.gz scala-d0de367e72ba695777cfec31d796f5972ae18601.tar.bz2 scala-d0de367e72ba695777cfec31d796f5972ae18601.zip |
Fix for SI-6706, Symbol breakage under GC.
Ensure the map key and the String in the Symbol are the
same reference by removing the old key before updating the
map with the new key -> symbol relation.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/Symbol.scala | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/library/scala/Symbol.scala b/src/library/scala/Symbol.scala index 723c05a30c..4fead7a50c 100644 --- a/src/library/scala/Symbol.scala +++ b/src/library/scala/Symbol.scala @@ -69,6 +69,11 @@ private[scala] abstract class UniquenessCache[K, V >: Null] val res = cached() if (res != null) res else { + // If we don't remove the old String key from the map, we can + // wind up with one String as the key and a different String as + // as the name field in the Symbol, which can lead to surprising + // GC behavior and duplicate Symbols. See SI-6706. + map remove name val sym = valueFromKey(name) map.put(name, new WeakReference(sym)) sym |