From ae52867be48d864e4641a61e50799588ac427f4e Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 29 Sep 2011 12:17:45 -0700 Subject: [PATCH] Add no-args constructor for ClusterSyncCommand/ClusterSyncAnswer Otherwise they can't be deserialized. Fix the following exception on KVM host: ERROR [agent.transport.Request] (Agent-Handler-2:null) Caught problem with [{"ClusterSyncCommand":{"_interval":60,"_skipSteps":20,"_steps":0,"_clusterId":2,"contextMap":{},"wait":0}}] com.google.gson.JsonParseException: The JsonDeserializer com.cloud.agent.transport.ArrayTypeAdaptor@44ed904 failed to deserialized json object [{"ClusterSyncCommand":{"_interval":60,"_skipSteps":20,"_steps":0,"_clusterId":2,"contextMap":{},"wait":0}}] given the type class [Lcom.cloud.agent.api.Command; ... Caused by: java.lang.RuntimeException: No-args constructor for class com.cloud.agent.api.ClusterSyncCommand does not exist. Register an InstanceCreator with Gson for this type to fix this problem. at com.google.gson.MappedObjectConstructor.constructWithNoArgConstructor(MappedObjectConstructor.java:64) ... --- api/src/com/cloud/agent/api/ClusterSyncAnswer.java | 2 ++ api/src/com/cloud/agent/api/ClusterSyncCommand.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/api/src/com/cloud/agent/api/ClusterSyncAnswer.java b/api/src/com/cloud/agent/api/ClusterSyncAnswer.java index c39927668da..927f857e5db 100644 --- a/api/src/com/cloud/agent/api/ClusterSyncAnswer.java +++ b/api/src/com/cloud/agent/api/ClusterSyncAnswer.java @@ -31,6 +31,8 @@ public class ClusterSyncAnswer extends Answer { public static final int FULL_SYNC=0; public static final int DELTA_SYNC=1; + public ClusterSyncAnswer() { + } public ClusterSyncAnswer(long clusterId, HashMap> newStates, int type){ _clusterId = clusterId; diff --git a/api/src/com/cloud/agent/api/ClusterSyncCommand.java b/api/src/com/cloud/agent/api/ClusterSyncCommand.java index 17b66d1a9e4..9a6b009cc0a 100644 --- a/api/src/com/cloud/agent/api/ClusterSyncCommand.java +++ b/api/src/com/cloud/agent/api/ClusterSyncCommand.java @@ -28,6 +28,8 @@ public class ClusterSyncCommand extends Command implements CronCommand { long _clusterId; + public ClusterSyncCommand() { + } public ClusterSyncCommand(int interval, int skipSteps, long clusterId){ _interval = interval;