mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Fix same-key check in linkToSegmentContextsChain()
This commit is contained in:
@@ -318,13 +318,8 @@ public abstract class SegmentStages implements SegmentLock, LocksInterface {
|
||||
private void linkToSegmentContextsChain() {
|
||||
LocksInterface innermostContextOnThisSegment = rootContextOnThisSegment;
|
||||
while (true) {
|
||||
if (innermostContextOnThisSegment instanceof KeySearch) {
|
||||
Data key = ((KeySearch) innermostContextOnThisSegment).inputKey;
|
||||
if (Objects.equals(key, ((KeySearch) (Object) this).inputKey)) {
|
||||
throw new IllegalStateException("Nested same-thread contexts cannot access " +
|
||||
"the same key " + key);
|
||||
}
|
||||
}
|
||||
checkNestedContextsQueryDifferentKeys(innermostContextOnThisSegment);
|
||||
|
||||
if (innermostContextOnThisSegment.nextNode() == null)
|
||||
break;
|
||||
innermostContextOnThisSegment = innermostContextOnThisSegment.nextNode();
|
||||
@@ -332,6 +327,18 @@ public abstract class SegmentStages implements SegmentLock, LocksInterface {
|
||||
innermostContextOnThisSegment.setNextNode(this);
|
||||
}
|
||||
|
||||
public void checkNestedContextsQueryDifferentKeys(
|
||||
LocksInterface innermostContextOnThisSegment) {
|
||||
// TODO Spoon doesn't replace RHS instanceof occurances
|
||||
if (innermostContextOnThisSegment.getClass() == this.getClass()) {
|
||||
Data key = ((KeySearch) innermostContextOnThisSegment).inputKey;
|
||||
if (Objects.equals(key, ((KeySearch) (Object) this).inputKey)) {
|
||||
throw new IllegalStateException("Nested same-thread contexts cannot access " +
|
||||
"the same key " + key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Stage("Locks")
|
||||
private void unlinkFromSegmentContextsChain() {
|
||||
LocksInterface prevContext = rootContextOnThisSegment;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package net.openhft.chronicle.hash.impl.stage.iter;
|
||||
|
||||
import net.openhft.chronicle.hash.impl.VanillaChronicleHashHolder;
|
||||
import net.openhft.chronicle.hash.impl.stage.entry.LocksInterface;
|
||||
import net.openhft.chronicle.hash.impl.stage.entry.SegmentStages;
|
||||
import net.openhft.chronicle.hash.impl.stage.entry.HashLookupSearch;
|
||||
import net.openhft.chronicle.hash.impl.stage.query.KeySearch;
|
||||
@@ -48,4 +49,10 @@ public abstract class IterationSegmentStages extends SegmentStages {
|
||||
segmentTier = tier;
|
||||
segmentBaseAddr = tierBaseAddr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkNestedContextsQueryDifferentKeys(
|
||||
LocksInterface innermostContextOnThisSegment) {
|
||||
// this check is relevant only for query contexts
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user