diff --git a/src/main/java/net/openhft/chronicle/map/ShortShortMultiMap.java b/src/main/java/net/openhft/chronicle/map/ShortShortMultiMap.java old mode 100644 new mode 100755 index 911d71262..c55e2da74 --- a/src/main/java/net/openhft/chronicle/map/ShortShortMultiMap.java +++ b/src/main/java/net/openhft/chronicle/map/ShortShortMultiMap.java @@ -149,12 +149,15 @@ class ShortShortMultiMap implements MultiMap { key = maskUnsetKey(key); checkValueForRemove(value); long posToRemove; + int limit = capacity; for (long pos = pos(key); ; pos = step(pos)) { int entry = bytes.readInt(pos); if (key(entry) == key && value(entry) == value) { posToRemove = pos; break; } + if (limit-- < 0) + throw new IllegalStateException(); } positions.clear(value); removePos(posToRemove); diff --git a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationPostConnectionTest.java b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationPostConnectionTest.java old mode 100644 new mode 100755 index e25847bbd..b4c0b63df --- a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationPostConnectionTest.java +++ b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationPostConnectionTest.java @@ -39,6 +39,7 @@ import static org.junit.Assert.assertTrue; public class TCPSocketReplicationPostConnectionTest { + private static int s_port = 13050; private ChronicleMap map1; private ChronicleMap map2; @@ -56,11 +57,13 @@ public class TCPSocketReplicationPostConnectionTest { @Test public void testPostConnection() throws IOException, InterruptedException { - - map1 = TCPSocketReplication4WayMapTest.newTcpSocketShmIntString((byte) 1, 8076); + int port = s_port; + s_port += 2; + map1 = TCPSocketReplication4WayMapTest.newTcpSocketShmIntString((byte) 1, port); map1.put(5, "EXAMPLE-2"); Thread.sleep(1); - map2 = TCPSocketReplication4WayMapTest.newTcpSocketShmIntString((byte) 2, 8077, new InetSocketAddress("localhost", 8076)); + map2 = TCPSocketReplication4WayMapTest.newTcpSocketShmIntString((byte) 2, port + 1, + new InetSocketAddress("localhost", port)); // allow time for the recompilation to resolve waitTillEqual(500); @@ -71,10 +74,12 @@ public class TCPSocketReplicationPostConnectionTest { @Test public void testPostConnectionNoSleep() throws IOException, InterruptedException { - - map1 = TCPSocketReplication4WayMapTest.newTcpSocketShmIntString((byte) 1, 8076); + int port = s_port; + s_port += 2; + map1 = TCPSocketReplication4WayMapTest.newTcpSocketShmIntString((byte) 1, port); map1.put(5, "EXAMPLE-2"); - map2 = TCPSocketReplication4WayMapTest.newTcpSocketShmIntString((byte) 2, 8077, new InetSocketAddress("localhost", 8076)); + map2 = TCPSocketReplication4WayMapTest.newTcpSocketShmIntString((byte) 2, port + 1, + new InetSocketAddress("localhost", port)); // allow time for the recompilation to resolve waitTillEqual(1000); @@ -85,13 +90,15 @@ public class TCPSocketReplicationPostConnectionTest { @Test public void testBootStrapIntoNewMapWithNewFile() throws IOException, InterruptedException { + int port = s_port; + s_port += 2; ChronicleMapBuilder map2aBuilder = newTcpSocketShmBuilder(Integer.class, CharSequence.class, - (byte) 2, 8077, new InetSocketAddress("localhost", 8076)); + (byte) 2, port + 1, new InetSocketAddress("localhost", port)); try (final ChronicleMap map2a = map2aBuilder.createPersistedTo(Builder.getPersistenceFile())) { - map1 = TCPSocketReplication4WayMapTest.newTcpSocketShmIntString((byte) 1, 8076); + map1 = TCPSocketReplication4WayMapTest.newTcpSocketShmIntString((byte) 1, port); Thread.sleep(1); map1.put(5, "EXAMPLE-2");