nbronson / snaptree

Concurrent TreeMap w/ efficient support for clone() and consistent iteration
Other
148 stars 30 forks source link

When cloning, the COWEpoch is not created in the right enclosing object #1

Closed pcmanus closed 13 years ago

pcmanus commented 13 years ago

COWEpoch are inner object. When a CopyOnWriteManager is cloned, the new COWEpoch for the clone is created by the initial object rather than the clone. I believe this is wrong, and leads to problem when later the COWEpoch affects _active (in onClosed), affecting the original object rather than the clone.

The commit includes a small unit test demonstrating the bug (I got lazy and created a SnapTree test bug it's likely possible to simply have CopyOnWriteManagerTest), as well as a simple fix.

nbronson commented 13 years ago

Nice catch!