From e431538b0a59d4bedad1fcf23ded89816f991a64 Mon Sep 17 00:00:00 2001 From: Daan Hoogland Date: Wed, 26 Feb 2014 11:56:49 +0100 Subject: [PATCH] findbugs possible nullpointer mitigated --- server/src/com/cloud/api/ApiServer.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java index f0fc372723d..ba58b52d385 100755 --- a/server/src/com/cloud/api/ApiServer.java +++ b/server/src/com/cloud/api/ApiServer.java @@ -366,9 +366,13 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer Class cmdClass = getCmdClass(command[0]); - APICommand annotation = cmdClass.getAnnotation(APICommand.class); - if (cmdClass != null) { + APICommand annotation = cmdClass.getAnnotation(APICommand.class); + if (annotation == null) { + s_logger.error("No APICommand annotation found for class " + cmdClass.getCanonicalName()); + throw new CloudRuntimeException("No APICommand annotation found for class " + cmdClass.getCanonicalName()); + } + BaseCmd cmdObj = (BaseCmd)cmdClass.newInstance(); cmdObj = ComponentContext.inject(cmdObj); cmdObj.configure();