Skip to content

Commit 8beaa58

Browse files
Fix item processing in SyncStack to handle JSONObject correctly and prevent crashes
1 parent cb5ce37 commit 8beaa58

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/java/com/contentstack/sdk/SyncStack.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,13 @@ protected synchronized void setJSON(@NotNull JSONObject jsonobject) {
7878
}
7979
}
8080
} else {
81-
logger.warning("'items' is not a valid list. Skipping processing."); // ✅ Prevent crashes
82-
syncItems = new ArrayList<>();
81+
if (itemsObj instanceof JSONObject) {
82+
syncItems = new ArrayList<>();
83+
syncItems.add(sanitizeJson((JSONObject) itemsObj));
84+
} else {
85+
logger.warning("'items' is not a valid list. Skipping processing.");
86+
syncItems = new ArrayList<>();
87+
}
8388
}
8489
} else {
8590
syncItems = new ArrayList<>();

0 commit comments

Comments
 (0)