mirror of
https://github.com/corda/corda.git
synced 2025-01-04 04:04:27 +00:00
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.
This commit is contained in:
parent
a3c4b60f43
commit
3e0ab35ba1
@ -252,7 +252,7 @@ public class PersistentSet <T> implements Iterable <T> {
|
||||
}
|
||||
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 <T> implements Iterable <T> {
|
||||
}
|
||||
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)) {
|
||||
|
Loading…
Reference in New Issue
Block a user