From 9a5bf78c3ee156daf5527a4faf70375fc3a5fa47 Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Fri, 29 Mar 2013 11:55:00 +0100 Subject: [PATCH] Better error handling for some corner cases Make the exceptions more descriptive so admins can pinpoint the issue easier. --- .../cloud/agent/manager/ClusteredAgentAttache.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/server/src/com/cloud/agent/manager/ClusteredAgentAttache.java b/server/src/com/cloud/agent/manager/ClusteredAgentAttache.java index a6487402942..058a90475fd 100755 --- a/server/src/com/cloud/agent/manager/ClusteredAgentAttache.java +++ b/server/src/com/cloud/agent/manager/ClusteredAgentAttache.java @@ -95,8 +95,13 @@ public class ClusteredAgentAttache extends ConnectedAgentAttache implements Rout SynchronousListener synchronous = (SynchronousListener)listener; String peerName = synchronous.getPeer(); if (peerName != null) { - s_logger.debug(log(seq, "Forwarding to peer to cancel due to timeout")); - s_clusteredAgentMgr.cancel(peerName, _id, seq, "Timed Out"); + if (s_clusteredAgentMgr != null) { + s_logger.debug(log(seq, "Forwarding to peer to cancel due to timeout")); + s_clusteredAgentMgr.cancel(peerName, _id, seq, "Timed Out"); + } else { + s_logger.error("Unable to forward cancel, ClusteredAgentAttache is not properly initialized"); + } + } } } @@ -159,6 +164,10 @@ public class ClusteredAgentAttache extends ConnectedAgentAttache implements Rout } } + if (s_clusteredAgentMgr == null) { + throw new AgentUnavailableException("ClusteredAgentAttache not properly initialized", _id); + } + int i = 0; SocketChannel ch = null; boolean error = true;