cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sw...@apache.org
Subject [03/39] git commit: updated refs/heads/master to 3c800b4
Date Thu, 26 May 2016 03:05:42 GMT
CLOUDSTACK-9358: StringIndexOutOfBoundsException on events

Fixes JSON deserialization of cmdInfo (current process fails with
StringIndexOutOfBoundsException when cmdEventType is the last parameter
in the JSON string.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/61d26925
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/61d26925
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/61d26925

Branch: refs/heads/master
Commit: 61d2692597dd9219862573933957f0da504acb42
Parents: e762e27
Author: Olivier Lemasle <olivier.lemasle@apalia.net>
Authored: Wed Apr 20 15:25:17 2016 +0200
Committer: Olivier Lemasle <olivier.lemasle@apalia.net>
Committed: Wed May 4 01:15:03 2016 +0200

----------------------------------------------------------------------
 server/src/com/cloud/api/ApiServer.java | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/61d26925/server/src/com/cloud/api/ApiServer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java
index 6ec2f18..ad75d98 100644
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@ -19,6 +19,7 @@ package com.cloud.api;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InterruptedIOException;
+import java.lang.reflect.Type;
 import java.net.InetAddress;
 import java.net.ServerSocket;
 import java.net.Socket;
@@ -176,6 +177,7 @@ import com.cloud.utils.db.TransactionLegacy;
 import com.cloud.utils.db.UUIDManager;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.exception.ExceptionProxyObject;
+import com.google.gson.reflect.TypeToken;
 
 @Component
 public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiServerService
{
@@ -264,10 +266,11 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler,
ApiSer
         String info = job.getCmdInfo();
         String cmdEventType = "unknown";
         if (info != null) {
-            String marker = "\"cmdEventType\"";
-            int begin = info.indexOf(marker);
-            if (begin >= 0) {
-                cmdEventType = info.substring(begin + marker.length() + 2, info.indexOf(",",
begin) - 1);
+            Type type = new TypeToken<Map<String, String>>(){}.getType();
+            Map<String, String> cmdInfo = ApiGsonHelper.getBuilder().create().fromJson(info,
type);
+            String eventTypeObj = cmdInfo.get("cmdEventType");
+            if (eventTypeObj != null) {
+                cmdEventType = eventTypeObj;
 
                 if (s_logger.isDebugEnabled())
                     s_logger.debug("Retrieved cmdEventType from job info: " + cmdEventType);


Mime
View raw message