diff --git a/src/main/java/net/openhft/chronicle/map/MapWireConnectionHub.java b/src/main/java/net/openhft/chronicle/map/MapWireConnectionHub.java old mode 100644 new mode 100755 index 2bfbd65c7..faf660d6c --- a/src/main/java/net/openhft/chronicle/map/MapWireConnectionHub.java +++ b/src/main/java/net/openhft/chronicle/map/MapWireConnectionHub.java @@ -22,16 +22,14 @@ import static net.openhft.chronicle.map.ChronicleMapBuilder.of; */ public class MapWireConnectionHub implements Closeable { - private static final Logger LOG = LoggerFactory.getLogger(MapWireHandler.class); public static final int MAP_SERVICE = 3; - - protected ChronicleMap channelNameToId; + private static final Logger LOG = LoggerFactory.getLogger(MapWireHandler.class); private final Map channelMap; private final ReplicationHub hub; - private final ArrayList bytesChronicleMaps = new ArrayList<>(); private final ChannelProvider provider; private final Supplier>> mapFactory; + protected ChronicleMap channelNameToId; public MapWireConnectionHub( @@ -94,19 +92,11 @@ public class MapWireConnectionHub implements Closeable { return bytesMap(channelId); final int nextFreeChannel = getNextFreeChannel(); - try { - - mapFactory.get().replicatedViaChannel(hub.createChannel(nextFreeChannel)).create(); - channelNameToId.put(fromName, nextFreeChannel); - - return bytesMap(nextFreeChannel); - } catch (IOException e) { - // todo send this error back to the user - LOG.error("", e); - throw e; - } + mapFactory.get().replicatedViaChannel(hub.createChannel(nextFreeChannel)).create(); + channelNameToId.put(fromName, nextFreeChannel); + return bytesMap(nextFreeChannel); } diff --git a/src/test/java/net/openhft/lang/values/DoubleArray.java b/src/test/java/net/openhft/lang/values/DoubleArray.java index 56cd94175..b04010179 100755 --- a/src/test/java/net/openhft/lang/values/DoubleArray.java +++ b/src/test/java/net/openhft/lang/values/DoubleArray.java @@ -9,6 +9,7 @@ import net.openhft.lang.model.Copyable; * Created by peter.lawrey on 23/04/2015. */ public class DoubleArray implements Byteable, Copyable { + static boolean HACK = true; private static int CAPACITY = 0; // assume a 32-bit size. private static int LENGTH = CAPACITY + 4; // assume a 32-bit size. private static int BASE = LENGTH + 4; @@ -49,7 +50,7 @@ public class DoubleArray implements Byteable, Copyable { } public int length() { - return bytes == null ? 6 * 8 : bytes.readInt(LENGTH + offset); + return HACK && bytes == null ? 6 * 8 : bytes.readInt(LENGTH + offset); } public int capacity() { diff --git a/src/test/java/net/openhft/lang/values/DoubleArrayTest.java b/src/test/java/net/openhft/lang/values/DoubleArrayTest.java index 2868f7b31..307914e6e 100755 --- a/src/test/java/net/openhft/lang/values/DoubleArrayTest.java +++ b/src/test/java/net/openhft/lang/values/DoubleArrayTest.java @@ -2,6 +2,7 @@ package net.openhft.lang.values; import net.openhft.chronicle.map.ChronicleMap; import net.openhft.chronicle.map.ChronicleMapBuilder; +import org.junit.Ignore; import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -56,7 +57,6 @@ public class DoubleArrayTest { DoubleArray b = new DoubleArray(10); b.setData(new double[]{5, 6, 7, 8, 9}); - ChronicleMap proxyMap = ChronicleMapBuilder.of(Integer.class, DoubleArray.class) .create(); proxyMap.put(1, a); @@ -66,4 +66,26 @@ public class DoubleArrayTest { System.out.println(proxyMap.get(2)); proxyMap.close(); } + + @Test + @Ignore + public void addToAMap2() { + DoubleArray.HACK = false; + DoubleArray a = new DoubleArray(10); + a.setData(new double[]{1, 2, 3, 4, 5}); + + DoubleArray b = new DoubleArray(10); + b.setData(new double[]{5, 6, 7, 8, 9}); + + ChronicleMap proxyMap = ChronicleMapBuilder.of(Integer.class, DoubleArray.class) + .averageValueSize(6 * 8) + .create(); + proxyMap.put(1, a); + proxyMap.put(2, b); + + System.out.println(proxyMap.get(1)); + System.out.println(proxyMap.get(2)); + proxyMap.close(); + DoubleArray.HACK = true; + } } \ No newline at end of file