Add Check for Null destinations (#20717)

This commit is contained in:
Mohit Yadav 2025-04-09 12:02:43 +05:30 committed by GitHub
parent 7c5ba41630
commit 4aa070f04e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -57,15 +57,17 @@ public class MigrationUtil {
JSONObject jsonObj = new JSONObject(eventSubscription);
// Read array detination if exist and check subscription type if Generic then change to
// Webhook
JSONArray destination = jsonObj.getJSONArray("destinations");
if (destination != null && !destination.isEmpty()) {
for (Object value : destination) {
JSONObject destinationObj = (JSONObject) value;
if (destinationObj.getString("type").equals("Generic")) {
destinationObj.put("type", "Webhook");
collectionDAO
.eventSubscriptionDAO()
.update(JsonUtils.readValue(jsonObj.toString(), EventSubscription.class));
if (jsonObj.keySet().contains("destinations")) {
JSONArray destination = jsonObj.getJSONArray("destinations");
if (destination != null && !destination.isEmpty()) {
for (Object value : destination) {
JSONObject destinationObj = (JSONObject) value;
if (destinationObj.getString("type").equals("Generic")) {
destinationObj.put("type", "Webhook");
collectionDAO
.eventSubscriptionDAO()
.update(JsonUtils.readValue(jsonObj.toString(), EventSubscription.class));
}
}
}
}