Skip to content

Commit 36c1a74

Browse files
committed
add setError
1 parent 8828b1a commit 36c1a74

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

mse-simple-demo/C/src/main/java/com/alibabacloud/mse/demo/c/CController.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,21 @@ public String spring_boot() {
103103
return "C" + serviceTag + "[" + inetUtils.findFirstNonLoopbackAddress().getHostAddress() + "]";
104104
}
105105

106-
107106
@GetMapping("/flow")
108-
public String flow() throws ExecutionException, InterruptedException {
107+
public String flow() {
109108
try (Entry entry1 = SphU.entry("HelloWorld-c-flow-1", EntryType.IN)) {
110109
log.debug("Hello Sentinel!1");
111110
try (Entry entry2 = SphU.entry("HelloWorld-c-flow-2", EntryType.IN)) {
112111
log.debug("Hello Sentinel!2");
113-
long sleepTime = 5 + RANDOM.nextInt(5);
114-
silentSleep(sleepTime);
115-
return "C" + serviceTag + "[" + inetUtils.findFirstNonLoopbackAddress().getHostAddress() + "]" + " sleepTime:" + sleepTime;
112+
try {
113+
long sleepTime = 5 + RANDOM.nextInt(5);
114+
silentSleep(sleepTime);
115+
return "C" + serviceTag + "[" + inetUtils.findFirstNonLoopbackAddress().getHostAddress() + "]" + " sleepTime:" + sleepTime;
116+
} catch (Throwable throwable) {
117+
entry2.setError(throwable);
118+
entry1.setError(throwable);
119+
throw throwable;
120+
}
116121
} catch (BlockException e) {
117122
throw new RuntimeException(e);
118123
}

0 commit comments

Comments
 (0)