Process all non-private methods, not just public methods

Previously, the configuration processor would ignore any
@ConfigurationProperties-annotated methods that were not public. This
prevented metadata generation for package-private @Bean methods such
as those in DataSourceConfiguration's inner-classes for DBCP2, Hikari,
and Tomcat JDBC.

This commit updates the annotation processor so that it will process
any non-private method annotated with @ConfigurationProperties.

Fixes gh-18124
This commit is contained in:
Andy Wilkinson
2019-09-04 14:22:04 +01:00
parent d5b289c02f
commit 4b5ebd8505
6 changed files with 204 additions and 10 deletions

View File

@@ -216,7 +216,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
}
private void processExecutableElement(String prefix, ExecutableElement element) {
if (element.getModifiers().contains(Modifier.PUBLIC) && (TypeKind.VOID != element.getReturnType().getKind())) {
if ((!element.getModifiers().contains(Modifier.PRIVATE))
&& (TypeKind.VOID != element.getReturnType().getKind())) {
Element returns = this.processingEnv.getTypeUtils().asElement(element.getReturnType());
if (returns instanceof TypeElement) {
ItemMetadata group = ItemMetadata.newGroup(prefix,