diff --git a/src/main/java/net/openhft/chronicle/map/CloseablesManager.java b/src/main/java/net/openhft/chronicle/map/CloseablesManager.java index d2fb0517d..3b4f4b889 100644 --- a/src/main/java/net/openhft/chronicle/map/CloseablesManager.java +++ b/src/main/java/net/openhft/chronicle/map/CloseablesManager.java @@ -33,20 +33,17 @@ final class CloseablesManager implements Closeable { private boolean isClosed = false; private final Set closeables = new LinkedHashSet(); - private void checkState() { - if (isClosed) - throw new IllegalStateException(); - } + public synchronized void add(Closeable closeable) { - checkState(); + if (closeable == null) throw new NullPointerException(); closeables.add(closeable); } public synchronized void close(Closeable closeable) throws IOException { - checkState(); + for (Iterator iterator = closeables.iterator(); iterator.hasNext(); ) { if (iterator.next() == closeable) iterator.remove(); diff --git a/src/main/java/net/openhft/chronicle/map/TcpReplicator.java b/src/main/java/net/openhft/chronicle/map/TcpReplicator.java index c5b7c3e62..945ddf50c 100644 --- a/src/main/java/net/openhft/chronicle/map/TcpReplicator.java +++ b/src/main/java/net/openhft/chronicle/map/TcpReplicator.java @@ -76,7 +76,9 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable private final Replica.EntryExternalizable externalizable; private final TcpTransportAndNetworkConfig replicationConfig; private final StatelessServerConnector statelessServerConnector; - private final @Nullable RemoteNodeValidator remoteNodeValidator; + private final + @Nullable + RemoteNodeValidator remoteNodeValidator; private long selectorTimeout; @@ -1794,7 +1796,7 @@ class StatelessServerConnector { /** * write the keysize and the key to the the {@code target} buffer * - * @param key the key of the map + * @param key the key of the map */ private void writeKey(K key, Bytes writer, final ThreadLocalCopies local) { diff --git a/src/test/java/net/openhft/chronicle/map/TCPSocketReplication3VoidValueTest.java b/src/test/java/net/openhft/chronicle/map/TCPSocketReplication3VoidValueTest.java index ef33cffca..a1bd1d062 100644 --- a/src/test/java/net/openhft/chronicle/map/TCPSocketReplication3VoidValueTest.java +++ b/src/test/java/net/openhft/chronicle/map/TCPSocketReplication3VoidValueTest.java @@ -112,7 +112,7 @@ public class TCPSocketReplication3VoidValueTest { map2.put(5, null); // allow time for the recompilation to resolve - assertTrue("test timed out", waitTillEqual(5000)); + assertTrue("test timed out", waitTillEqual(15000)); assertEquals(map3, map3); assertTrue(!map1.isEmpty()); diff --git a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationBootStrapTest.java b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationBootStrapTest.java index 5e051ef7a..e540c68ff 100644 --- a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationBootStrapTest.java +++ b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationBootStrapTest.java @@ -45,11 +45,11 @@ public class TCPSocketReplicationBootStrapTest { @Test public void testBootstrap() throws IOException, InterruptedException { - map1 = newTcpSocketShmIntString((byte) 1, 8079); + map1 = newTcpSocketShmIntString((byte) 1, 8069); ChronicleMapBuilder map2aBuilder = newTcpSocketShmBuilder(Integer.class, CharSequence.class, - (byte) 2, 8076, new InetSocketAddress("localhost", 8079)); + (byte) 2, 8066, new InetSocketAddress("localhost", 8069)); final ChronicleMap map2a = map2aBuilder.createPersistedTo(getPersistenceFile()); map2a.put(10, "EXAMPLE-10"); // this will be the last time that map1 go an update from map2 @@ -86,14 +86,16 @@ public class TCPSocketReplicationBootStrapTest { @Test public void testBootstrapAndHeartbeat() throws IOException, InterruptedException { - map1 = newTcpSocketShmIntString((byte) 1, 8080, new InetSocketAddress("localhost", 8081)); + map1 = newTcpSocketShmIntString((byte) 1, 8068, new InetSocketAddress("localhost", 8067)); ChronicleMapBuilder map2aBuilder = - newTcpSocketShmBuilder(Integer.class, CharSequence.class, (byte) 2, 8081); + newTcpSocketShmBuilder(Integer.class, CharSequence.class, (byte) 2, 8067); + Thread.sleep(1); + File persistenceFile = getPersistenceFile(); final ReplicatedChronicleMap map2a = (ReplicatedChronicleMap) - map2aBuilder.createPersistedTo(getPersistenceFile()); + map2aBuilder.createPersistedTo(persistenceFile); map2a.put(10, "EXAMPLE-10"); // this will be the last time that map1 go an update from map2 @@ -105,7 +107,7 @@ public class TCPSocketReplicationBootStrapTest { Thread.yield(); } while (lastModificationTime == 0); - final File map2File = map2a.file(); + final File map2File = persistenceFile; map2a.close(); {