From 039de2d07f4185350ac3be2c4c122f9aae3dff56 Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Thu, 7 Aug 2014 19:14:45 +0100 Subject: [PATCH] HCOLL-124 fixed - Issue preventing the Replication in chronicle map from working --- .../collections/SharedHashMapBuilder.java | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/main/java/net/openhft/collections/SharedHashMapBuilder.java b/src/main/java/net/openhft/collections/SharedHashMapBuilder.java index 861f824bb..049e777b4 100644 --- a/src/main/java/net/openhft/collections/SharedHashMapBuilder.java +++ b/src/main/java/net/openhft/collections/SharedHashMapBuilder.java @@ -73,7 +73,7 @@ public class SharedHashMapBuilder implements Cloneable { private boolean canReplicate; byte identifier = Byte.MIN_VALUE; TcpReplicatorBuilder tcpReplicatorBuilder; - // ExternalReplicatorBuilder externalReplicatorBuilder; + // ExternalReplicatorBuilder externalReplicatorBuilder; private TimeProvider timeProvider = TimeProvider.SYSTEM; UdpReplicatorBuilder udpReplicatorBuilder; @@ -285,10 +285,6 @@ public class SharedHashMapBuilder implements Cloneable { if (vClass == null) throw new IllegalArgumentException("missing mandatory parameter vClass"); - if (file == null) - throw new IllegalArgumentException("missing mandatory parameter file"); - - SharedHashMapBuilder builder = toBuilder(); if (!canReplicate()) @@ -334,23 +330,25 @@ public class SharedHashMapBuilder implements Cloneable { SharedHashMapBuilder toBuilder() throws IOException { SharedHashMapBuilder builder = clone(); - for (int i = 0; i < 10; i++) { - if (file.exists() && file.length() > 0) { - readFile(file, builder); - break; - } - if (file.createNewFile() || file.length() == 0) { - newFile(file); - break; - } - try { - Thread.sleep(100); - } catch (InterruptedException e) { - throw new IOException(e); + if (file != null) { + for (int i = 0; i < 10; i++) { + if (file.exists() && file.length() > 0) { + readFile(file, builder); + break; + } + if (file.createNewFile() || file.length() == 0) { + newFile(file); + break; + } + try { + Thread.sleep(100); + } catch (InterruptedException e) { + throw new IOException(e); + } } + if (builder == null || !file.exists()) + throw new FileNotFoundException("Unable to create " + file); } - if (builder == null || !file.exists()) - throw new FileNotFoundException("Unable to create " + file); return builder; }