From 3e0ab35ba1e7b6544e52ae4e95f80cae4247a498 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sat, 13 Oct 2012 09:39:14 -0600 Subject: [PATCH] fix PersistentSet.remove side-effect bug The whole point of PersistentSet is to provide non-destructive write operations, which means the add and remove methods should have no effect on previous revisions. However, a bug in remove caused shared tree nodes to be modified, corrupting any revisions with which they were shared. --- classpath/avian/PersistentSet.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classpath/avian/PersistentSet.java b/classpath/avian/PersistentSet.java index 5683327aee..917607ed90 100644 --- a/classpath/avian/PersistentSet.java +++ b/classpath/avian/PersistentSet.java @@ -252,7 +252,7 @@ public class PersistentSet implements Iterable { } ancestors.next = new Cell(n, ancestors.next); - sibling = ancestors.value.right; + sibling = ancestors.value.right = new Node(ancestors.value.right); } if (! (sibling.left.red || sibling.right.red)) { @@ -303,7 +303,7 @@ public class PersistentSet implements Iterable { } ancestors.next = new Cell(n, ancestors.next); - sibling = ancestors.value.left; + sibling = ancestors.value.left = new Node(ancestors.value.left); } if (! (sibling.right.red || sibling.left.red)) {