diff --git a/spring-kafka/src/main/java/org/springframework/kafka/annotation/KafkaListenerAnnotationBeanPostProcessor.java b/spring-kafka/src/main/java/org/springframework/kafka/annotation/KafkaListenerAnnotationBeanPostProcessor.java index d7e68a7709..22276e98f0 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/annotation/KafkaListenerAnnotationBeanPostProcessor.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/annotation/KafkaListenerAnnotationBeanPostProcessor.java @@ -139,6 +139,8 @@ * @author Filip Halemba * @author Tomaz Fernandes * @author Wang Zhiyang + * @author Sanghyeok An + * @author Soby Chacko * * @see KafkaListener * @see KafkaListenerErrorHandler @@ -351,7 +353,7 @@ private void buildEnhancer() { for (AnnotationEnhancer enh : enhancers) { newAttrs = enh.apply(newAttrs, element); } - return attrs; + return newAttrs; }; } } diff --git a/spring-kafka/src/test/java/org/springframework/kafka/annotation/AliasPropertiesTests.java b/spring-kafka/src/test/java/org/springframework/kafka/annotation/AliasPropertiesTests.java index e719213169..500b7b02ce 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/annotation/AliasPropertiesTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/annotation/AliasPropertiesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2018-2023 the original author or authors. + * Copyright 2018-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import java.lang.annotation.Target; import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Method; +import java.util.HashMap; import java.util.Map; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -56,6 +57,7 @@ /** * @author Gary Russell * @author Artem Bilan + * @author Soby Chacko * * @since 2.2 * @@ -113,13 +115,15 @@ public static class Config { @Bean public static AnnotationEnhancer mainEnhancer() { + return (attrs, element) -> { - attrs.put("groupId", attrs.get("id") + "." + (element instanceof Class + Map newAttrs = new HashMap<>(attrs); + newAttrs.put("groupId", attrs.get("id") + "." + (element instanceof Class ? ((Class) element).getSimpleName() : ((Method) element).getDeclaringClass().getSimpleName() + "." + ((Method) element).getName())); orderedCalledFirst.set(true); - return attrs; + return newAttrs; }; }