stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From im...@apache.org
Subject stratos git commit: Fixing de-serialization issue in cloud controller registry service read() method
Date Mon, 08 Dec 2014 08:39:37 GMT
Repository: stratos
Updated Branches:
  refs/heads/master 760fcf845 -> 637222c22


Fixing de-serialization issue in cloud controller registry service read() method


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/637222c2
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/637222c2
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/637222c2

Branch: refs/heads/master
Commit: 637222c22621d1d322b96f0417a9ae2bbdb2b0a8
Parents: 760fcf8
Author: Imesh Gunaratne <imesh@apache.org>
Authored: Mon Dec 8 14:09:27 2014 +0530
Committer: Imesh Gunaratne <imesh@apache.org>
Committed: Mon Dec 8 14:09:27 2014 +0530

----------------------------------------------------------------------
 .../cloud/controller/context/CloudControllerContext.java |  5 ++---
 .../cloud/controller/registry/RegistryManager.java       | 11 ++++++++++-
 .../cloud/controller/util/CloudControllerUtil.java       |  6 ++----
 3 files changed, 14 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/637222c2/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
index 56ddd48..0dfb371 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
@@ -618,9 +618,8 @@ public class CloudControllerContext implements Serializable {
     private void updateContextFromRegistry() {
         if ((!isClustered()) || (isCoordinator())) {
             try {
-                Object obj = RegistryManager.getInstance().read(CloudControllerConstants.DATA_RESOURCE);
-                if (obj != null) {
-                    Object dataObj = Deserializer.deserializeFromByteArray((byte[]) obj);
+                Object dataObj = RegistryManager.getInstance().read(CloudControllerConstants.DATA_RESOURCE);
+                if (dataObj != null) {
                     if (dataObj instanceof CloudControllerContext) {
                         CloudControllerContext serializedObj = (CloudControllerContext) dataObj;
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/637222c2/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/registry/RegistryManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/registry/RegistryManager.java
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/registry/RegistryManager.java
index 3b589ff..bcb4e7a 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/registry/RegistryManager.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/registry/RegistryManager.java
@@ -113,7 +113,16 @@ public class RegistryManager {
         	ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
         	ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
             Resource resource = registry.get(CloudControllerConstants.CLOUD_CONTROLLER_RESOURCE
+ resourcePath);
-            return resource.getContent();
+            Object content = resource.getContent();
+            if (content != null) {
+                try {
+                    return Deserializer.deserializeFromByteArray((byte[])content);
+                } catch (Exception e) {
+                    log.error("Could not de-serialize object stored in registry", e);
+                    throw new RuntimeException(e);
+                }
+            }
+            return null;
         } catch (ResourceNotFoundException ignore) {
             // this means, we've never persisted CC info in registry
             return null;

http://git-wip-us.apache.org/repos/asf/stratos/blob/637222c2/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
index 7ceca72..c7fc86e 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
@@ -327,11 +327,9 @@ public class CloudControllerUtil {
     }
     
     public static Topology retrieveTopology() {    	
-          Object obj = RegistryManager.getInstance().read(CloudControllerConstants.TOPOLOGY_RESOURCE);
-          if (obj != null) {
+          Object dataObj = RegistryManager.getInstance().read(CloudControllerConstants.TOPOLOGY_RESOURCE);
+          if (dataObj != null) {
               try {
-                  Object dataObj = Deserializer
-                          .deserializeFromByteArray((byte[]) obj);
                   if(dataObj instanceof Topology) {
                       return (Topology) dataObj;
                   } else {


Mime
View raw message