Docs and test polishing for previous commit

This commit is contained in:
Gary Russell
2021-03-09 16:46:47 -05:00
parent 4d2bb2be27
commit ae3ad4a249
3 changed files with 35 additions and 8 deletions

View File

@@ -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:

View File

@@ -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) {

View File

@@ -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 {