@@ -118,8 +118,7 @@ public class KafkaListenerAnnotationBeanPostProcessor<K, V>
118
118
*/
119
119
public static final String DEFAULT_KAFKA_LISTENER_CONTAINER_FACTORY_BEAN_NAME = "kafkaListenerContainerFactory" ;
120
120
121
- private final Set <Class <?>> nonAnnotatedClasses =
122
- Collections .newSetFromMap (new ConcurrentHashMap <Class <?>, Boolean >(64 ));
121
+ private final Set <Class <?>> nonAnnotatedClasses = Collections .newSetFromMap (new ConcurrentHashMap <>(64 ));
123
122
124
123
private final Log logger = LogFactory .getLog (getClass ());
125
124
@@ -241,7 +240,7 @@ public Object postProcessAfterInitialization(final Object bean, final String bea
241
240
Class <?> targetClass = AopUtils .getTargetClass (bean );
242
241
Collection <KafkaListener > classLevelListeners = findListenerAnnotations (targetClass );
243
242
final boolean hasClassLevelListeners = classLevelListeners .size () > 0 ;
244
- final List <Method > multiMethods = new ArrayList <Method >();
243
+ final List <Method > multiMethods = new ArrayList <>();
245
244
Map <Method , Set <KafkaListener >> annotatedMethods = MethodIntrospector .selectMethods (targetClass ,
246
245
new MethodIntrospector .MetadataLookup <Set <KafkaListener >>() {
247
246
@@ -288,7 +287,7 @@ public Set<KafkaListener> inspect(Method method) {
288
287
* AnnotationUtils.getRepeatableAnnotations does not look at interfaces
289
288
*/
290
289
private Collection <KafkaListener > findListenerAnnotations (Class <?> clazz ) {
291
- Set <KafkaListener > listeners = new HashSet <KafkaListener >();
290
+ Set <KafkaListener > listeners = new HashSet <>();
292
291
KafkaListener ann = AnnotationUtils .findAnnotation (clazz , KafkaListener .class );
293
292
if (ann != null ) {
294
293
listeners .add (ann );
@@ -318,12 +317,13 @@ private Set<KafkaListener> findListenerAnnotations(Method method) {
318
317
319
318
private void processMultiMethodListeners (Collection <KafkaListener > classLevelListeners , List <Method > multiMethods ,
320
319
Object bean , String beanName ) {
321
- List <Method > checkedMethods = new ArrayList <Method >();
320
+
321
+ List <Method > checkedMethods = new ArrayList <>();
322
322
for (Method method : multiMethods ) {
323
323
checkedMethods .add (checkProxy (method , bean ));
324
324
}
325
325
for (KafkaListener classLevelListener : classLevelListeners ) {
326
- MultiMethodKafkaListenerEndpoint <K , V > endpoint = new MultiMethodKafkaListenerEndpoint <K , V >(checkedMethods ,
326
+ MultiMethodKafkaListenerEndpoint <K , V > endpoint = new MultiMethodKafkaListenerEndpoint <>(checkedMethods ,
327
327
bean );
328
328
endpoint .setBeanFactory (this .beanFactory );
329
329
processListener (endpoint , classLevelListener , bean , bean .getClass (), beanName );
@@ -332,7 +332,7 @@ private void processMultiMethodListeners(Collection<KafkaListener> classLevelLis
332
332
333
333
protected void processKafkaListener (KafkaListener kafkaListener , Method method , Object bean , String beanName ) {
334
334
Method methodToUse = checkProxy (method , bean );
335
- MethodKafkaListenerEndpoint <K , V > endpoint = new MethodKafkaListenerEndpoint <K , V >();
335
+ MethodKafkaListenerEndpoint <K , V > endpoint = new MethodKafkaListenerEndpoint <>();
336
336
endpoint .setMethod (methodToUse );
337
337
endpoint .setBeanFactory (this .beanFactory );
338
338
String errorHandlerBeanName = resolveExpressionAsString (kafkaListener .errorHandler (), "errorHandler" );
@@ -462,7 +462,7 @@ private Pattern resolvePattern(KafkaListener kafkaListener) {
462
462
else if (resolved instanceof String ) {
463
463
pattern = Pattern .compile ((String ) resolved );
464
464
}
465
- else {
465
+ else if ( resolved != null ) {
466
466
throw new IllegalStateException (
467
467
"topicPattern must resolve to a Pattern or String, not " + resolved .getClass ());
468
468
}
@@ -603,16 +603,15 @@ private String resolveExpressionAsString(String value, String attribute) {
603
603
if (resolved instanceof String ) {
604
604
return (String ) resolved ;
605
605
}
606
- else {
606
+ else if ( resolved != null ) {
607
607
throw new IllegalStateException ("The [" + attribute + "] must resolve to a String. "
608
608
+ "Resolved to [" + resolved .getClass () + "] for [" + value + "]" );
609
609
}
610
+ return null ;
610
611
}
611
612
612
613
private Object resolveExpression (String value ) {
613
- String resolvedValue = resolve (value );
614
-
615
- return this .resolver .evaluate (resolvedValue , this .expressionContext );
614
+ return this .resolver .evaluate (resolve (value ), this .expressionContext );
616
615
}
617
616
618
617
/**
0 commit comments