Skip to content

Commit a7fd74f

Browse files
committed
ApiDispatcher: Fix uuid->id translation and throw better debug statement
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
1 parent 03d2c01 commit a7fd74f

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

server/src/com/cloud/api/ApiDispatcher.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ public void dispatch(BaseCmd cmd, Map<String, String> params) throws Exception {
158158
}
159159

160160
if (queueSizeLimit != null) {
161-
_asyncMgr
162-
.syncAsyncJobExecution(asyncCmd.getJob(), asyncCmd.getSyncObjType(), asyncCmd.getSyncObjId().longValue(), queueSizeLimit);
161+
_asyncMgr.syncAsyncJobExecution(asyncCmd.getJob(), asyncCmd.getSyncObjType(), asyncCmd.getSyncObjId().longValue(), queueSizeLimit);
163162
} else {
164163
s_logger.trace("The queue size is unlimited, skipping the synchronizing");
165164
}
@@ -360,8 +359,9 @@ private static Long translateUuidToInternalId(String uuid, Parameter annotation)
360359
// Go through each entity which is an interface to a VO class and get a VO object
361360
// Try to getId() for the object using reflection, break on first non-null value
362361
for (Class<?> entity: entities) {
363-
// findByUuid returns one VO object using uuid, use reflect to get the Id
364-
Object objVO = s_instance._entityMgr.findByUuid(entity, uuid);
362+
// For backward compatibility, we search within removed entities and let service layer deal
363+
// with removed ones, return empty response or error
364+
Object objVO = s_instance._entityMgr.findByUuidIncludingRemoved(entity, uuid);
365365
if (objVO == null) {
366366
continue;
367367
}
@@ -377,11 +377,10 @@ private static Long translateUuidToInternalId(String uuid, Parameter annotation)
377377
break;
378378
}
379379
if (internalId == null) {
380-
if (s_logger.isDebugEnabled()) {
381-
s_logger.debug("Object entity with uuid=" + uuid + " does not exist in the database.");
382-
}
380+
if (s_logger.isDebugEnabled())
381+
s_logger.debug("Object entity uuid = " + uuid + " does not exist in the database.");
383382
throw new InvalidParameterValueException("Invalid parameter value=" + uuid
384-
+ " due to incorrect long value, entity not found, or an annotation bug.");
383+
+ " due to incorrect long value format, or entity was not found as it may have been deleted, or due to incorrect parameter annotation for the field in api cmd.");
385384
}
386385
return internalId;
387386
}

0 commit comments

Comments
 (0)