Skip to content

Commit 439ccfd

Browse files
committed
fix TreeSet/TreeMap serialisation
add SerialVersionUID to Set and Map proxy regenerate and record(int he test) the existing 2.12 serial format for TreeMap and TreeSet
1 parent 9da87e6 commit 439ccfd

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

library/src/scala/collection/immutable/TreeMap.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ object TreeMap extends ImmutableSortedMapFactory[TreeMap] {
8585

8686
override def result(): TreeMap[A, B] = new TreeMap[A, B](beforePublish(tree))
8787
}
88-
private val legacySerialisation = System.getProperty("scala.collection.immutable.TreeMap.newSerialisation", "false") != "false"
88+
private val legacySerialisation = System.getProperty("scala.collection.immutable.TreeMap.newSerialisation", "false") == "false"
8989

90+
@SerialVersionUID(-5672253444750945796L)
9091
private class TreeMapProxy[A, B](
9192
@transient private[this] var tree: RB.Tree[A, B],
9293
@transient private[this] var ordering: Ordering[A]) extends Serializable {
@@ -381,7 +382,7 @@ final class TreeMap[A, +B] private (tree: RB.Tree[A, B])(implicit val ordering:
381382
}
382383

383384
@throws[IOException]
384-
private[this] def writeReplace(out: java.io.ObjectOutputStream): AnyRef =
385+
private[this] def writeReplace(): AnyRef =
385386
if (TreeMap.legacySerialisation) this else new TreeMap.TreeMapProxy(tree, ordering)
386387

387388
@throws[IOException]

library/src/scala/collection/immutable/TreeSet.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ object TreeSet extends ImmutableSortedSetFactory[TreeSet] {
6767

6868
override def result(): TreeSet[A] = new TreeSet[A](beforePublish(tree))(ordering)
6969
}
70-
private val legacySerialisation = System.getProperty("scala.collection.immutable.TreeSet.newSerialisation", "false") != "false"
70+
private val legacySerialisation = System.getProperty("scala.collection.immutable.TreeSet.newSerialisation", "false") == "false"
7171

72+
@SerialVersionUID(-8462554036344260506L)
7273
private class TreeSetProxy[A](
7374
@transient private[this] var tree: RB.Tree[A, Any],
7475
@transient private[this] var ordering: Ordering[A]) extends Serializable {
@@ -292,7 +293,7 @@ final class TreeSet[A] private[immutable] (private[immutable] val tree: RB.Tree[
292293
}
293294

294295
@throws[IOException]
295-
private[this] def writeReplace(out: java.io.ObjectOutputStream): AnyRef =
296+
private[this] def writeReplace(): AnyRef =
296297
if (TreeSet.legacySerialisation) this else new TreeSet.TreeSetProxy(tree, ordering)
297298

298299
@throws[IOException]

0 commit comments

Comments
 (0)