Spring Boot version: 2.1.8.RELEASE

spring-boot-configuration-processor removes nested properties declared with inner class types of the @ConfigurationProperties class from existing metadata file on incremental build with the IntelliJ IDEA. This is a rather annoying issue that manifests at the development time.

Apparently this bug is caused by the MetadataCollector#deletedInCurrentBuild method calling Elements#getTypeElement with wrong argument format. According to the API documentation, it should be a canonical class name with inner class name separated by the dot, but configuration processor passes a dollar-separated one. getTypeElement returns null as such a name does not exists in the symbol table, deletedInCurrentBuild considers it was deleted, and upstream MetadataCollector methods shouldBeMerged and getMetadata strips the leaf with this inner class type.

Sample project.

Steps to reproduce 1. Import project into IntelliJ IDEA. 2. Do NOT delegate build process to Maven in IDE settings. 3. Perform a clean build. 4. View a generated metadata in the target/classes/META-INF/spring-configuration-metadata.json and make sure in contains nested properties of inner class types (nested1.b and nested2.c and d). 5. Modify any class not annotated with @ConfigurationProperties (e.g. TestConfigPropsApplication) and do an incrementail build in the IDE (Ctrl-F9). 6. Review a metadata file again. Now it has no any inner class nested properties. 7. If metadata apperas correct, repeat steps 5 and 6 once more, sometimes bug does not strike the every build.

Correct and wrong metadata files are attached.

Proposed fix:

    private boolean deletedInCurrentBuild(String sourceType) {
        return this.processingEnvironment.getElementUtils().getTypeElement(sourceType.replace('$','.')) == null;
    }

Unfortunately I'm not aware of any conventional way of conversion between string-represented type name formats.

spring-configuration-metadata (wrong).json.txt spring-configuration-metadata (correct).json.txt

Comment From: snicoll

Thanks for the report, this is a duplicate of #10886.

Comment From: philwebb

@borisfox73 Thanks for the detailed bug report and for the suggested fix. I've implemented it in commit cf09451ffb9cdc38a7a48a7e486d66fc7d325267