From f0ce85bd8d59c28ca833d4bd7f7887df615833df Mon Sep 17 00:00:00 2001 From: Jeremy Lakeman Date: Wed, 12 Mar 2014 13:48:37 +1030 Subject: [PATCH] Throw an explicit error instead of a NullPointerException --- java/org/servalproject/servaldna/AbstractId.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/java/org/servalproject/servaldna/AbstractId.java b/java/org/servalproject/servaldna/AbstractId.java index 2ecdf12c..4d49c2b3 100644 --- a/java/org/servalproject/servaldna/AbstractId.java +++ b/java/org/servalproject/servaldna/AbstractId.java @@ -46,6 +46,8 @@ public abstract class AbstractId { private final byte[] binary; public AbstractId(String hex) throws InvalidHexException { + if (hex==null) + throw new InvalidHexException(this, "null is not a invalid hex value"); if (hex.length() != getBinarySize()*2) throw new InvalidHexException(this, "invalid length " + hex.length() + " (should be " + (getBinarySize() * 2) + ") of '" + hex + "'"); binary = new byte[getBinarySize()];