diff --git a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java index 69dd14935..b3062b4a2 100755 --- a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java @@ -1368,8 +1368,8 @@ class VanillaChronicleMap, final SearchState searchState = new SearchState(); private SegmentState(int depth) { - if (depth > (1 << 16)) - throw new IllegalStateException("More than " + (1 << 16) + + if (depth > (1 << 10)) + throw new IllegalStateException("More than " + (1 << 10) + " nested ChronicleMap contexts are not supported. Very probable that you " + "simply forgot to close context somewhere (recommended to use " + "try-with-resources statement). " + @@ -1383,9 +1383,14 @@ class VanillaChronicleMap, used = true; return this; } - if (next != null) - return next.get(); - return next = new SegmentState(depth + 1); + SegmentState ss; + for (ss = this; ss.next != null; ss = ss.next) { + if (!ss.used) { + used = true; + return ss; + } + } + return ss.next = new SegmentState(depth + 1); } @Override diff --git a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationTest.java b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationTest.java index 3912e75eb..9023eeddf 100644 --- a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationTest.java +++ b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationTest.java @@ -20,7 +20,6 @@ package net.openhft.chronicle.map; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import java.io.Closeable; @@ -40,7 +39,6 @@ import static org.junit.Assert.assertTrue; * * @author Rob Austin. */ -@Ignore("TODO https://higherfrequencytrading.atlassian.net/browse/HCOLL-366") public class TCPSocketReplicationTest { static int s_port = 12050;