diff --git a/src/main/java/net/openhft/chronicle/hash/serialization/internal/ByteableMarshaller.java b/src/main/java/net/openhft/chronicle/hash/serialization/internal/ByteableMarshaller.java index 2e7f415ce..7e7dd742c 100644 --- a/src/main/java/net/openhft/chronicle/hash/serialization/internal/ByteableMarshaller.java +++ b/src/main/java/net/openhft/chronicle/hash/serialization/internal/ByteableMarshaller.java @@ -103,7 +103,14 @@ public class ByteableMarshaller @Override public void write(Bytes bytes, E e) { - bytes.write(e.bytes(), e.offset(), size); + Bytes eBytes = e.bytes(); + if (eBytes != null) { + bytes.write(eBytes, e.offset(), size); + } else { + throw new NullPointerException("You are trying to write a byteable object of " + + e.getClass() + ", " + + "which bytes are not assigned. I. e. most likely the object is uninitialized."); + } } @Override diff --git a/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java b/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java index 54906f545..60f897a35 100755 --- a/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java @@ -1398,8 +1398,7 @@ public class ChronicleMapTest { } } - @Ignore("JIRA raised for failing test HCOLL-222") - @Test + @Test(expected = NullPointerException.class) public void testPutLongValue() throws IOException { final ChronicleMapBuilder builder = ChronicleMapBuilder .of(CharSequence.class, LongValue.class)