Ensure acquireUsing() doesn't return null

This commit is contained in:
leventov
2014-09-17 10:45:48 +04:00
parent 69ea009f02
commit 4b70aafa20
@@ -770,7 +770,16 @@ class VanillaChronicleMap<K, V> extends AbstractMap<K, V>
return usingValue;
} else {
try {
return valueFactory.create();
usingValue = valueFactory.create();
if (usingValue == null) {
throw new IllegalStateException("acquireUsing() method requires" +
"valueFactory.create() result to be non-null. " +
"By default it is so when value class is" +
"a Byteable/BytesMarshallable/Externalizable subclass." +
"Note that acquireUsing() anyway makes very little sense " +
"when value class is not a Byteable subclass.");
}
return usingValue;
} catch (Exception e) {
throw new IllegalStateException(e);
}