diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-02-14 13:24:05 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-02-14 13:24:05 -0800 |
commit | e86675f582ed8fef880f71744241f30e0d57a51c (patch) | |
tree | ad457f11f19c6487ced06dc7dedda58d538cebe9 /test/files | |
parent | d62ceb88278bbe8317e8dcce6fb8515cae64e2b1 (diff) | |
parent | a4a13199d0811d01cb008804ae34c594abdc415e (diff) | |
download | scala-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/files')
-rw-r--r-- | test/files/run/t8188.scala | 25 |
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 ) + } +} |