File tree 9 files changed +24
-24
lines changed
main/java/com/iluwatar/retry
test/java/com/iluwatar/retry
9 files changed +24
-24
lines changed Original file line number Diff line number Diff line change 56
56
*
57
57
* @author George Aristy (george.aristy@gmail.com)
58
58
* @see <a href="https://docs.microsoft.com/en-us/azure/architecture/patterns/retry">Retry pattern (Microsoft Azure Docs)</a>
59
- * @since 1.17 .0
59
+ * @since 1.18 .0
60
60
*/
61
61
public final class App {
62
62
private static final Logger LOG = LoggerFactory .getLogger (App .class );
@@ -67,7 +67,7 @@ public final class App {
67
67
*
68
68
* @param args not used
69
69
* @throws Exception not expected
70
- * @since 1.17 .0
70
+ * @since 1.18 .0
71
71
*/
72
72
public static void main (String [] args ) throws Exception {
73
73
noErrors ();
Original file line number Diff line number Diff line change 31
31
* be able to handle this error and should be reported to the maintainers immediately.
32
32
*
33
33
* @author George Aristy (george.aristy@gmail.com)
34
- * @since 1.17 .0
34
+ * @since 1.18 .0
35
35
*/
36
36
public class BusinessException extends Exception {
37
37
private static final long serialVersionUID = 6235833142062144336L ;
@@ -40,7 +40,7 @@ public class BusinessException extends Exception {
40
40
* Ctor
41
41
*
42
42
* @param message the error message
43
- * @since 1.17 .0
43
+ * @since 1.18 .0
44
44
*/
45
45
public BusinessException (String message ) {
46
46
super (message );
Original file line number Diff line number Diff line change 29
29
*
30
30
* @author George Aristy (george.aristy@gmail.com)
31
31
* @param <T> the return type
32
- * @since 1.17 .0
32
+ * @since 1.18 .0
33
33
*/
34
34
@ FunctionalInterface
35
35
public interface BusinessOperation <T > {
@@ -40,7 +40,7 @@ public interface BusinessOperation<T> {
40
40
* @return the return value
41
41
* @throws BusinessException if the operation fails. Implementations are allowed to throw more
42
42
* specific subtypes depending on the error conditions
43
- * @since 1.17 .0
43
+ * @since 1.18 .0
44
44
*/
45
45
T perform () throws BusinessException ;
46
46
}
Original file line number Diff line number Diff line change 31
31
* by an input from some end user, or were the search parameters pulled from your database?
32
32
*
33
33
* @author George Aristy (george.aristy@gmail.com)
34
- * @since 1.17 .0
34
+ * @since 1.18 .0
35
35
*/
36
36
public final class CustomerNotFoundException extends BusinessException {
37
37
private static final long serialVersionUID = -6972888602621778664L ;
@@ -40,7 +40,7 @@ public final class CustomerNotFoundException extends BusinessException {
40
40
* Ctor.
41
41
*
42
42
* @param message the error message
43
- * @since 1.17 .0
43
+ * @since 1.18 .0
44
44
*/
45
45
public CustomerNotFoundException (String message ) {
46
46
super (message );
Original file line number Diff line number Diff line change 28
28
* Catastrophic error indicating that we have lost connection to our database.
29
29
*
30
30
* @author George Aristy (george.aristy@gmail.com)
31
- * @since 1.17 .0
31
+ * @since 1.18 .0
32
32
*/
33
33
public final class DatabaseNotAvailableException extends BusinessException {
34
34
private static final long serialVersionUID = -3750769625095997799L ;
@@ -37,7 +37,7 @@ public final class DatabaseNotAvailableException extends BusinessException {
37
37
* Ctor.
38
38
*
39
39
* @param message the error message
40
- * @since 1.17 .0
40
+ * @since 1.18 .0
41
41
*/
42
42
public DatabaseNotAvailableException (String message ) {
43
43
super (message );
Original file line number Diff line number Diff line change 36
36
* purposes of this example it fails in a programmed way depending on the constructor parameters.
37
37
*
38
38
* @author George Aristy (george.aristy@gmail.com)
39
- * @since 1.17 .0
39
+ * @since 1.18 .0
40
40
*/
41
41
public final class FindCustomer implements BusinessOperation <String > {
42
42
private final String customerId ;
@@ -47,7 +47,7 @@ public final class FindCustomer implements BusinessOperation<String> {
47
47
*
48
48
* @param customerId the final result of the remote operation
49
49
* @param errors the errors to throw before returning {@code customerId}
50
- * @since 1.17 .0
50
+ * @since 1.18 .0
51
51
*/
52
52
public FindCustomer (String customerId , BusinessException ... errors ) {
53
53
this .customerId = customerId ;
Original file line number Diff line number Diff line change 36
36
*
37
37
* @author George Aristy (george.aristy@gmail.com)
38
38
* @param <T> the remote op's return type
39
- * @since 1.17 .0
39
+ * @since 1.18 .0
40
40
*/
41
41
public final class Retry <T > implements BusinessOperation <T > {
42
42
private final BusinessOperation <T > op ;
@@ -54,7 +54,7 @@ public final class Retry<T> implements BusinessOperation<T> {
54
54
* @param delay delay (in milliseconds) between attempts
55
55
* @param ignoreTests tests to check whether the remote exception can be ignored. No exceptions
56
56
* will be ignored if no tests are given
57
- * @since 1.17 .0
57
+ * @since 1.18 .0
58
58
*/
59
59
@ SafeVarargs
60
60
public Retry (
@@ -75,7 +75,7 @@ public Retry(
75
75
* The errors encountered while retrying, in the encounter order.
76
76
*
77
77
* @return the errors encountered while retrying
78
- * @since 1.17 .0
78
+ * @since 1.18 .0
79
79
*/
80
80
public List <Exception > errors () {
81
81
return Collections .unmodifiableList (this .errors );
@@ -85,7 +85,7 @@ public List<Exception> errors() {
85
85
* The number of retries performed.
86
86
*
87
87
* @return the number of retries performed
88
- * @since 1.17 .0
88
+ * @since 1.18 .0
89
89
*/
90
90
public int attempts () {
91
91
return this .attempts .intValue ();
Original file line number Diff line number Diff line change 32
32
* Unit tests for {@link FindCustomer}.
33
33
*
34
34
* @author George Aristy (george.aristy@gmail.com)
35
- * @since 1.17 .0
35
+ * @since 1.18 .0
36
36
*/
37
37
public class FindCustomerTest {
38
38
/**
39
39
* Returns the given result with no exceptions.
40
40
*
41
- * @since 1.17 .0
41
+ * @since 1.18 .0
42
42
*/
43
43
@ Test
44
44
public void noExceptions () throws Exception {
@@ -52,7 +52,7 @@ public void noExceptions() throws Exception {
52
52
* Throws the given exception.
53
53
*
54
54
* @throws Exception the expected exception
55
- * @since 1.17 .0
55
+ * @since 1.18 .0
56
56
*/
57
57
@ Test (expected = BusinessException .class )
58
58
public void oneException () throws Exception {
@@ -63,7 +63,7 @@ public void oneException() throws Exception {
63
63
* Should first throw the given exceptions, then return the given result.
64
64
*
65
65
* @throws Exception not an expected exception
66
- * @since 1.17 .0
66
+ * @since 1.18 .0
67
67
*/
68
68
@ Test
69
69
public void resultAfterExceptions () throws Exception {
Original file line number Diff line number Diff line change 33
33
* Unit tests for {@link Retry}.
34
34
*
35
35
* @author George Aristy (george.aristy@gmail.com)
36
- * @since 1.17 .0
36
+ * @since 1.18 .0
37
37
*/
38
38
public class RetryTest {
39
39
/**
40
40
* Should contain all errors thrown.
41
41
*
42
- * @since 1.17 .0
42
+ * @since 1.18 .0
43
43
*/
44
44
@ Test
45
45
public void errors () throws Exception {
@@ -65,7 +65,7 @@ public void errors() throws Exception {
65
65
* No exceptions will be ignored, hence final number of attempts should be 1 even if we're asking
66
66
* it to attempt twice.
67
67
*
68
- * @since 1.17 .0
68
+ * @since 1.18 .0
69
69
*/
70
70
@ Test
71
71
public void attempts () {
@@ -91,7 +91,7 @@ public void attempts() {
91
91
* Final number of attempts should be equal to the number of attempts asked because we are
92
92
* asking it to ignore the exception that will be thrown.
93
93
*
94
- * @since 1.17 .0
94
+ * @since 1.18 .0
95
95
*/
96
96
@ Test
97
97
public void ignore () throws Exception {
You can’t perform that action at this time.
0 commit comments