diff options
author | qingshuting <qingshuting1@huawei.com> | 2022-09-14 10:37:24 +0800 |
---|---|---|
committer | qingshuting <qingshuting1@huawei.com> | 2022-09-20 21:13:42 +0800 |
commit | f2a6c55e7eec923b662fb161a3ba2ef5e144a085 (patch) | |
tree | 2864167b15824b6303a250e989ae25b56bad4941 /src/main/java | |
parent | c88aa892312ef0fec4c39f9239b54cc0468ce35c (diff) |
[ConfigFetchFromCbs] Fix bug of cbs that fetch configs getting hung whenjakarta
policy engine is empty
Issue-ID: DCAEGEN2-3242
Signed-off-by: qingshuting <qingshuting1@huawei.com>
Change-Id: I21307291c182e3681ba864afc5a6a6f7eb5a8add
(cherry picked from commit 7d549f48c21ff063518e8ff481c3e5a9eb8ca8b0)
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java b/src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java index afd5092..41f00a9 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/controller/ConfigFetchFromCbs.java @@ -3,6 +3,7 @@ * son-handler * ================================================================================ * Copyright (C) 2019-2021 Wipro Limited. + * Copyright (C) 2022 Huawei Technologies Co., Ltd. * ============================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -93,11 +94,15 @@ public class ConfigFetchFromCbs implements Runnable { Type mapType = new TypeToken<Map<String, Object>>() { }.getType(); if (jsonObject.getAsJsonObject("policies") != null) { - JsonObject policyJson = jsonObject.getAsJsonObject("policies").getAsJsonArray("items").get(0) + if(jsonObject.getAsJsonObject("policies").getAsJsonArray("items").size() == 0) { + log.error("No policy in policy drool pdp engine, nothing to update."); + } else { + JsonObject policyJson = jsonObject.getAsJsonObject("policies").getAsJsonArray("items").get(0) .getAsJsonObject().getAsJsonObject("config"); - Map<String, Object> policy = new Gson().fromJson(policyJson, mapType); - configPolicy.setConfig(policy); - log.info("Config policy {}", configPolicy); + Map<String, Object> policy = new Gson().fromJson(policyJson, mapType); + configPolicy.setConfig(policy); + log.info("Config policy {}", configPolicy); + } } }, throwable -> log.warn("Ooops", throwable)); } |