Skip to content

Commit 39c8293

Browse files
authored
[ISSUE #4095] Code Optimization and Interrupeted Exception handling.[EtcdCustomService] (#4752)
* Enhance thread handling of InterruptedException * inline variable * check code style * catch InterruptedException in a separate catch code block
1 parent 21e4c3a commit 39c8293

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Diff for: eventmesh-meta/eventmesh-meta-etcd/src/main/java/org/apache/eventmesh/meta/etcd/service/EtcdCustomService.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ public List<EventMeshServicePubTopicInfo> findEventMeshServicePubTopicInfos() th
6666
}
6767
return eventMeshServicePubTopicInfoList;
6868
}
69+
} catch (InterruptedException e) {
70+
log.error("[EtcdRegistryService][findEventMeshServicePubTopicInfos] InterruptedException", e);
71+
Thread.currentThread().interrupt();
6972
} catch (Exception e) {
7073
log.error("[EtcdRegistryService][findEventMeshServicePubTopicInfos] error", e);
7174
throw new MetaException(e.getMessage());
@@ -84,12 +87,13 @@ public EventMeshAppSubTopicInfo findEventMeshAppSubTopicInfoByGroup(String group
8487
GetOption getOption = GetOption.newBuilder().withPrefix(keyByteSequence).build();
8588
keyValues = client.getKVClient().get(keyByteSequence, getOption).get().getKvs();
8689
if (CollectionUtils.isNotEmpty(keyValues)) {
87-
EventMeshAppSubTopicInfo eventMeshAppSubTopicInfo =
88-
JsonUtils.parseObject(
89-
new String(keyValues.get(0).getValue().getBytes(), Constants.DEFAULT_CHARSET),
90-
EventMeshAppSubTopicInfo.class);
91-
return eventMeshAppSubTopicInfo;
90+
return JsonUtils.parseObject(
91+
new String(keyValues.get(0).getValue().getBytes(), Constants.DEFAULT_CHARSET),
92+
EventMeshAppSubTopicInfo.class);
9293
}
94+
} catch (InterruptedException e) {
95+
log.error("[EtcdRegistryService][findEventMeshAppSubTopicInfoByGroup] InterruptedException", e);
96+
Thread.currentThread().interrupt();
9397
} catch (Exception e) {
9498
log.error("[EtcdRegistryService][findEventMeshAppSubTopicInfoByGroup] error, group: {}", group, e);
9599
throw new MetaException(e.getMessage());

0 commit comments

Comments
 (0)