geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hiteshkhame...@apache.org
Subject incubator-geode git commit: GEODE-732 Fixed the issue with List inside list and added test for it
Date Fri, 13 May 2016 17:32:30 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop 04a000422 -> a881e9cb1


GEODE-732 Fixed the issue with List inside list and added test for it


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/a881e9cb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/a881e9cb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/a881e9cb

Branch: refs/heads/develop
Commit: a881e9cb1b86bfd5b928b8719219421f5a26a954
Parents: 04a0004
Author: Hitesh Khamesra <hkhamesra@pivotal.io>
Authored: Thu May 12 12:52:41 2016 -0700
Committer: Hitesh Khamesra <hkhamesra@pivotal.io>
Committed: Fri May 13 10:32:51 2016 -0700

----------------------------------------------------------------------
 .../com/gemstone/gemfire/pdx/JSONFormatter.java | 21 +++++++--
 .../pdx/internal/json/PdxListHelper.java        |  2 +-
 .../pdx/jsonStrings/jsonListInsideList.txt      | 48 ++++++++++++++++++++
 3 files changed, 65 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a881e9cb/geode-core/src/main/java/com/gemstone/gemfire/pdx/JSONFormatter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/pdx/JSONFormatter.java b/geode-core/src/main/java/com/gemstone/gemfire/pdx/JSONFormatter.java
