Skip to content

Commit 9f74a64

Browse files
committed
Do not instantiate property value while parsing MVC element
This commit harmonizes AnnotationDrivenBeanDefinitionParser so that it does not instantiate a property value while parsing the element. Rather, it creates an inner bean definition so that the property is created during the refresh phase. Closes gh-31472
1 parent 3b80f2c commit 9f74a64

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -602,15 +602,15 @@ else if (gsonPresent) {
602602
Class<?> type = MappingJackson2SmileHttpMessageConverter.class;
603603
RootBeanDefinition jacksonConverterDef = createConverterDefinition(type, source);
604604
GenericBeanDefinition jacksonFactoryDef = createObjectMapperFactoryDefinition(source);
605-
jacksonFactoryDef.getPropertyValues().add("factory", new SmileFactory());
605+
jacksonFactoryDef.getPropertyValues().add("factory", new RootBeanDefinition(SmileFactory.class));
606606
jacksonConverterDef.getConstructorArgumentValues().addIndexedArgumentValue(0, jacksonFactoryDef);
607607
messageConverters.add(jacksonConverterDef);
608608
}
609609
if (jackson2CborPresent) {
610610
Class<?> type = MappingJackson2CborHttpMessageConverter.class;
611611
RootBeanDefinition jacksonConverterDef = createConverterDefinition(type, source);
612612
GenericBeanDefinition jacksonFactoryDef = createObjectMapperFactoryDefinition(source);
613-
jacksonFactoryDef.getPropertyValues().add("factory", new CBORFactory());
613+
jacksonFactoryDef.getPropertyValues().add("factory", new RootBeanDefinition(CBORFactory.class));
614614
jacksonConverterDef.getConstructorArgumentValues().addIndexedArgumentValue(0, jacksonFactoryDef);
615615
messageConverters.add(jacksonConverterDef);
616616
}

0 commit comments

Comments
 (0)