diff options
author | Paul Phillips <paulp@improving.org> | 2009-12-10 17:45:17 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-12-10 17:45:17 +0000 |
commit | b9d997e1d94a9c0c6673cd21e708d7ed970747cf (patch) | |
tree | 1506225def6b58a26b965fc0028153622c2ce922 /src | |
parent | 505a7bc4e07cfe6bd3a0972691b31a91856c54f4 (diff) | |
download | scala-b9d997e1d94a9c0c6673cd21e708d7ed970747cf.tar.gz scala-b9d997e1d94a9c0c6673cd21e708d7ed970747cf.tar.bz2 scala-b9d997e1d94a9c0c6673cd21e708d7ed970747cf.zip |
Don't NPE on null hashtable entries.
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/collection/mutable/FlatHashTable.scala | 2 | ||||
-rw-r--r-- | src/library/scala/collection/mutable/HashTable.scala | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/library/scala/collection/mutable/FlatHashTable.scala b/src/library/scala/collection/mutable/FlatHashTable.scala index ab7d8ae51c..422559f089 100644 --- a/src/library/scala/collection/mutable/FlatHashTable.scala +++ b/src/library/scala/collection/mutable/FlatHashTable.scala @@ -187,7 +187,7 @@ trait FlatHashTable[A] { assert(false, i+" "+table(i)+" "+table.toString) } - protected def elemHashCode(elem: A) = elem.hashCode() + protected def elemHashCode(elem: A) = if (elem == null) 0 else elem.hashCode() protected final def improve(hcode: Int) = { var h: Int = hcode + ~(hcode << 9) diff --git a/src/library/scala/collection/mutable/HashTable.scala b/src/library/scala/collection/mutable/HashTable.scala index 5e68e6c656..aa7993ed14 100644 --- a/src/library/scala/collection/mutable/HashTable.scala +++ b/src/library/scala/collection/mutable/HashTable.scala @@ -227,7 +227,7 @@ trait HashTable[A] { protected def elemEquals(key1: A, key2: A): Boolean = (key1 == key2) - protected def elemHashCode(key: A) = key.hashCode() + protected def elemHashCode(key: A) = if (key == null) 0 else key.hashCode() protected final def improve(hcode: Int) = { var h: Int = hcode + ~(hcode << 9) |