Refine changes for PR

Closes gh-23882
This commit is contained in:
Rossen Stoyanchev 2019-10-31 14:12:34 +00:00
parent 64f2beb9bf
commit 005d2018d4
4 changed files with 10 additions and 12 deletions

View File

@ -73,10 +73,16 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
* @param beanFactory a bean factory for resolving {@code ${...}}
* placeholders and {@code #{...}} SpEL expressions in default values
*/
protected AbstractNamedValueMethodArgumentResolver(@Nullable ConversionService conversionService,
protected AbstractNamedValueMethodArgumentResolver(ConversionService conversionService,
@Nullable ConfigurableBeanFactory beanFactory) {
this.conversionService = conversionService != null ? conversionService : DefaultConversionService.getSharedInstance();
// Fallback on shared ConversionService for now for historic reasons.
// Possibly remove after discussion in gh-23882.
//noinspection ConstantConditions
this.conversionService = conversionService != null ?
conversionService : DefaultConversionService.getSharedInstance();
this.configurableBeanFactory = beanFactory;
this.expressionContext = (beanFactory != null ? new BeanExpressionContext(beanFactory, null) : null);
}

View File

@ -41,7 +41,7 @@ public class DestinationVariableMethodArgumentResolver extends AbstractNamedValu
DestinationVariableMethodArgumentResolver.class.getSimpleName() + ".templateVariables";
public DestinationVariableMethodArgumentResolver(@Nullable ConversionService conversionService) {
public DestinationVariableMethodArgumentResolver(ConversionService conversionService) {
super(conversionService, null);
}

View File

@ -49,7 +49,7 @@ public class HeaderMethodArgumentResolver extends AbstractNamedValueMethodArgume
public HeaderMethodArgumentResolver(
@Nullable ConversionService conversionService, @Nullable ConfigurableBeanFactory beanFactory) {
ConversionService conversionService, @Nullable ConfigurableBeanFactory beanFactory) {
super(conversionService, beanFactory);
}

View File

@ -145,14 +145,6 @@ public class HeaderMethodArgumentResolverTests {
assertThat(result).isEqualTo(Optional.of("bar"));
}
@Test
public void resolveOptionalHeaderWithValueFromNullConversionServiceInput() throws Exception {
GenericApplicationContext context = new GenericApplicationContext();
context.refresh();
resolver = new HeaderMethodArgumentResolver(null, context.getBeanFactory());
resolveOptionalHeaderWithValue();
}
@Test
public void resolveOptionalHeaderAsEmpty() throws Exception {
Message<String> message = MessageBuilder.withPayload("foo").build();