From e168760295c1488befbaf254897a4c3671e8d32f Mon Sep 17 00:00:00 2001 From: Kris McQueen Date: Thu, 14 Oct 2010 14:38:08 -0700 Subject: [PATCH] The code implies resource could be null, and yet de-references resource before the null check. As I was experiencing a NPE because if this exact scenario, put the remote agent check inside the check for null to avoid problems. If resource is null we log that we were unable to send ping due to agent disconnected... --- .../com/cloud/agent/manager/DirectAgentAttache.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/src/com/cloud/agent/manager/DirectAgentAttache.java b/server/src/com/cloud/agent/manager/DirectAgentAttache.java index cafa42b9306..cb7fcfbc147 100644 --- a/server/src/com/cloud/agent/manager/DirectAgentAttache.java +++ b/server/src/com/cloud/agent/manager/DirectAgentAttache.java @@ -125,11 +125,11 @@ public class DirectAgentAttache extends AgentAttache { try { ServerResource resource = _resource; - if (resource.IsRemoteAgent()) { - return; - } - - if (resource != null) { + if (resource != null) { + if (resource.IsRemoteAgent()) { + return; + } + PingCommand cmd = resource.getCurrentStatus(_id); if (cmd == null) { s_logger.warn("Unable to get current status on " + _id);