diff --git a/build.gradle b/build.gradle
index f3207ad41c..ec670037af 100644
--- a/build.gradle
+++ b/build.gradle
@@ -131,7 +131,7 @@ subprojects { subproject ->
romeToolsVersion = '1.9.0'
servletApiVersion = '4.0.0'
smackVersion = '4.3.1'
- springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '2.1.2.RELEASE'
+ springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '2.1.3.BUILD-SNAPSHOT'
springDataJpaVersion = '2.1.3.RELEASE'
springDataMongoVersion = '2.1.3.RELEASE'
springDataRedisVersion = '2.1.3.RELEASE'
diff --git a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/channel/AbstractSubscribableAmqpChannel.java b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/channel/AbstractSubscribableAmqpChannel.java
index b6a406fe5d..41c35a51ae 100644
--- a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/channel/AbstractSubscribableAmqpChannel.java
+++ b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/channel/AbstractSubscribableAmqpChannel.java
@@ -288,14 +288,9 @@ abstract class AbstractSubscribableAmqpChannel extends AbstractAmqpChannel
Message> messageToSend = null;
try {
Object converted = this.converter.fromMessage(message);
- if (converted != null) {
- messageToSend = (converted instanceof Message>) ? (Message>) converted
- : buildMessage(message, converted);
- this.dispatcher.dispatch(messageToSend);
- }
- else if (this.logger.isWarnEnabled()) {
- this.logger.warn("MessageConverter returned null, no Message to dispatch");
- }
+ messageToSend = (converted instanceof Message>) ? (Message>) converted
+ : buildMessage(message, converted);
+ this.dispatcher.dispatch(messageToSend);
}
catch (MessageDispatchingException e) {
String exceptionMessage = e.getMessage() + " for amqp-channel '"
diff --git a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/config/AmqpChannelFactoryBean.java b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/config/AmqpChannelFactoryBean.java
index 426e542ff9..5cd3d341b2 100644
--- a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/config/AmqpChannelFactoryBean.java
+++ b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/config/AmqpChannelFactoryBean.java
@@ -46,6 +46,7 @@ import org.springframework.integration.amqp.channel.PollableAmqpChannel;
import org.springframework.integration.amqp.channel.PublishSubscribeAmqpChannel;
import org.springframework.integration.amqp.support.AmqpHeaderMapper;
import org.springframework.integration.amqp.support.DefaultAmqpHeaderMapper;
+import org.springframework.lang.Nullable;
import org.springframework.messaging.support.ChannelInterceptor;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.interceptor.TransactionAttribute;
@@ -152,7 +153,7 @@ public class AmqpChannelFactoryBean extends AbstractFactoryBean failedMessage = (actualThrowable instanceof MessagingException) ?
((MessagingException) actualThrowable).getFailedMessage() : null;
if (getDefaultErrorChannel() == null && getChannelResolver() != null) {
- setChannel(getChannelResolver().resolveDestination(
+ setChannel(getChannelResolver().resolveDestination(// NOSONAR not null
IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME));
}
@@ -137,11 +137,11 @@ public class MessagePublishingErrorHandler extends ErrorMessagePublisher impleme
if (errorChannelHeader instanceof MessageChannel) {
return (MessageChannel) errorChannelHeader;
}
- Assert.isInstanceOf(String.class, errorChannelHeader,
+ Assert.isInstanceOf(String.class, errorChannelHeader, () ->
"Unsupported error channel header type. Expected MessageChannel or String, but actual type is [" +
- errorChannelHeader.getClass() + "]");
+ errorChannelHeader.getClass() + "]"); // NOSONAR never null here
if (getChannelResolver() != null) {
- return getChannelResolver().resolveDestination((String) errorChannelHeader);
+ return getChannelResolver().resolveDestination((String) errorChannelHeader); // NOSONAR not null
}
else {
return null;
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/QueueChannel.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/QueueChannel.java
index 24d61afd2a..db7a987907 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/channel/QueueChannel.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/QueueChannel.java
@@ -26,6 +26,7 @@ import java.util.concurrent.TimeUnit;
import org.springframework.integration.core.MessageSelector;
import org.springframework.integration.support.management.QueueChannelManagement;
+import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
import org.springframework.util.Assert;
@@ -116,19 +117,7 @@ public class QueueChannel extends AbstractPollableChannel implements QueueChanne
return ((BlockingQueue>) this.queue).poll(timeout, TimeUnit.MILLISECONDS);
}
else {
- Message> message = this.queue.poll();
- if (message == null) {
- long nanos = TimeUnit.MILLISECONDS.toNanos(timeout);
- long deadline = System.nanoTime() + nanos;
- while (message == null && nanos > 0) {
- this.queueSemaphore.tryAcquire(nanos, TimeUnit.NANOSECONDS); // NOSONAR ok to ignore result
- message = this.queue.poll();
- if (message == null) {
- nanos = deadline - System.nanoTime();
- }
- }
- }
- return message;
+ return pollNonBlockingQueue(timeout);
}
}
if (timeout == 0) {
@@ -141,7 +130,7 @@ public class QueueChannel extends AbstractPollableChannel implements QueueChanne
else {
Message> message = this.queue.poll();
while (message == null) {
- this.queueSemaphore.tryAcquire(50, TimeUnit.MILLISECONDS);
+ this.queueSemaphore.tryAcquire(50, TimeUnit.MILLISECONDS); // NOSONAR ok to ignore result
message = this.queue.poll();
}
return message;
@@ -153,6 +142,23 @@ public class QueueChannel extends AbstractPollableChannel implements QueueChanne
}
}
+ @Nullable
+ private Message> pollNonBlockingQueue(long timeout) throws InterruptedException {
+ Message> message = this.queue.poll();
+ if (message == null) {
+ long nanos = TimeUnit.MILLISECONDS.toNanos(timeout);
+ long deadline = System.nanoTime() + nanos;
+ while (message == null && nanos > 0) {
+ this.queueSemaphore.tryAcquire(nanos, TimeUnit.NANOSECONDS); // NOSONAR ok to ignore result
+ message = this.queue.poll();
+ if (message == null) {
+ nanos = deadline - System.nanoTime();
+ }
+ }
+ }
+ return message;
+ }
+
@Override
public List> clear() {
List> clearedMessages = new ArrayList<>();
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/DefaultConfiguringBeanFactoryPostProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/config/DefaultConfiguringBeanFactoryPostProcessor.java
index d013796a0b..118091e857 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/config/DefaultConfiguringBeanFactoryPostProcessor.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/config/DefaultConfiguringBeanFactoryPostProcessor.java
@@ -160,7 +160,7 @@ class DefaultConfiguringBeanFactoryPostProcessor
else {
nullChannelDefinition =
((BeanDefinitionRegistry) this.beanFactory.getParentBeanFactory())
- .getBeanDefinition(IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME);
+ .getBeanDefinition(IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME); // NOSONAR not null
}
if (!NullChannel.class.getName().equals(nullChannelDefinition.getBeanClassName())) {
throw new IllegalStateException("The bean name '" + IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/GlobalChannelInterceptorInitializer.java b/spring-integration-core/src/main/java/org/springframework/integration/config/GlobalChannelInterceptorInitializer.java
index 9ff505615c..75bbe10cb3 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/config/GlobalChannelInterceptorInitializer.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/config/GlobalChannelInterceptorInitializer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 the original author or authors.
+ * Copyright 2014-2018 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.
@@ -38,6 +38,7 @@ import org.springframework.util.CollectionUtils;
* {@link org.springframework.context.annotation.Bean} methods are also processed.
*
* @author Artem Bilan
+ * @author Gary Russell
* @since 4.0
*/
public class GlobalChannelInterceptorInitializer implements IntegrationConfigurationInitializer {
@@ -50,14 +51,18 @@ public class GlobalChannelInterceptorInitializer implements IntegrationConfigura
BeanDefinition beanDefinition = registry.getBeanDefinition(beanName);
if (beanDefinition instanceof AnnotatedBeanDefinition) {
AnnotationMetadata metadata = ((AnnotatedBeanDefinition) beanDefinition).getMetadata();
- Map annotationAttributes = metadata.getAnnotationAttributes(GlobalChannelInterceptor.class.getName());
- if (CollectionUtils.isEmpty(annotationAttributes) && beanDefinition.getSource() instanceof MethodMetadata) {
+ Map annotationAttributes = metadata
+ .getAnnotationAttributes(GlobalChannelInterceptor.class.getName());
+ if (CollectionUtils.isEmpty(annotationAttributes)
+ && beanDefinition.getSource() instanceof MethodMetadata) {
MethodMetadata beanMethod = (MethodMetadata) beanDefinition.getSource();
- annotationAttributes = beanMethod.getAnnotationAttributes(GlobalChannelInterceptor.class.getName());
+ annotationAttributes =
+ beanMethod.getAnnotationAttributes(GlobalChannelInterceptor.class.getName()); // NOSONAR not null
}
if (!CollectionUtils.isEmpty(annotationAttributes)) {
- BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(GlobalChannelInterceptorWrapper.class)
+ BeanDefinitionBuilder builder = BeanDefinitionBuilder
+ .genericBeanDefinition(GlobalChannelInterceptorWrapper.class)
.addConstructorArgReference(beanName)
.addPropertyValue("patterns", annotationAttributes.get("patterns"))
.addPropertyValue("order", annotationAttributes.get("order"));
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/IdGeneratorConfigurer.java b/spring-integration-core/src/main/java/org/springframework/integration/config/IdGeneratorConfigurer.java
index 7feed854b0..638a5676a4 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/config/IdGeneratorConfigurer.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/config/IdGeneratorConfigurer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2018 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.
@@ -48,6 +48,7 @@ public final class IdGeneratorConfigurer implements ApplicationListener returnType;
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationConverterInitializer.java b/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationConverterInitializer.java
index 8b2904fba6..eae95cf0f7 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationConverterInitializer.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationConverterInitializer.java
@@ -54,7 +54,7 @@ public class IntegrationConverterInitializer implements IntegrationConfiguration
if (!hasIntegrationConverter && beanDefinition.getSource() instanceof MethodMetadata) {
MethodMetadata beanMethod = (MethodMetadata) beanDefinition.getSource();
- hasIntegrationConverter = beanMethod.isAnnotated(IntegrationConverter.class.getName());
+ hasIntegrationConverter = beanMethod.isAnnotated(IntegrationConverter.class.getName()); // NOSONAR never null
}
if (hasIntegrationConverter) {
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/MessageHistoryRegistrar.java b/spring-integration-core/src/main/java/org/springframework/integration/config/MessageHistoryRegistrar.java
index da0f88a9dc..336d2027d9 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/config/MessageHistoryRegistrar.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/config/MessageHistoryRegistrar.java
@@ -73,7 +73,7 @@ public class MessageHistoryRegistrar implements ImportBeanDefinitionRegistrar {
if (propertyValue != null) {
@SuppressWarnings("unchecked")
Set
*
* @author Artem Bilan
+ * @author Gary Russell
*
* @since 3.0
*/
@@ -192,6 +194,7 @@ public final class ExpressionEvalMap extends AbstractMap {
@FunctionalInterface
public interface EvaluationCallback {
+ @Nullable
Object evaluate(Expression expression);
}
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/expression/ExpressionSource.java b/spring-integration-core/src/main/java/org/springframework/integration/expression/ExpressionSource.java
index d4afa8f9e9..3b8747f6db 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/expression/ExpressionSource.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/expression/ExpressionSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2018 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,16 +19,20 @@ package org.springframework.integration.expression;
import java.util.Locale;
import org.springframework.expression.Expression;
+import org.springframework.lang.Nullable;
/**
* Strategy interface for retrieving Expressions.
*
* @author Mark Fisher
+ * @author Gary Russell
+ *
* @since 2.0
*/
@FunctionalInterface
public interface ExpressionSource {
+ @Nullable
Expression getExpression(String key, Locale locale);
}
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/expression/ExpressionUtils.java b/spring-integration-core/src/main/java/org/springframework/integration/expression/ExpressionUtils.java
index ad41aa4a94..7c28b236cb 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/expression/ExpressionUtils.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/expression/ExpressionUtils.java
@@ -36,6 +36,7 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.expression.spel.support.StandardTypeConverter;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.support.utils.IntegrationUtils;
+import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
import org.springframework.util.Assert;
@@ -163,10 +164,12 @@ public final class ExpressionUtils {
* @return the File.
* @since 5.0
*/
- public static File expressionToFile(Expression expression, EvaluationContext evaluationContext, Message> message,
- String name) {
+ public static File expressionToFile(Expression expression, EvaluationContext evaluationContext,
+ @Nullable Message> message, String name) {
File file;
- Object value = expression.getValue(evaluationContext, message);
+ Object value = message == null
+ ? expression.getValue(evaluationContext)
+ : expression.getValue(evaluationContext, message);
if (value == null) {
throw new IllegalStateException(String.format("The provided %s expression (%s) must not evaluate to null.",
name, expression.getExpressionString()));
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/expression/FunctionExpression.java b/spring-integration-core/src/main/java/org/springframework/integration/expression/FunctionExpression.java
index 9dda92857e..bb01c1b8d9 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/expression/FunctionExpression.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/expression/FunctionExpression.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2018 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.
@@ -87,7 +87,8 @@ public class FunctionExpression implements Expression {
@Override
public Object getValue(EvaluationContext context) throws EvaluationException {
- return getValue(context.getRootObject().getValue());
+ Object root = context.getRootObject().getValue();
+ return root == null ? getValue() : getValue(root);
}
@Override
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/expression/ReloadableResourceBundleExpressionSource.java b/spring-integration-core/src/main/java/org/springframework/integration/expression/ReloadableResourceBundleExpressionSource.java
index 3d4d1e7382..5043169e7c 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/expression/ReloadableResourceBundleExpressionSource.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/expression/ReloadableResourceBundleExpressionSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2018 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.expression;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -37,6 +38,7 @@ import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.SpelParserConfiguration;
import org.springframework.expression.spel.standard.SpelExpressionParser;
+import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.DefaultPropertiesPersister;
import org.springframework.util.PropertiesPersister;
@@ -240,13 +242,14 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
*/
@Override
public Expression getExpression(String key, Locale locale) {
- String expressionString = this.getExpressionString(key, locale);
+ String expressionString = getExpressionString(key, locale);
if (expressionString != null) {
return this.parser.parseExpression(expressionString);
}
return null;
}
+ @Nullable
private String getExpressionString(String key, Locale locale) {
if (this.cacheMillis < 0) {
PropertiesHolder propHolder = getMergedProperties(locale);
@@ -476,32 +479,15 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
InputStream is = resource.getInputStream();
Properties props = new Properties();
try {
- if (resource.getFilename().endsWith(XML_SUFFIX)) {
+ String resourceFilename = resource.getFilename();
+ if (resourceFilename != null && resourceFilename.endsWith(XML_SUFFIX)) {
if (logger.isDebugEnabled()) {
- logger.debug("Loading properties [" + resource.getFilename() + "]");
+ logger.debug("Loading properties [" + resourceFilename + "]");
}
this.propertiesPersister.loadFromXml(props, is);
}
else {
- String encoding = null;
- if (this.fileEncodings != null) {
- encoding = this.fileEncodings.getProperty(filename);
- }
- if (encoding == null) {
- encoding = this.defaultEncoding;
- }
- if (encoding != null) {
- if (logger.isDebugEnabled()) {
- logger.debug("Loading properties [" + resource.getFilename() + "] with encoding '" + encoding + "'");
- }
- this.propertiesPersister.load(props, new InputStreamReader(is, encoding));
- }
- else {
- if (logger.isDebugEnabled()) {
- logger.debug("Loading properties [" + resource.getFilename() + "]");
- }
- this.propertiesPersister.load(props, is);
- }
+ loadFromProperties(resource, filename, is, props, resourceFilename);
}
return props;
}
@@ -510,6 +496,32 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
}
}
+ private void loadFromProperties(Resource resource, String filename, InputStream is, Properties props,
+ String resourceFilename) throws IOException, UnsupportedEncodingException {
+ String encoding = null;
+ if (this.fileEncodings != null) {
+ encoding = this.fileEncodings.getProperty(filename);
+ }
+ if (encoding == null) {
+ encoding = this.defaultEncoding;
+ }
+ if (encoding != null) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Loading properties ["
+ + (resourceFilename == null ? resource : resourceFilename)
+ + "] with encoding '" + encoding + "'");
+ }
+ this.propertiesPersister.load(props, new InputStreamReader(is, encoding));
+ }
+ else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Loading properties [" + (resourceFilename == null ? resource : resourceFilename)
+ + "]");
+ }
+ this.propertiesPersister.load(props, is);
+ }
+ }
+
/**
* Clear the resource bundle cache.
@@ -570,6 +582,7 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
return this.refreshTimestamp;
}
+ @Nullable
public String getProperty(String code) {
if (this.properties == null) {
return null;
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/expression/SupplierExpression.java b/spring-integration-core/src/main/java/org/springframework/integration/expression/SupplierExpression.java
index 71bb1ec9ec..d94f7feb99 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/expression/SupplierExpression.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/expression/SupplierExpression.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2018 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.
@@ -16,7 +16,7 @@
package org.springframework.integration.expression;
-import org.boon.core.Supplier;
+import java.util.function.Supplier;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.EvaluationContext;
@@ -86,7 +86,8 @@ public class SupplierExpression implements Expression {
@Override
public Object getValue(EvaluationContext context) throws EvaluationException {
- return getValue(context.getRootObject().getValue());
+ Object root = context.getRootObject().getValue();
+ return root == null ? getValue() : getValue(root);
}
@Override
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/expression/package-info.java b/spring-integration-core/src/main/java/org/springframework/integration/expression/package-info.java
index 46da20b571..06cd283d61 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/expression/package-info.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/expression/package-info.java
@@ -1,4 +1,5 @@
/**
* Provides classes supporting SpEL expressions.
*/
+@org.springframework.lang.NonNullApi
package org.springframework.integration.expression;
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/gateway/AnnotationGatewayProxyFactoryBean.java b/spring-integration-core/src/main/java/org/springframework/integration/gateway/AnnotationGatewayProxyFactoryBean.java
index bf9f56dbd7..864e587574 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/gateway/AnnotationGatewayProxyFactoryBean.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/gateway/AnnotationGatewayProxyFactoryBean.java
@@ -58,7 +58,7 @@ public class AnnotationGatewayProxyFactoryBean extends GatewayProxyFactoryBean {
this.gatewayAttributes = gatewayAttributes;
String id = gatewayAttributes.getString("name");
- if (!StringUtils.hasText(id)) {
+ if (StringUtils.hasText(id)) {
setBeanName(id);
}
}
@@ -88,11 +88,15 @@ public class AnnotationGatewayProxyFactoryBean extends GatewayProxyFactoryBean {
String defaultRequestChannel =
beanFactory.resolveEmbeddedValue(this.gatewayAttributes.getString("defaultRequestChannel"));
- setDefaultRequestChannelName(defaultRequestChannel);
+ if (StringUtils.hasText(defaultRequestChannel)) {
+ setDefaultRequestChannelName(defaultRequestChannel);
+ }
String defaultReplyChannel =
beanFactory.resolveEmbeddedValue(this.gatewayAttributes.getString("defaultReplyChannel"));
- setDefaultReplyChannelName(defaultReplyChannel);
+ if (StringUtils.hasText(defaultReplyChannel)) {
+ setDefaultReplyChannelName(defaultReplyChannel);
+ }
String errorChannel = beanFactory.resolveEmbeddedValue(this.gatewayAttributes.getString("errorChannel"));
setErrorChannelName(errorChannel);
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/gateway/MessagingGatewaySupport.java b/spring-integration-core/src/main/java/org/springframework/integration/gateway/MessagingGatewaySupport.java
index 11a838bf14..f5c5f28f47 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/gateway/MessagingGatewaySupport.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/gateway/MessagingGatewaySupport.java
@@ -360,6 +360,7 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
* @return the channel.
* @since 4.2
*/
+ @Nullable
public MessageChannel getRequestChannel() {
if (this.requestChannelName != null) {
synchronized (this) {
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/graph/IntegrationGraphServer.java b/spring-integration-core/src/main/java/org/springframework/integration/graph/IntegrationGraphServer.java
index f9748a446f..41204293d8 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/graph/IntegrationGraphServer.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/graph/IntegrationGraphServer.java
@@ -352,7 +352,9 @@ public class IntegrationGraphServer implements ApplicationContextAware, Applicat
private MessageGatewayNode gatewayNode(String name, MessagingGatewaySupport gateway) {
String errorChannel = gateway.getErrorChannel() != null ? gateway.getErrorChannel().toString() : null;
- String requestChannel = gateway.getRequestChannel() != null ? gateway.getRequestChannel().toString() : null;
+ String requestChannel = gateway.getRequestChannel() != null
+ ? gateway.getRequestChannel().toString() // NOSONAR not null
+ : null;
return new MessageGatewayNode(this.nodeId.incrementAndGet(), name, gateway,
requestChannel, errorChannel);
}
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java b/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java
index 81d365bf06..2387d7ccf8 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java
@@ -137,14 +137,12 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler imple
}
protected ConversionService getRequiredConversionService() {
- if (this.getConversionService() == null) {
- synchronized (this) {
- if (getConversionService() == null) {
- setConversionService(DefaultConversionService.getSharedInstance());
- }
- }
+ ConversionService conversionService = getConversionService();
+ if (conversionService == null) {
+ conversionService = DefaultConversionService.getSharedInstance();
+ setConversionService(conversionService);
}
- return getConversionService();
+ return conversionService;
}
@Override
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/store/MessageGroupQueue.java b/spring-integration-core/src/main/java/org/springframework/integration/store/MessageGroupQueue.java
index d69b4aa462..ce4caf2a78 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/store/MessageGroupQueue.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/store/MessageGroupQueue.java
@@ -349,6 +349,7 @@ public class MessageGroupQueue extends AbstractQueue> implements Bloc
/**
* It is assumed that the 'storeLock' is being held by the caller, otherwise
* IllegalMonitorStateException may be thrown
+ * @return a message // TODO @Nullable
*/
protected Message> doPoll() {
Message> message = this.messageGroupStore.pollMessageFromGroup(this.groupId);
@@ -360,6 +361,7 @@ public class MessageGroupQueue extends AbstractQueue> implements Bloc
* It is assumed that the 'storeLock' is being held by the caller, otherwise
* IllegalMonitorStateException may be thrown
* @param message the message to offer.
+ * @return true if offered.
*/
protected boolean doOffer(Message> message) {
boolean offered = false;
diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/FileWritingMessageHandler.java b/spring-integration-file/src/main/java/org/springframework/integration/file/FileWritingMessageHandler.java
index ab26a4ce61..6be70aeef0 100644
--- a/spring-integration-file/src/main/java/org/springframework/integration/file/FileWritingMessageHandler.java
+++ b/spring-integration-file/src/main/java/org/springframework/integration/file/FileWritingMessageHandler.java
@@ -448,9 +448,8 @@ public class FileWritingMessageHandler extends AbstractReplyProducingMessageHand
this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
if (this.destinationDirectoryExpression instanceof LiteralExpression) {
- final File directory =
- new File(this.destinationDirectoryExpression.getValue(this.evaluationContext, String.class));
-
+ final File directory = ExpressionUtils.expressionToFile(this.destinationDirectoryExpression,
+ this.evaluationContext, null, "destinationDirectoryExpression");
validateDestinationDirectory(directory, this.autoCreateDirectory);
}
diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterFactoryBean.java b/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterFactoryBean.java
index ac8f56906b..a9f4a45c72 100644
--- a/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterFactoryBean.java
+++ b/spring-integration-file/src/main/java/org/springframework/integration/file/config/FileTailInboundChannelAdapterFactoryBean.java
@@ -253,7 +253,7 @@ public class FileTailInboundChannelAdapterFactoryBean extends AbstractFactoryBea
adapter.setApplicationEventPublisher(this.applicationEventPublisher);
}
if (getBeanFactory() != null) {
- adapter.setBeanFactory(getBeanFactory());
+ adapter.setBeanFactory(getBeanFactory()); // NOSONAR never null
}
adapter.afterPropertiesSet();
this.adapter = adapter;
diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/filters/ExpressionFileListFilter.java b/spring-integration-file/src/main/java/org/springframework/integration/file/filters/ExpressionFileListFilter.java
index 5a96b10c45..565c658332 100644
--- a/spring-integration-file/src/main/java/org/springframework/integration/file/filters/ExpressionFileListFilter.java
+++ b/spring-integration-file/src/main/java/org/springframework/integration/file/filters/ExpressionFileListFilter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 the original author or authors.
+ * Copyright 2017-2018 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.
@@ -30,6 +30,7 @@ import org.springframework.util.Assert;
* A SpEL expression based {@link AbstractFileListFilter} implementation.
*
* @author Artem Bilan
+ * @author Gary Russell
*
* @since 5.0
*/
@@ -61,7 +62,8 @@ public class ExpressionFileListFilter extends AbstractFileListFilter
@Override
public boolean accept(F file) {
- return this.expression.getValue(getEvaluationContext(), file, Boolean.class);
+ Boolean pass = this.expression.getValue(getEvaluationContext(), file, Boolean.class);
+ return pass == null ? false : pass;
}
private EvaluationContext getEvaluationContext() {
diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/gateway/AbstractRemoteFileOutboundGateway.java b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/gateway/AbstractRemoteFileOutboundGateway.java
index 084a258b54..09b5bc38d7 100644
--- a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/gateway/AbstractRemoteFileOutboundGateway.java
+++ b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/gateway/AbstractRemoteFileOutboundGateway.java
@@ -536,7 +536,9 @@ public abstract class AbstractRemoteFileOutboundGateway extends AbstractReply
|| Command.MGET.equals(this.command)) {
Assert.notNull(this.localDirectoryExpression, "localDirectory must not be null");
if (this.localDirectoryExpression instanceof ValueExpression) {
- File localDirectory = this.localDirectoryExpression.getValue(File.class);
+ File localDirectory = ExpressionUtils.expressionToFile(this.localDirectoryExpression,
+ ExpressionUtils.createStandardEvaluationContext(getBeanFactory()), null,
+ "localDirectoryExpression");
try {
if (!localDirectory.exists()) {
if (this.autoCreateLocalDirectory) {
diff --git a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParser.java b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParser.java
index fad2ab0e94..196d8cc78c 100644
--- a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParser.java
+++ b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014-2016 the original author or authors.
+ * Copyright 2014-2018 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.
@@ -54,7 +54,7 @@ public class FtpOutboundChannelAdapterParser extends RemoteFileOutboundChannelAd
.iterator()
.next()
.getValue();
- templateDefinition.getPropertyValues()
+ templateDefinition.getPropertyValues() // NOSONAR never null
.add("existsMode", FtpRemoteFileTemplate.ExistsMode.NLST);
}
diff --git a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpOutboundGatewayParser.java b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpOutboundGatewayParser.java
index d404f46285..76e506ab89 100644
--- a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpOutboundGatewayParser.java
+++ b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpOutboundGatewayParser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2017 the original author or authors.
+ * Copyright 2002-2018 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.
@@ -66,7 +66,7 @@ public class FtpOutboundGatewayParser extends AbstractRemoteFileOutboundGatewayP
.iterator()
.next()
.getValue();
- templateDefinition.getPropertyValues()
+ templateDefinition.getPropertyValues() // NOSONAR never null
.add("existsMode", FtpRemoteFileTemplate.ExistsMode.NLST);
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "working-dir-expression",
diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/dsl/FtpTests.java b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/dsl/FtpTests.java
index 6018c4cecc..3c5afaa274 100644
--- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/dsl/FtpTests.java
+++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/dsl/FtpTests.java
@@ -217,7 +217,7 @@ public class FtpTests extends FtpTestSupport {
assertNotNull(result);
List localFiles = (List) result.getPayload();
// should have filtered ftpSource2.txt
- assertEquals(2, localFiles.size());
+ assertEquals("unexpected local files " + localFiles, 2, localFiles.size());
for (File file : localFiles) {
assertThat(file.getPath().replaceAll(Matcher.quoteReplacement(File.separator), "/"),