Skip to content

Commit 9d05b32

Browse files
committed
Add Check for Null destinations (#20717)
(cherry picked from commit 4aa070f)
1 parent e230a09 commit 9d05b32

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

  • openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v140

openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v140/MigrationUtil.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,17 @@ public static void migrateGenericToWebhook(CollectionDAO collectionDAO) {
5757
JSONObject jsonObj = new JSONObject(eventSubscription);
5858
// Read array detination if exist and check subscription type if Generic then change to
5959
// Webhook
60-
JSONArray destination = jsonObj.getJSONArray("destinations");
61-
if (destination != null && !destination.isEmpty()) {
62-
for (Object value : destination) {
63-
JSONObject destinationObj = (JSONObject) value;
64-
if (destinationObj.getString("type").equals("Generic")) {
65-
destinationObj.put("type", "Webhook");
66-
collectionDAO
67-
.eventSubscriptionDAO()
68-
.update(JsonUtils.readValue(jsonObj.toString(), EventSubscription.class));
60+
if (jsonObj.keySet().contains("destinations")) {
61+
JSONArray destination = jsonObj.getJSONArray("destinations");
62+
if (destination != null && !destination.isEmpty()) {
63+
for (Object value : destination) {
64+
JSONObject destinationObj = (JSONObject) value;
65+
if (destinationObj.getString("type").equals("Generic")) {
66+
destinationObj.put("type", "Webhook");
67+
collectionDAO
68+
.eventSubscriptionDAO()
69+
.update(JsonUtils.readValue(jsonObj.toString(), EventSubscription.class));
70+
}
6971
}
7072
}
7173
}

0 commit comments

Comments
 (0)