Skip to content

Commit

Permalink
[ISSUE #4095] Code Optimization and Interrupeted Exception handling.[…
Browse files Browse the repository at this point in the history
…EtcdCustomService] (#4752)

* Enhance thread handling of InterruptedException

* inline variable

* check code style

* catch InterruptedException in a separate catch code block
  • Loading branch information
scwlkq authored Jan 20, 2024
1 parent 21e4c3a commit 39c8293
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ public List<EventMeshServicePubTopicInfo> findEventMeshServicePubTopicInfos() th
}
return eventMeshServicePubTopicInfoList;
}
} catch (InterruptedException e) {
log.error("[EtcdRegistryService][findEventMeshServicePubTopicInfos] InterruptedException", e);
Thread.currentThread().interrupt();
} catch (Exception e) {
log.error("[EtcdRegistryService][findEventMeshServicePubTopicInfos] error", e);
throw new MetaException(e.getMessage());
Expand All @@ -84,12 +87,13 @@ public EventMeshAppSubTopicInfo findEventMeshAppSubTopicInfoByGroup(String group
GetOption getOption = GetOption.newBuilder().withPrefix(keyByteSequence).build();
keyValues = client.getKVClient().get(keyByteSequence, getOption).get().getKvs();
if (CollectionUtils.isNotEmpty(keyValues)) {
EventMeshAppSubTopicInfo eventMeshAppSubTopicInfo =
JsonUtils.parseObject(
new String(keyValues.get(0).getValue().getBytes(), Constants.DEFAULT_CHARSET),
EventMeshAppSubTopicInfo.class);
return eventMeshAppSubTopicInfo;
return JsonUtils.parseObject(
new String(keyValues.get(0).getValue().getBytes(), Constants.DEFAULT_CHARSET),
EventMeshAppSubTopicInfo.class);
}
} catch (InterruptedException e) {
log.error("[EtcdRegistryService][findEventMeshAppSubTopicInfoByGroup] InterruptedException", e);
Thread.currentThread().interrupt();
} catch (Exception e) {
log.error("[EtcdRegistryService][findEventMeshAppSubTopicInfoByGroup] error, group: {}", group, e);
throw new MetaException(e.getMessage());
Expand Down

0 comments on commit 39c8293

Please sign in to comment.