[ISSUE #8196] Return count number of subscribers correctly when throw an exception (#8197)

Close #8196
This commit is contained in:
onewe 2022-04-18 17:10:50 +08:00 committed by GitHub
parent 44850cc732
commit 8401b8c836
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -342,6 +342,8 @@ public class ServiceController {
ObjectNode result = JacksonUtils.createEmptyJsonNode();
int count = 0;
try {
List<Subscriber> subscribers = subscribeManager.getSubscribers(serviceName, namespaceId, aggregation);
@ -351,7 +353,7 @@ public class ServiceController {
}
int end = start + pageSize;
int count = subscribers.size();
count = subscribers.size();
if (end > count) {
end = count;
}
@ -363,7 +365,7 @@ public class ServiceController {
} catch (Exception e) {
Loggers.SRV_LOG.warn("query subscribers failed!", e);
result.replace("subscribers", JacksonUtils.createEmptyArrayNode());
result.put("count", 0);
result.put("count", count);
return result;
}
}