|
19 | 19 | import java.lang.reflect.Method; |
20 | 20 | import java.util.ArrayList; |
21 | 21 | import java.util.Arrays; |
| 22 | +import java.util.Collection; |
22 | 23 | import java.util.Collections; |
23 | 24 | import java.util.List; |
24 | 25 | import java.util.Map; |
@@ -131,10 +132,15 @@ public RetryTopicConfiguration processAnnotation(String[] topics, Class<?> clazz |
131 | 132 | if (resolvedTimeout != null) { |
132 | 133 | timeout = resolvedTimeout; |
133 | 134 | } |
134 | | - List<Class<? extends Throwable>> includes = resolveClasses(annotation.include(), annotation.includeNames(), |
| 135 | + |
| 136 | + String[] resolvedIncludeNames = resolveToStringArray(annotation.includeNames()); |
| 137 | + List<Class<? extends Throwable>> includes = resolveClasses(annotation.include(), resolvedIncludeNames, |
135 | 138 | "include"); |
136 | | - List<Class<? extends Throwable>> excludes = resolveClasses(annotation.exclude(), annotation.excludeNames(), |
| 139 | + |
| 140 | + String[] resolvedExcludeNames = resolveToStringArray(annotation.excludeNames()); |
| 141 | + List<Class<? extends Throwable>> excludes = resolveClasses(annotation.exclude(), resolvedExcludeNames, |
137 | 142 | "exclude"); |
| 143 | + |
138 | 144 | boolean traverse = false; |
139 | 145 | if (StringUtils.hasText(annotation.traversingCauses())) { |
140 | 146 | Boolean traverseResolved = resolveExpressionAsBoolean(annotation.traversingCauses(), "traversingCauses"); |
@@ -422,4 +428,25 @@ private String resolve(String value) { |
422 | 428 | return value; |
423 | 429 | } |
424 | 430 |
|
| 431 | + private String[] resolveToStringArray(String[] values) { |
| 432 | + List<String> result = new ArrayList<>(); |
| 433 | + for (String value : values) { |
| 434 | + Object resolved = resolveExpression(value); |
| 435 | + if (resolved instanceof String[] strings) { |
| 436 | + Collections.addAll(result, strings); |
| 437 | + } |
| 438 | + else if (resolved instanceof Collection<?> coll) { |
| 439 | + for (Object item : coll) { |
| 440 | + result.add(item.toString()); |
| 441 | + } |
| 442 | + } |
| 443 | + else if (resolved instanceof String str) { |
| 444 | + result.addAll(Arrays.asList(StringUtils.commaDelimitedListToStringArray(str))); |
| 445 | + } |
| 446 | + else if (resolved != null) { |
| 447 | + result.add(resolved.toString()); |
| 448 | + } |
| 449 | + } |
| 450 | + return result.toArray(new String[0]); |
| 451 | + } |
425 | 452 | } |
0 commit comments