From c537d8a00b325ac5e1b6ff7fc489c6d2bbc0069d Mon Sep 17 00:00:00 2001 From: Alex Huang Date: Mon, 11 Jul 2011 14:19:35 -0700 Subject: [PATCH] more logging for gson --- client/tomcatconf/log4j-cloud.xml.in | 4 ++++ core/src/com/cloud/agent/transport/Request.java | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/client/tomcatconf/log4j-cloud.xml.in b/client/tomcatconf/log4j-cloud.xml.in index a33127524c4..0876507796a 100755 --- a/client/tomcatconf/log4j-cloud.xml.in +++ b/client/tomcatconf/log4j-cloud.xml.in @@ -66,6 +66,10 @@ + + + + diff --git a/core/src/com/cloud/agent/transport/Request.java b/core/src/com/cloud/agent/transport/Request.java index 4345a212b92..021352dc8c7 100755 --- a/core/src/com/cloud/agent/transport/Request.java +++ b/core/src/com/cloud/agent/transport/Request.java @@ -221,7 +221,12 @@ public class Request { public Command[] getCommands() { if (_cmds == null) { - _cmds = s_gson.fromJson(_content, Command[].class); + try { + _cmds = s_gson.fromJson(_content, Command[].class); + } catch (RuntimeException e) { + s_logger.error("Caught problem with " + _content, e); + throw e; + } } return _cmds; } @@ -311,7 +316,12 @@ public class Request { StringBuilder content = new StringBuilder(); if (logContent) { if (_cmds == null) { - _cmds = s_gson.fromJson(_content, this instanceof Response ? Answer[].class : Command[].class); + try { + _cmds = s_gson.fromJson(_content, this instanceof Response ? Answer[].class : Command[].class); + } catch (RuntimeException e) { + s_logger.error("Unable to convert to json: " + _content); + throw e; + } } try { s_gogger.toJson(_cmds, content);