Polish "Support @Value for record injection"
See gh-28774
This commit is contained in:
@@ -1353,10 +1353,6 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
* @param bw the BeanWrapper with bean instance
|
||||
*/
|
||||
protected void populateBean(String beanName, RootBeanDefinition mbd, @Nullable BeanWrapper bw) {
|
||||
// record has not set methods
|
||||
if (mbd.getBeanClass().isRecord()) {
|
||||
return;
|
||||
}
|
||||
if (bw == null) {
|
||||
if (mbd.hasPropertyValues()) {
|
||||
throw new BeanCreationException(
|
||||
@@ -1368,6 +1364,17 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
}
|
||||
}
|
||||
|
||||
if (bw.getWrappedClass().isRecord()) {
|
||||
if (mbd.hasPropertyValues()) {
|
||||
throw new BeanCreationException(
|
||||
mbd.getResourceDescription(), beanName, "Cannot apply property values to a record");
|
||||
}
|
||||
else {
|
||||
// Skip property population phase for records since they are immutable.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Give any InstantiationAwareBeanPostProcessors the opportunity to modify the
|
||||
// state of the bean before properties are set. This can be used, for example,
|
||||
// to support styles of field injection.
|
||||
|
||||
Reference in New Issue
Block a user