Skip to content

Commit

Permalink
修复无权限导致监听配置报错
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongxunking committed Apr 4, 2021
1 parent 6ae283b commit 3da6f82
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* 作者:钟勋 (e-mail:[email protected])
*/

Expand Down Expand Up @@ -65,12 +65,7 @@ public FindConfigResult findConfig(String mainAppId, String queriedAppId, String
if (properties.getConfig().isFetchNeedManager()) {
ManagerApps.assertAdminOrHaveApp(mainAppId);
}
FindConfigOrder order = new FindConfigOrder();
order.setMainAppId(mainAppId);
order.setQueriedAppId(queriedAppId);
order.setProfileId(profileId);
order.setTarget(target);

FindConfigOrder order = buildFindConfigOrder(mainAppId, queriedAppId, profileId, target);
return configService.findConfig(order);
}

Expand All @@ -85,7 +80,8 @@ public DeferredResult<ListeningClientsContainer.ListenResult> listen(@RequestPar
// 查找需要立即刷新的配置主题
ListeningClientsContainer.ListenResult listenResult = FacadeUtils.buildSuccess(ListeningClientsContainer.ListenResult.class);
for (ListenMeta listenMeta : listenMetas) {
FindConfigResult findConfigResult = findConfig(listenMeta.getTopic().getAppId(), listenMeta.getTopic().getAppId(), listenMeta.getTopic().getProfileId(), target);
FindConfigOrder findConfigOrder = buildFindConfigOrder(listenMeta.getTopic().getAppId(), listenMeta.getTopic().getAppId(), listenMeta.getTopic().getProfileId(), target);
FindConfigResult findConfigResult = configService.findConfig(findConfigOrder);
FacadeUtils.assertSuccess(findConfigResult);
if (!Objects.equals(listenMeta.getConfigVersion(), findConfigResult.getVersion())) {
listenResult.addTopic(listenMeta.getTopic());
Expand All @@ -106,6 +102,17 @@ public DeferredResult<ListeningClientsContainer.ListenResult> listen(@RequestPar
return deferredResult;
}

// 构建FindConfigOrder
private FindConfigOrder buildFindConfigOrder(String mainAppId, String queriedAppId, String profileId, String target) {
FindConfigOrder order = new FindConfigOrder();
order.setMainAppId(mainAppId);
order.setQueriedAppId(queriedAppId);
order.setProfileId(profileId);
order.setTarget(target);

return order;
}

// 生成超时时间
private long generateTimeout() {
return LISTEN_MIN_TIMEOUT + RANDOM.nextInt(LISTEN_MAX_TIMEOUT - LISTEN_MIN_TIMEOUT);
Expand Down

0 comments on commit 3da6f82

Please sign in to comment.