From a6fcd70b6047ab56cb3415f378ffc8d72a524a8d Mon Sep 17 00:00:00 2001 From: aleksandar Date: Mon, 23 Jan 2012 18:47:04 +0100 Subject: Fix for SI-5374. Lists are now serialized so that the entire list structure is serialized, including list nodes. This is different from the previous behaviour where only the elements were serialized. List buffers are now optimized so that only the elements of the list are serialized, and not the nodes of the internally maintained list. --- test/files/run/si5374.check | 3 +++ test/files/run/si5374.scala | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 test/files/run/si5374.check create mode 100644 test/files/run/si5374.scala (limited to 'test') diff --git a/test/files/run/si5374.check b/test/files/run/si5374.check new file mode 100644 index 0000000000..cdf0bc7e5b --- /dev/null +++ b/test/files/run/si5374.check @@ -0,0 +1,3 @@ +ListBuffer(1, 2, 3, 1) +ListBuffer(1, 2, 3, 1) +ListBuffer() \ No newline at end of file diff --git a/test/files/run/si5374.scala b/test/files/run/si5374.scala new file mode 100644 index 0000000000..a5678c3a81 --- /dev/null +++ b/test/files/run/si5374.scala @@ -0,0 +1,42 @@ + + + +import collection.mutable.ListBuffer +import java.io._ + + + +object Test { + + def main(args: Array[String]) { + ticketExample() + emptyListBuffer() + } + + def ticketExample() { + val baos = new ByteArrayOutputStream + val oos = new ObjectOutputStream(baos) + oos.writeObject( ListBuffer(1,2,3) ) + val bais = new ByteArrayInputStream( baos.toByteArray ) + val ois = new ObjectInputStream(bais) + val lb = ois.readObject.asInstanceOf[ListBuffer[Int]] + val lb2 = ListBuffer[Int]() ++= lb + + lb2 ++= List(1) + lb ++= List(1) + println(lb) + println(lb2) + } + + def emptyListBuffer() { + val baos = new ByteArrayOutputStream + val oos = new ObjectOutputStream(baos) + oos.writeObject( ListBuffer() ) + val bais = new ByteArrayInputStream( baos.toByteArray ) + val ois = new ObjectInputStream(bais) + val lb = ois.readObject.asInstanceOf[ListBuffer[Int]] + + println(lb) + } + +} -- cgit v1.2.3