index 220deaf..d929cf6 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/pdx/JSONFormatter.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/pdx/JSONFormatter.java
@@ -52,7 +52,7 @@ public class JSONFormatter {
   
   public static final String JSON_CLASSNAME = "__GEMFIRE_JSON";
   
-  enum states {NONE, ObJECT_START,  FIELD_NAME, INNER_OBJECT_FOUND, SCALER_FOUND, LIST_FOUND,
OBJECT_ENDS};
+  enum states {NONE, ObJECT_START,  FIELD_NAME, SCALER_FOUND, LIST_FOUND, LIST_ENDS, OBJECT_ENDS};
   
   private JSONFormatter() {
   }
@@ -192,9 +192,10 @@ public class JSONFormatter {
         {
           //need to create array; fieldname may be there; will it case it not there
           arrayStarts(currentState);
+          currentState = states.LIST_FOUND;
           PdxListHelper list = getList(jp, currentState, null);
           currentPdxInstance.addListField(currentFieldName, list);
-          currentState = states.LIST_FOUND;
+          currentState = states.LIST_ENDS;
           currentFieldName = null;          
           break;
         }
@@ -409,10 +410,10 @@ public class JSONFormatter {
         {
           //array is end
           arrayEnds(currentState);
+          currentState = states.LIST_ENDS;
           if(currentPdxList.getParent() == null)
             return currentPdxList;
-          currentPdxList = currentPdxList.getParent(); 
-          currentState = states.LIST_FOUND;
+          currentPdxList = currentPdxList.getParent();          
           break;
         }
         case VALUE_EMBEDDED_OBJECT :
@@ -486,6 +487,8 @@ public class JSONFormatter {
     case FIELD_NAME:
     case OBJECT_ENDS://in list
     case SCALER_FOUND://inlist
+    case LIST_FOUND:
+    case LIST_ENDS:
       return true;
       default:
         throw new IllegalStateException("Object start called when state is " +currentState);
@@ -499,7 +502,7 @@ public class JSONFormatter {
     {
     case ObJECT_START: //when empty object on field
     case SCALER_FOUND:
-    case LIST_FOUND:
+    case LIST_ENDS:
     case OBJECT_ENDS://inner object closes
       return true;
       default:
@@ -515,6 +518,7 @@ public class JSONFormatter {
     case SCALER_FOUND:
     case FIELD_NAME:
     case LIST_FOUND:
+    case LIST_ENDS:
       return true;
       default:
         throw new IllegalStateException("Array start called when state is " +currentState);
@@ -529,6 +533,7 @@ public class JSONFormatter {
     case FIELD_NAME://when empty array
     case SCALER_FOUND:
     case LIST_FOUND:
+    case LIST_ENDS:  
     case OBJECT_ENDS:
       return true;
       default:
@@ -544,6 +549,7 @@ public class JSONFormatter {
     case FIELD_NAME:
     case SCALER_FOUND:
     case LIST_FOUND:
+    case LIST_ENDS:
     case OBJECT_ENDS:
       return true;
       default:
@@ -559,6 +565,7 @@ public class JSONFormatter {
     case FIELD_NAME:
     case SCALER_FOUND:
     case LIST_FOUND:
+    case LIST_ENDS:
     case OBJECT_ENDS:
       return true;
       default:
@@ -574,6 +581,7 @@ public class JSONFormatter {
     case FIELD_NAME:
     case SCALER_FOUND:
     case LIST_FOUND:
+    case LIST_ENDS:
     case OBJECT_ENDS:
       return true;
       default:
@@ -589,6 +597,7 @@ public class JSONFormatter {
     case FIELD_NAME:
     case SCALER_FOUND:
     case LIST_FOUND:
+    case LIST_ENDS:
     case OBJECT_ENDS:
       return true;
       default:
@@ -604,6 +613,7 @@ public class JSONFormatter {
     case ObJECT_START:
     case SCALER_FOUND:
     case LIST_FOUND:
+    case LIST_ENDS:
     case OBJECT_ENDS:
       return true;
       default:
@@ -619,6 +629,7 @@ public class JSONFormatter {
     case FIELD_NAME:
     case SCALER_FOUND:
     case LIST_FOUND:
+    case LIST_ENDS:
     case OBJECT_ENDS:
       return true;
       default:

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a881e9cb/geode-core/src/main/java/com/gemstone/gemfire/pdx/internal/json/PdxListHelper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/pdx/internal/json/PdxListHelper.java
b/geode-core/src/main/java/com/gemstone/gemfire/pdx/internal/json/PdxListHelper.java
index 7700b30..d51ceed 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/pdx/internal/json/PdxListHelper.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/pdx/internal/json/PdxListHelper.java
@@ -153,7 +153,7 @@ public class PdxListHelper {
       logger.trace("addListField");
     }
     PdxListHelper tmp = new PdxListHelper(this, "no-name");
-    list.add(tmp);
+    list.add(tmp.getList());
     return tmp;
   }
   

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a881e9cb/geode-core/src/test/resources/com/gemstone/gemfire/pdx/jsonStrings/jsonListInsideList.txt
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/com/gemstone/gemfire/pdx/jsonStrings/jsonListInsideList.txt
b/geode-core/src/test/resources/com/gemstone/gemfire/pdx/jsonStrings/jsonListInsideList.txt
new file mode 100755
index 0000000..9a04081
--- /dev/null
+++ b/geode-core/src/test/resources/com/gemstone/gemfire/pdx/jsonStrings/jsonListInsideList.txt
@@ -0,0 +1,48 @@
+{
+  "photos": [
+    [
+      {
+        "url": "image url",
+        "dimensions": "192x144"
+      },
+      {
+        "url": "image url",
+        "dimensions": "original"
+      },
+      {
+        "url": "image url",
+        "dimensions": "128x96"
+      },
+      {
+        "url": "image url",
+        "dimensions": "64x48"
+      },
+      {
+        "url": "image url",
+        "dimensions": "400x300"
+      }
+    ],
+    [
+      {
+        "url": "image url",
+        "dimensions": "192x144"
+      },
+      {
+        "url": "image url",
+        "dimensions": "original"
+      },
+      {
+        "url": "image url",
+        "dimensions": "128x96"
+      },
+      {
+        "url": "image url",
+        "dimensions": "64x48"
+      },
+      {
+        "url": "image url",
+        "dimensions": "400x300"
+      }
+    ]
+  ]
+}
\ No newline at end of file


Mime
View raw message