summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2014-02-14 13:24:05 -0800
committerAdriaan Moors <adriaan.moors@typesafe.com>2014-02-14 13:24:05 -0800
commite86675f582ed8fef880f71744241f30e0d57a51c (patch)
treead457f11f19c6487ced06dc7dedda58d538cebe9 /test
parentd62ceb88278bbe8317e8dcce6fb8515cae64e2b1 (diff)
parenta4a13199d0811d01cb008804ae34c594abdc415e (diff)
downloadscala-e86675f582ed8fef880f71744241f30e0d57a51c.tar.gz
scala-e86675f582ed8fef880f71744241f30e0d57a51c.tar.bz2
scala-e86675f582ed8fef880f71744241f30e0d57a51c.zip
Merge pull request #3531 from Ichoran/issue/8188
SI-8188 NPE during deserialization of TrieMap
Diffstat (limited to 'test')
-rw-r--r--test/files/run/t8188.scala25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/files/run/t8188.scala b/test/files/run/t8188.scala
new file mode 100644
index 0000000000..ec3a968e4a
--- /dev/null
+++ b/test/files/run/t8188.scala
@@ -0,0 +1,25 @@
+object Test {
+ def main(args: Array[String]) {
+ import java.io.ByteArrayInputStream
+ import java.io.ByteArrayOutputStream
+ import java.io.ObjectInputStream
+ import java.io.ObjectOutputStream
+ import scala.collection.concurrent.TrieMap
+
+ def ser[T](o: T): Array[Byte] = {
+ val baos = new ByteArrayOutputStream()
+ new ObjectOutputStream(baos).writeObject(o)
+ baos.toByteArray()
+ }
+
+ def deser[T](bs: Array[Byte]): T =
+ new ObjectInputStream(new ByteArrayInputStream(bs)).readObject().asInstanceOf[T]
+
+ def cloneViaSerialization[T](t: T): T = deser(ser(t))
+
+ val f = cloneViaSerialization(_: TrieMap[Int, Int])
+ val tm = TrieMap(1 -> 2)
+ assert( f(f(tm)) == tm )
+ assert( ser(tm).length == ser(f(tm)).length )
+ }
+}