During incremental compilation, configuration property metadata isn't generated for classes annotated with @ControllerEndpoint, @JmxEndpoint, @RestControllerEndpoint, @ServletEndpoint, or @WebEndpoint
See original GitHub issueWe’ve seen this a few times when building locally. The build fails like this:
> Task :spring-boot-project:spring-boot-docs:asciidoctor
Feb 22, 2021 9:50:24 AM asciidoctor
WARNING: Configuration property 'management.endpoint.jolokia.enabled' not found.
Exception in thread "main" org.asciidoctor.gradle.remote.AsciidoctorRemoteExecutionException: ERROR: The following messages from AsciidoctorJ are treated as errors:
Configuration property 'management.endpoint.jolokia.enabled' not found.
at org.asciidoctor.gradle.remote.ExecutorBase.failOnWarnings(ExecutorBase.groovy:223)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:101)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1217)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1041)
at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:1011)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:994)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethodSafe(InvokerHelper.java:97)
at org.asciidoctor.gradle.remote.AsciidoctorJavaExec$_run_closure3.doCall(AsciidoctorJavaExec.groovy:74)
at org.asciidoctor.gradle.remote.AsciidoctorJavaExec$_run_closure3.call(AsciidoctorJavaExec.groovy)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2330)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2315)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2356)
at org.asciidoctor.gradle.remote.AsciidoctorJavaExec.run(AsciidoctorJavaExec.groovy:67)
at org.asciidoctor.gradle.remote.AsciidoctorJavaExec.main(AsciidoctorJavaExec.groovy:49)
Our current theory is that it’s a bug in the annotation processor when it’s being run incrementally. In this case, we can see that Asciidoctor ran at 9:50:24. Looking at the file system, the JSON file was written at 09:49:
$ ls -al spring-boot-project/spring-boot-actuator-autoconfigure/build/classes/java/main/META-INF/spring-configuration-metadata.json
-rw-r--r-- 1 awilkinson staff 87298 22 Feb 09:49 spring-boot-project/spring-boot-actuator-autoconfigure/build/classes/java/main/META-INF/spring-configuration-metadata.json
The build scan shows that spring-boot-actuator-autoconfigure:compileJava
ran due to the following changes:
Input property 'classpath' file spring-boot-project/spring-boot-autoconfigure/build/classes/java/main/org/springframework/boot/autoconfigure/jdbc/DataSourceInitialization.class has been removed.
Input property 'classpath' file spring-boot-project/spring-boot-autoconfigure/build/classes/java/main/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializationConfiguration$BeforeJpaDataSourceInitializationConfiguration.class has been added.
Input property 'classpath' file spring-boot-project/spring-boot-autoconfigure/build/classes/java/main/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializationConfiguration$BeforeJpaDataSourceInitializationConfiguration.class has been removed.
The metadata contains the management.endpoint.jolokia
group:
{
"name": "management.endpoint.jolokia",
"type": "org.springframework.boot.actuate.autoconfigure.jolokia.JolokiaProperties",
"sourceType": "org.springframework.boot.actuate.autoconfigure.jolokia.JolokiaProperties"
},
It also contains the management.endpoint.jolokia.config
property. Note that the group is as a result of processing the @ConfigurationProperties
class. When the .enabled
property is present, there’s another management.endpoint.jolokia
group:
{
"name": "management.endpoint.jolokia",
"type": "org.springframework.boot.actuate.autoconfigure.jolokia.JolokiaEndpoint",
"sourceType": "org.springframework.boot.actuate.autoconfigure.jolokia.JolokiaEndpoint"
},
It appears to be behaving as if the @Endpoint
annotation isn’t on the classpath, or the @Endpoint
-annotated classes aren’t in the RoundEnvironment
.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (11 by maintainers)
I think this is much simpler than we’d been thinking.
JolokiaEndpoint
is a@ServletEndpoint
yet the annotation processor only claims support for@Endpoint
. When Gradle is compiling incrementally it doesn’t includeJolokiaEndpoint
in theRoundEnvironment
as it isn’t annotated with an annotation that the processor claims to support. We need to add@ServletEndpoint
to the supported types declared byConfigurationMetadataAnnotationProcessor
.2.3.x doesn’t have this problem as it uses
*
.