From e6582b0a39a1f6fb7a935f413b99676128d4a858 Mon Sep 17 00:00:00 2001 From: Peter Lawrey Date: Thu, 11 Jun 2015 14:46:41 +0100 Subject: [PATCH] HCOLL-366 Changed this method from recursive to use iteration. No longer shows up as a problem. Also reduce the maximum depth from 16K to 1K. --- .../chronicle/map/VanillaChronicleMap.java | 15 ++++++++++----- .../chronicle/map/TCPSocketReplicationTest.java | 2 -- 2 files changed, 10 insertions(+), 7 deletions(-) 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;