Skip to content

Instantly share code, notes, and snippets.

@dlwh
Created March 30, 2012 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlwh/2257703 to your computer and use it in GitHub Desktop.
Save dlwh/2257703 to your computer and use it in GitHub Desktop.
5632 patch
--- a/src/library/scala/collection/mutable/HashTable.scala
+++ b/src/library/scala/collection/mutable/HashTable.scala
@@ -366,7 +366,7 @@ private[collection] object HashTable {
private[collection] final def newThreshold(_loadFactor: Int, size: Int) = ((size.toLong * _loadFactor) / loadFactorDenum).toInt
- private[collection] final def sizeForThreshold(_loadFactor: Int, thr: Int) = thr * loadFactorDenum / _loadFactor
+ private[collection] final def sizeForThreshold(_loadFactor: Int, thr: Int) = ((thr.toLong * loadFactorDenum) / _loadFactor).toInt
private[collection] final def capacity(expectedSize: Int) = if (expectedSize == 0) 1 else powerOfTwo(expectedSize)
import scala.collection.mutable._
import java.io._
object Test extends App {
def test(size: Int) {
val map = new HashMap[Int,AnyRef]()
map ++= (0 until size).view.map( _ -> null)
val bout = new ByteArrayOutputStream()
val oout = new ObjectOutputStream(bout)
oout.writeObject(map)
oout.close()
val in = new ObjectInputStream(new ByteArrayInputStream(bout.toByteArray))
in.readObject()
in.close()
}
// works by default
//test(2147483)
// broken prior to fix with this commit
test(2147484)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment