失败重试机制-递归应用1

 1 private String reqRetry(Integer param, int errorCount) {
 2         try {
 3             return reqRemote(param);
 4         } catch (Exception e) {
 5             errorCount++;
 6             if (errorCount < 2) {
 7                 return reqRetry(param, errorCount);
 8             } else {
 9                 throw new RuntimeException(e);
10             }
11         }
12     }
13 
14 Student str= reqRetry(id,0);

失败重试机制:边界errorCount = 2,循环体reqRetry

猜你喜欢

转载自www.cnblogs.com/chinano1/p/9357756.html