HCOLL-222 clarified error message if trying to put the unitialized byteable key/value, that might be quite common mistake

This commit is contained in:
leventov
2014-12-01 23:21:58 +07:00
parent b774cc3e9a
commit f0bb095d65
2 changed files with 9 additions and 3 deletions
@@ -103,7 +103,14 @@ public class ByteableMarshaller<E extends Byteable>
@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