From 1f8b34f5c55086fce2185c4393baea5d8df167ce Mon Sep 17 00:00:00 2001 From: dahn Date: Wed, 21 Jul 2021 13:01:08 +0200 Subject: [PATCH] add entity-type to message when no UUID is found for a DB ID (#5163) * add entity-type to message * Update server/src/main/java/com/cloud/uuididentity/UUIDManagerImpl.java * update for review comments * syntax * Avoid NPE when entity type is null, and throw appropriate exception Co-authored-by: Daan Hoogland Co-authored-by: Suresh Kumar Anaparti --- .../java/com/cloud/uuididentity/UUIDManagerImpl.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/com/cloud/uuididentity/UUIDManagerImpl.java b/server/src/main/java/com/cloud/uuididentity/UUIDManagerImpl.java index 8f3e9a1af5b..9b6ac8a960a 100644 --- a/server/src/main/java/com/cloud/uuididentity/UUIDManagerImpl.java +++ b/server/src/main/java/com/cloud/uuididentity/UUIDManagerImpl.java @@ -117,12 +117,16 @@ public class UUIDManagerImpl implements UUIDManager { if (customId == null) { return null; } + if (entityType == null ) { + throw new InvalidParameterValueException("Unknown entity type"); + } + Identity identity = (Identity) this._entityMgr.findById(entityType, customId); if (identity == null) { - throw new InvalidParameterValueException("Unable to find UUID for id " + customId); + throw new InvalidParameterValueException(String.format("Unable to find UUID for id [%s] of type [%s]", + customId, entityType.getSimpleName())); + } return identity.getUuid(); - } - }