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

Configuration properties that use the builder pattern are not recognized when used with a generic #19099

Closed
wants to merge 7 commits into from

Conversation

ChunMengLu
Copy link
Contributor

@ChunMengLu ChunMengLu commented Nov 22, 2019

I am writing a redisson starter. For the sake of simplicity, I have used the following this:

@ConfigurationProperties(prefix = "redisson")
public class RedissonProperties {

	@NestedConfigurationProperty
	private ClusterServersConfig cluster = new ClusterServersConfig();

	public ClusterServersConfig getCluster() {
		return cluster;
	}

	public void setCluster(ClusterServersConfig cluster) {
		this.cluster = cluster;
	}
}

I found that the generated spring-configuration-metadata.json does not have ClusterServersConfig parent BaseMasterSlaveServersConfig and BaseConfig props!

public class BaseMasterSlaveServersConfig<T extends BaseMasterSlaveServersConfig<T>> extends BaseConfig<T> {
    private ReadMode readMode = ReadMode.SLAVE;
	
    public T setReadMode(ReadMode readMode) {
        this.readMode = readMode;
        return (T) this;
    }
    public ReadMode getReadMode() {
        return readMode;
    }
}

setReadMode method returnType is generic type T.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 22, 2019
@philwebb philwebb added the for: team-attention An issue we'd like other members of the team to review label Dec 2, 2019
@snicoll snicoll added type: bug A general bug and removed for: team-attention An issue we'd like other members of the team to review status: waiting-for-triage An issue we've not yet triaged labels Dec 23, 2019
@snicoll snicoll self-assigned this Dec 23, 2019
@snicoll snicoll added this to the 2.2.3 milestone Dec 23, 2019
@snicoll snicoll changed the title Configuration Processor support generic chain properties. Configuration properties that use the builder pattern are not recognized when used with a generic Dec 23, 2019
@snicoll snicoll closed this in 7d53c62 Dec 23, 2019
@snicoll
Copy link
Member

snicoll commented Dec 23, 2019

@ChunMengLu good catch and thank you for making your first contribution to Spring Boot. I've decided to take a different approach, reusing the infrastructure we already have to resolve generic types. Right now we do a type FQN name equality check which is something I would have liked to avoid but I don't want to invest into a too much sotipshicaated solution for this either.

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

Successfully merging this pull request may close these issues.

None yet

4 participants