Docs and test polishing for previous commit
This commit is contained in:
29
README.md
29
README.md
@@ -512,6 +512,35 @@ class Service {
|
||||
}
|
||||
```
|
||||
|
||||
Version 1.3.2 and later supports matching a paramterized (generic) return type to detect the correct recovery method:
|
||||
|
||||
```java
|
||||
@Service
|
||||
class Service {
|
||||
|
||||
@Retryable(RemoteAccessException.class)
|
||||
public List<Thing1> service1(String str1, String str2) {
|
||||
// ... do something
|
||||
}
|
||||
|
||||
@Retryable(RemoteAccessException.class)
|
||||
public List<Thing2> service2(String str1, String str2) {
|
||||
// ... do something
|
||||
}
|
||||
|
||||
@Recover
|
||||
public List<Thing1> recover1(RemoteAccessException e, String str1, String str2) {
|
||||
// ... error handling for service1
|
||||
}
|
||||
|
||||
@Recover
|
||||
public List<Thing2> recover2(RemoteAccessException e, String str1, String str2) {
|
||||
// ... error handling for service2
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
Version 1.2 introduced the ability to use expressions for certain properties. The
|
||||
following example show how to use expressions this way:
|
||||
|
||||
|
||||
@@ -197,10 +197,12 @@ public class RecoverAnnotationRecoveryHandler<T> implements MethodInvocationReco
|
||||
* deciding a match.
|
||||
* @param methodReturnType
|
||||
* @param failingMethodReturnType
|
||||
* @return
|
||||
* @return true if the parameterized return types match.
|
||||
* @since 1.3.1
|
||||
*/
|
||||
private boolean isParameterizedTypeAssignable(ParameterizedType methodReturnType,
|
||||
ParameterizedType failingMethodReturnType) {
|
||||
|
||||
Type[] methodActualArgs = methodReturnType.getActualTypeArguments();
|
||||
Type[] failingMethodActualArgs = failingMethodReturnType.getActualTypeArguments();
|
||||
if (methodActualArgs.length != failingMethodActualArgs.length) {
|
||||
|
||||
@@ -30,7 +30,9 @@ import org.springframework.retry.ExhaustedRetryException;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -501,12 +503,6 @@ public class RecoverAnnotationRecoveryHandlerTests {
|
||||
Collections.singletonMap("bar", Collections.singletonMap((Number) 0.0, "barRecoverNumberValue")));
|
||||
}
|
||||
|
||||
@Recover
|
||||
public Map<String, Map<String, Map<Double, String>>> barRecoverDouble(RuntimeException re, String name) {
|
||||
return Collections.singletonMap("bar",
|
||||
Collections.singletonMap("bar", Collections.singletonMap(0.0, "barRecoverDoubleValue")));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected static class MultipleQualifyingRecoversNoThrowable {
|
||||
|
||||
Reference in New Issue
Block a user