INT-4222: Don't Propagate a null ConversionService

JIRA: https://jira.spring.io/browse/INT-4222

See INT-4214; the `DefaultMessageHandlerMethodFactory` requires a conversion service
and sets up a default.

Some SI components propagated a `null` conversion service which overwrote the default
causing runtime exceptions.

    Caused by: java.lang.IllegalArgumentException: ConversionService must not be null
	at org.springframework.util.Assert.notNull(Assert.java:163) ~[spring-core-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
This commit is contained in:
Gary Russell
2017-02-01 12:45:01 -05:00
parent 9616cc72a1
commit 218daa94e8
11 changed files with 47 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,6 +45,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.Lifecycle;
import org.springframework.core.convert.ConversionService;
import org.springframework.expression.Expression;
import org.springframework.integration.IntegrationMessageHeaderAccessor;
import org.springframework.integration.MessageTimeoutException;
@@ -535,13 +536,18 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
^ this.requestDestinationExpressionProcessor != null,
"Exactly one of 'requestDestination', 'requestDestinationName', " +
"or 'requestDestinationExpression' is required.");
ConversionService conversionService = getConversionService();
if (this.requestDestinationExpressionProcessor != null) {
this.requestDestinationExpressionProcessor.setBeanFactory(getBeanFactory());
this.requestDestinationExpressionProcessor.setConversionService(getConversionService());
if (conversionService != null) {
this.requestDestinationExpressionProcessor.setConversionService(conversionService);
}
}
if (this.replyDestinationExpressionProcessor != null) {
this.replyDestinationExpressionProcessor.setBeanFactory(getBeanFactory());
this.replyDestinationExpressionProcessor.setConversionService(getConversionService());
if (conversionService != null) {
this.replyDestinationExpressionProcessor.setConversionService(conversionService);
}
}
/*
* This is needed because there is no way to detect 2 or more gateways using the same reply queue

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@ package org.springframework.integration.jms;
import javax.jms.Destination;
import javax.jms.JMSException;
import org.springframework.core.convert.ConversionService;
import org.springframework.expression.Expression;
import org.springframework.integration.IntegrationMessageHeaderAccessor;
import org.springframework.integration.handler.AbstractMessageHandler;
@@ -99,7 +100,10 @@ public class JmsSendingMessageHandler extends AbstractMessageHandler {
protected void onInit() {
if (this.destinationExpressionProcessor != null) {
this.destinationExpressionProcessor.setBeanFactory(getBeanFactory());
this.destinationExpressionProcessor.setConversionService(getConversionService());
ConversionService conversionService = getConversionService();
if (conversionService != null) {
this.destinationExpressionProcessor.setConversionService(conversionService);
}
}
}