| Total Complexity | 4 |
| Total Lines | 13 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | package io.mcarle.sciurus.retry; |
||
| 6 | 1 | class RetryAspectHandler { |
|
| 7 | |||
| 8 | static Object executeAndRetry(ProceedingJoinPoint joinPoint, Retry retry) throws Throwable { |
||
| 9 | 1 | int retryCount = 0; |
|
| 10 | 1 | while (true) { |
|
| 11 | try { |
||
| 12 | 1 | return joinPoint.proceed(); // when no exception, return result |
|
| 13 | 1 | } catch (Throwable t) { |
|
| 14 | 1 | if (retryCount >= retry.times()) { |
|
| 15 | // when not succeeded after specified retry amount, throw last exception |
||
| 16 | 1 | throw t; |
|
| 17 | } |
||
| 18 | 1 | retryCount++; |
|
| 19 | } |
||
| 23 |