Skip to content

Commit

Permalink
GH-3425: Return modified map from AnnotationEnhancer (#3428)
Browse files Browse the repository at this point in the history
Fixes: #3425

Implement fix for issue #3425 by modifying AnnotationEnhancer to return
the updated map after processing. This change ensures that all
annotation enhancements are properly reflected in the returned result.

Modifying an existing test to verify this behavior.

**Auto-cherry-pick to `3.2.x` & `3.1.x`**
  • Loading branch information
sobychacko committed Aug 19, 2024
1 parent 9b386df commit fe66062
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@
* @author Filip Halemba
* @author Tomaz Fernandes
* @author Wang Zhiyang
* @author Sanghyeok An
* @author Soby Chacko
*
* @see KafkaListener
* @see KafkaListenerErrorHandler
Expand Down Expand Up @@ -359,7 +361,7 @@ private void buildEnhancer() {
for (AnnotationEnhancer enh : enhancers) {
newAttrs = enh.apply(newAttrs, element);
}
return attrs;
return newAttrs;
};
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -56,6 +57,7 @@
/**
* @author Gary Russell
* @author Artem Bilan
* @author Soby Chacko
*
* @since 2.2
*
Expand Down Expand Up @@ -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<String, Object> 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;
};
}

Expand Down

0 comments on commit fe66062

Please sign in to comment.