From 642b8a56f4f08706db3399122f4294ae743bae89 Mon Sep 17 00:00:00 2001 From: Kris McQueen Date: Thu, 28 Oct 2010 17:50:44 -0700 Subject: [PATCH] If the create command returns null for whatever reason, throw an exception so it aborts scheduling the async job to act on the created object --- server/src/com/cloud/api/ApiDispatcher.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/src/com/cloud/api/ApiDispatcher.java b/server/src/com/cloud/api/ApiDispatcher.java index 860d5c47e5e..2f3b366ad7e 100644 --- a/server/src/com/cloud/api/ApiDispatcher.java +++ b/server/src/com/cloud/api/ApiDispatcher.java @@ -83,6 +83,10 @@ public class ApiDispatcher { Method method = mgr.getClass().getMethod(methodName, cmd.getClass()); Object dbObject = method.invoke(mgr, cmd); + if (dbObject == null) { + throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Create method " + methodName + " in class " + cmd.getClass().getSimpleName() + " failed to create an object."); + } + Method getIdMethod = dbObject.getClass().getMethod("getId"); Object id = getIdMethod.invoke(dbObject);