Created
March 30, 2012 23:17
-
-
Save dlwh/2257703 to your computer and use it in GitHub Desktop.
5632 patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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