You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@eventmesh.apache.org by "PickBas (via GitHub)" <gi...@apache.org> on 2023/03/30 07:49:06 UTC
[GitHub] [eventmesh] PickBas commented on a diff in pull request #3551: [ISSUE #3506] removed return statement from the for loop
PickBas commented on code in PR #3551:
URL: https://github.com/apache/eventmesh/pull/3551#discussion_r1152865610
##########
eventmesh-registry-plugin/eventmesh-registry-etcd/src/main/java/org/apache/eventmesh/registry/etcd/service/EtcdCustomService.java:
##########
@@ -77,31 +77,29 @@ public List<EventMeshServicePubTopicInfo> findEventMeshServicePubTopicInfos() th
@Nullable
public EventMeshAppSubTopicInfo findEventMeshAppSubTopicInfoByGroup(String group) throws RegistryException {
-
Client client = getEtcdClient();
String keyPrefix = KEY_PREFIX + KEY_APP + EtcdConstant.KEY_SEPARATOR + group;
List<KeyValue> keyValues = null;
try {
ByteSequence keyByteSequence = ByteSequence.from(keyPrefix.getBytes(Constants.DEFAULT_CHARSET));
-
GetOption getOption = GetOption.newBuilder().withPrefix(keyByteSequence).build();
-
keyValues = client.getKVClient().get(keyByteSequence, getOption).get().getKvs();
-
-
if (CollectionUtils.isNotEmpty(keyValues)) {
- for (KeyValue kv : keyValues) {
- EventMeshAppSubTopicInfo eventMeshAppSubTopicInfo =
- JsonUtils.parseObject(new String(kv.getValue().getBytes(), Constants.DEFAULT_CHARSET), EventMeshAppSubTopicInfo.class);
+ EventMeshAppSubTopicInfo eventMeshAppSubTopicInfo =
+ JsonUtils.parseObject(
+ new String(keyValues.get(0).getValue().getBytes(), Constants.DEFAULT_CHARSET),
+ EventMeshAppSubTopicInfo.class
+ );
+ if (eventMeshAppSubTopicInfo != null) {
return eventMeshAppSubTopicInfo;
+ } else {
+ throw new NullPointerException("eventMeshAppSubTopicInfo is null!");
Review Comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org