You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/07/09 04:09:05 UTC
[dubbo] branch 3.0 updated: don't trust the response from nacos
server. (#8230)
This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.0 by this push:
new 01874fc don't trust the response from nacos server. (#8230)
01874fc is described below
commit 01874fc4e5fb39c8cc9040368b298cd80a4208b8
Author: 赵延 <10...@qq.com>
AuthorDate: Fri Jul 9 12:08:50 2021 +0800
don't trust the response from nacos server. (#8230)
---
.../configcenter/support/nacos/NacosDynamicConfiguration.java | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/dubbo-configcenter/dubbo-configcenter-nacos/src/main/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfiguration.java b/dubbo-configcenter/dubbo-configcenter-nacos/src/main/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfiguration.java
index 80a1858..4c2e4ea 100644
--- a/dubbo-configcenter/dubbo-configcenter-nacos/src/main/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfiguration.java
+++ b/dubbo-configcenter/dubbo-configcenter-nacos/src/main/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfiguration.java
@@ -284,7 +284,9 @@ public class NacosDynamicConfiguration implements DynamicConfiguration {
HttpRestResult<String> result = httpAgent.httpGet(GET_CONFIG_KEYS_PATH, emptyMap(), paramsValues, encoding, 5 * 1000);
Stream<String> keysStream = toKeysStream(result.getData());
- keysStream.forEach(keys::add);
+ if (keysStream != null) {
+ keysStream.forEach(keys::add);
+ }
} catch (Exception e) {
if (logger.isErrorEnabled()) {
logger.error(e.getMessage(), e);
@@ -309,7 +311,13 @@ public class NacosDynamicConfiguration implements DynamicConfiguration {
private Stream<String> toKeysStream(String content) {
JSONObject jsonObject = JSON.parseObject(content);
+ if (jsonObject == null) {
+ return null;
+ }
JSONArray pageItems = jsonObject.getJSONArray("pageItems");
+ if (pageItems == null) {
+ return null;
+ }
return pageItems.stream()
.map(object -> (JSONObject) object)
.map(json -> json.getString("dataId"));