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

BindableRuntimeHintsRegistrar does not generate hints for all nested types of a ConfigurationProperties type #36909

Closed
snicoll opened this issue Aug 10, 2023 · 5 comments
Assignees
Labels
theme: aot An issue related to Ahead-of-time processing type: bug A general bug
Milestone

Comments

@snicoll
Copy link
Member

snicoll commented Aug 10, 2023

We still need to figure it out but it looks like the nested class detection can be faulty. This can be reproduced by running BindableRuntimeHintsRegistrar against RabbitProperties, there is no metadata for org.springframework.boot.autoconfigure.amqp.RabbitProperties$SimpleContainer.

@omercelikceng

This comment was marked as resolved.

@snicoll

This comment was marked as resolved.

@omercelikceng
Copy link

omercelikceng commented Sep 22, 2023

@snicoll I reviewed class ConfigurationPropertiesBeanFactoryInitializationAotProcessor. And I understood what you said. Thank you. But then isn't the document wrong?

The Spring documentation says: . Nested configuration properties which are not inner classes, however, must be annotated with @NestedConfigurationProperty, otherwise they won't be detected and will not be bindable. (@ConfigurationProperties)

But with the update you made, nested configurations are automatically registered. If what I think is true, should I open an issue to update the document? Or should I discuss it in gitter?

@snicoll
Copy link
Member Author

snicoll commented Sep 22, 2023

The documentation states the exact same thing. Those are inner classes don’t they?

@omercelikceng
Copy link

omercelikceng commented Sep 22, 2023

@snicoll I understand that thanks to your development, nested configuration properties which are not inner classes will be registered automatically.((@ConfigurationProperties)) Thanks to your development, we will not need to add the @NestedConfigurationProperty annotation.

However, the documentation says "nested configuration properties which are not inner classes cannot be detected , so you must add the @NestedConfigurationProperty annotation for nested configuration properties which are not inner classes.." Please excuse me for keeping you busy.

I reviewed your test. Let's say we update your test in your commit as in the example below. Then, would these classes(Simple, ListenerRetry, Retry) be registered to hint automatically? (Without @NestedConfigurationProperty annotation)
Or do I have to add the @NestedConfigurationProperty annotation for my example below so that it automatically registers with the hint?

public class ComplexNestedProperties {
	private Simple simple = new Simple();
	public Simple getSimple() {
		return this.simple;
	}

}

public class ListenerRetry extends Retry {
	private boolean stateless;
	public boolean isStateless() {
		return this.stateless;
	}
	public void setStateless(boolean stateless) {
		this.stateless = stateless;
	}
}

public abstract class Retry {
	private int count = 5;
	public int getCount() {
		return this.count;
	}
	public void setCount(int count) {
		this.count = count;
	}
}
public class Simple {
	private ListenerRetry retry = new ListenerRetry();
	public ListenerRetry getRetry() {
		return this.retry;
	}
}

Which of the following did your commit solve for automatic registration to hint? I want to understand this situation.
1- Inner classes registration
2- Nested configuration properties which are not inner classes(Example above)
3- Both

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: aot An issue related to Ahead-of-time processing type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants