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

Constructors for beans created using createBean(type) in Spring cannot be updated #630

Closed
Artur- opened this issue Jan 19, 2025 · 1 comment · Fixed by #632
Closed

Constructors for beans created using createBean(type) in Spring cannot be updated #630

Artur- opened this issue Jan 19, 2025 · 1 comment · Fixed by #632

Comments

@Artur-
Copy link
Contributor

Artur- commented Jan 19, 2025

If you create a bean using

getAutowireCapableBeanFactory().createBean(type)

then Spring will cache the constructors and maybe other info for the type. However, the check that HotswapAgent uses for clearing the cache:

String[] names = beanFactory.getBeanNamesForType(clazz);
// if the class is not spring bean or Factory Class, remove it
if ((names == null || names.length == 0) && !isFactoryMethod(clazz)) {
LOGGER.trace("the class '{}' is not spring bean or factory class", clazz.getName());
iterator.remove();

will print the class '{}' is not spring bean or factory class and then leave the invalid cached info in place.

This happens e.g. for Vaadin @Route classes which are not explicitly marked as Spring beans

@Artur-
Copy link
Contributor Author

Artur- commented Jan 20, 2025

At least in the basic case, only the constructor gets cached in AutowiredAnnotationBeanPostProcessor.candidateConstructorsCache and removing it from there resolves the issue. Is this something SpringBeanReload should separately check? Seems overkill to run the whole doReload loop for this case - unless something else is cached somewhere else

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

Successfully merging a pull request may close this issue.

1 participant