mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Make contexts follow the spec -- nested contexts on the same key should be forbidden
This commit is contained in:
@@ -16,24 +16,23 @@
|
||||
|
||||
package net.openhft.chronicle.hash.impl.stage.entry;
|
||||
|
||||
import net.openhft.chronicle.hash.Data;
|
||||
import net.openhft.chronicle.hash.SegmentLock;
|
||||
import net.openhft.chronicle.hash.impl.BigSegmentHeader;
|
||||
import net.openhft.chronicle.hash.impl.LocalLockState;
|
||||
import net.openhft.chronicle.hash.impl.SegmentHeader;
|
||||
import net.openhft.chronicle.hash.impl.VanillaChronicleHash;
|
||||
import net.openhft.chronicle.hash.impl.*;
|
||||
import net.openhft.chronicle.hash.impl.stage.hash.Chaining;
|
||||
import net.openhft.chronicle.hash.impl.stage.hash.CheckOnEachPublicOperation;
|
||||
import net.openhft.chronicle.hash.impl.VanillaChronicleHashHolder;
|
||||
import net.openhft.chronicle.hash.impl.stage.query.HashQuery;
|
||||
import net.openhft.chronicle.hash.locks.InterProcessLock;
|
||||
import net.openhft.chronicle.hash.locks.InterProcessReadWriteUpdateLock;
|
||||
import net.openhft.lang.collection.DirectBitSet;
|
||||
import net.openhft.lang.collection.SingleThreadedDirectBitSet;
|
||||
import net.openhft.lang.io.MultiStoreBytes;
|
||||
import net.openhft.sg.Stage;
|
||||
import net.openhft.sg.Staged;
|
||||
import net.openhft.sg.StageRef;
|
||||
import net.openhft.sg.Staged;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static net.openhft.chronicle.hash.impl.LocalLockState.UNLOCKED;
|
||||
|
||||
@Staged
|
||||
@@ -269,8 +268,16 @@ public abstract class SegmentStages implements SegmentLock {
|
||||
@Stage("Locks")
|
||||
private void linkToSegmentContextsChain() {
|
||||
SegmentStages innermostContextOnThisSegment = rootContextOnThisSegment;
|
||||
while (innermostContextOnThisSegment.nextNode != null)
|
||||
while (true) {
|
||||
Data key = ((HashQuery) (Object) innermostContextOnThisSegment).inputKey;
|
||||
if (Objects.equals(key, ((HashQuery) (Object) this).inputKey)) {
|
||||
throw new IllegalStateException("Nested same-thread contexts cannot access " +
|
||||
"the same key " + key);
|
||||
}
|
||||
if (innermostContextOnThisSegment.nextNode == null)
|
||||
break;
|
||||
innermostContextOnThisSegment = innermostContextOnThisSegment.nextNode;
|
||||
}
|
||||
innermostContextOnThisSegment.nextNode = this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user