Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate metadata entry for property that is @Deprecated when Lombok runs before spring-boot-configuration-processor #17550

Closed
brucelwl opened this issue Jul 17, 2019 · 6 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@brucelwl
Copy link

When Lombok is used, fields marked @deprecated will be generated twice in the spring-configuration-metadata.json file

@ConfigurationProperties("my.application")
@Setter
@Getter
public class ApplicationConfig {

    // application name
    private String name;

    // module version
    private String version;

    // architecture layer
    @Deprecated
    private String architecture = "hello";

}
<dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

As shown in the picture, two descriptions are generated.

image

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 17, 2019
@snicoll
Copy link
Member

snicoll commented Jul 17, 2019

@brucelwl thanks for the report but I find code in text generally not helpful as often something that's not shown is necessary to reproduce the problem. I've copy/pasted your example in a small project and I can't reproduce the problem.

Can you please provide a small sample (github repo or project zip) and instructions to reproduce the problem?

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Jul 17, 2019
@brucelwl
Copy link
Author

brucelwl commented Jul 17, 2019

@snicoll please see my demo https://github.com/brucelwl/demo
You just need to run the main method and look at spring-configuration-metadata.json in the target directory, There are two descriptions of my.application.architecture

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jul 17, 2019
@snicoll
Copy link
Member

snicoll commented Jul 17, 2019

Thanks. I can reproduce and this depends the order in which the APs are invoked on the project. I've swapped the order of lombok and spring-boot-configuration-processor in the pom and it didn't create the duplicate.

When lombok runs first, I suspect it creates an additional candidate that the AP detects and shouldn't.

@snicoll snicoll changed the title In special cases, properties in spring-configuration-metadata.json will be generated twice Duplicate metadata entry when lombok runs before spring-boot-configuration-processor Jul 17, 2019
@snicoll snicoll added type: bug A general bug and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Jul 17, 2019
@snicoll snicoll added this to the 2.1.x milestone Jul 17, 2019
@brucelwl

This comment has been minimized.

@wilkinsona wilkinsona self-assigned this Sep 2, 2019
@wilkinsona wilkinsona changed the title Duplicate metadata entry when lombok runs before spring-boot-configuration-processor Duplicate metadata entry for property that is @Deprecated when Lombok runs before spring-boot-configuration-processor Sep 2, 2019
@wilkinsona
Copy link
Member

This only appears to happen when the configuration property is @Deprecated. When that's the case, metadata is added twice:

  1. By processSimpleTypes with null deprecation
  2. By processSimpleLombokTypes with non-null deprecation

@wilkinsona
Copy link
Member

The metadata is also added twice when the property is not @Deprecated, however the two ItemMetadata instances are equal so the second addition attempt is ignored. They are not equal in the @Deprecated case as the Lombok-generated getter that is found by processSimpleTypes is not identified as being @Deprecated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants