diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/TimeoutCountSequenceSizeReleaseStrategy.java b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/TimeoutCountSequenceSizeReleaseStrategy.java
index 478ab8c2af..42348be093 100755
--- a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/TimeoutCountSequenceSizeReleaseStrategy.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/TimeoutCountSequenceSizeReleaseStrategy.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.
@@ -25,10 +25,12 @@ import org.springframework.messaging.Message;
*
* - The sequence is complete (if there is one).
* - There are more messages than a threshold set by the user.
- * - The time elapsed since the earliest message, according to their timestamps, exceeds a timeout set by the user.
+ * - The time elapsed since the earliest message, according to their timestamps, if
+ * present, exceeds a timeout set by the user.
*
*
* @author Dave Syer
+ * @author Gary Russell
*
* @since 2.0
*/
@@ -61,6 +63,7 @@ public class TimeoutCountSequenceSizeReleaseStrategy implements ReleaseStrategy
this.timeout = timeout;
}
+ @Override
public boolean canRelease(MessageGroup messages) {
long elapsedTime = System.currentTimeMillis() - findEarliestTimestamp(messages);
return messages.isComplete() || messages.getMessages().size() >= this.threshold || elapsedTime > this.timeout;
@@ -73,10 +76,13 @@ public class TimeoutCountSequenceSizeReleaseStrategy implements ReleaseStrategy
private long findEarliestTimestamp(MessageGroup messages) {
long result = Long.MAX_VALUE;
for (Message> message : messages.getMessages()) {
- long timestamp = message.getHeaders().getTimestamp();
- if (timestamp < result) {
+ Long timestamp = message.getHeaders().getTimestamp();
+ if (timestamp != null && timestamp < result) {
result = timestamp;
}
+ else {
+ return Long.MAX_VALUE; // can't release based on time if there is no timestamp
+ }
}
return result;
}
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java
index 66b18e4e57..d7721ef3f1 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java
@@ -253,6 +253,7 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
}
@Override
+ @Nullable
public ChannelInterceptor removeInterceptor(int index) {
return this.interceptors.remove(index);
}
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/ChannelInterceptorAware.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/ChannelInterceptorAware.java
index 2bab05015c..fb1b8c4137 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/channel/ChannelInterceptorAware.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/ChannelInterceptorAware.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.
@@ -18,6 +18,7 @@ package org.springframework.integration.channel;
import java.util.List;
+import org.springframework.lang.Nullable;
import org.springframework.messaging.support.ChannelInterceptor;
/**
@@ -28,6 +29,7 @@ import org.springframework.messaging.support.ChannelInterceptor;
* is an AOP Proxy.
* *
* @author Artem Bilan
+ * @author Gary Russell
* @since 4.0
*/
public interface ChannelInterceptorAware {
@@ -69,6 +71,7 @@ public interface ChannelInterceptorAware {
* @param index the index for the {@link org.springframework.messaging.support.ChannelInterceptor} to remove.
* @return the {@code boolean} if the {@link ChannelInterceptor} has been removed.
*/
+ @Nullable
ChannelInterceptor removeInterceptor(int index);
}
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/MessagePublishingErrorHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/MessagePublishingErrorHandler.java
index 86976fc562..0a2159dcc7 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/channel/MessagePublishingErrorHandler.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/MessagePublishingErrorHandler.java
@@ -20,6 +20,7 @@ import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.core.ErrorMessagePublisher;
import org.springframework.integration.support.ErrorMessageStrategy;
import org.springframework.integration.support.MessagingExceptionWrapper;
+import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessagingException;
@@ -71,6 +72,7 @@ public class MessagePublishingErrorHandler extends ErrorMessagePublisher impleme
* @return the error channel.
* @since 4.3
*/
+ @Nullable
public MessageChannel getDefaultErrorChannel() {
return getChannel();
}
@@ -115,6 +117,7 @@ public class MessagePublishingErrorHandler extends ErrorMessagePublisher impleme
}
}
+ @Nullable
private MessageChannel resolveErrorChannel(Throwable t) {
Throwable actualThrowable = t;
if (t instanceof MessagingExceptionWrapper) {
@@ -137,7 +140,12 @@ public class MessagePublishingErrorHandler extends ErrorMessagePublisher impleme
Assert.isInstanceOf(String.class, errorChannelHeader,
"Unsupported error channel header type. Expected MessageChannel or String, but actual type is [" +
errorChannelHeader.getClass() + "]");
- return getChannelResolver().resolveDestination((String) errorChannelHeader);
+ if (getChannelResolver() != null) {
+ return getChannelResolver().resolveDestination((String) errorChannelHeader);
+ }
+ else {
+ return null;
+ }
}
}
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/AbstractSimpleMessageHandlerFactoryBean.java b/spring-integration-core/src/main/java/org/springframework/integration/config/AbstractSimpleMessageHandlerFactoryBean.java
index 4ba429ddd8..a7ce748ec0 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/config/AbstractSimpleMessageHandlerFactoryBean.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/config/AbstractSimpleMessageHandlerFactoryBean.java
@@ -275,10 +275,8 @@ public abstract class AbstractSimpleMessageHandlerFactoryBean basePackages = new HashSet<>();
- for (String pkg : (String[]) componentScan.get("value")) {
+ for (String pkg : (String[]) componentScan.get("value")) { // NOSONAR - never null
if (StringUtils.hasText(pkg)) {
basePackages.add(pkg);
}
@@ -210,7 +210,9 @@ public class IntegrationComponentScanRegistrar implements ImportBeanDefinitionRe
if (parserStrategyBean instanceof BeanClassLoaderAware) {
ClassLoader classLoader = (registry instanceof ConfigurableBeanFactory ?
((ConfigurableBeanFactory) registry).getBeanClassLoader() : resourceLoader.getClassLoader());
- ((BeanClassLoaderAware) parserStrategyBean).setBeanClassLoader(classLoader);
+ if (classLoader != null) {
+ ((BeanClassLoaderAware) parserStrategyBean).setBeanClassLoader(classLoader);
+ }
}
if (parserStrategyBean instanceof BeanFactoryAware && registry instanceof BeanFactory) {
((BeanFactoryAware) parserStrategyBean).setBeanFactory((BeanFactory) registry);
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 f7317d3ed6..8b2904fba6 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
@@ -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.
@@ -35,6 +35,7 @@ import org.springframework.integration.support.utils.IntegrationUtils;
/**
* @author Artem Bilan
+ * @author Gary Russell
* @since 4.0
*/
public class IntegrationConverterInitializer implements IntegrationConfigurationInitializer {
@@ -89,6 +90,6 @@ public class IntegrationConverterInitializer implements IntegrationConfiguration
.getValue();
}
- converters.add(converterBeanDefinition);
+ converters.add(converterBeanDefinition); // NOSONAR never null
}
}
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 13db27eec0..da0f88a9dc 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
@@ -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.
@@ -37,6 +37,7 @@ import org.springframework.integration.history.MessageHistoryConfigurer;
* or from {@code MessageHistoryParser}.
*
* @author Artem Bilan
+ * @author Gary Russell
* @since 4.0
*/
public class MessageHistoryRegistrar implements ImportBeanDefinitionRegistrar {
@@ -44,7 +45,7 @@ public class MessageHistoryRegistrar implements ImportBeanDefinitionRegistrar {
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
Map annotationAttributes = importingClassMetadata.getAnnotationAttributes(EnableMessageHistory.class.getName());
- Object componentNamePatterns = annotationAttributes.get("value");
+ Object componentNamePatterns = annotationAttributes.get("value"); // NOSONAR never null
if (componentNamePatterns instanceof String[]) {
StringBuilder componentNamePatternsString = new StringBuilder();
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/MessagingGatewayRegistrar.java b/spring-integration-core/src/main/java/org/springframework/integration/config/MessagingGatewayRegistrar.java
index e2482e175b..f381732326 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/config/MessagingGatewayRegistrar.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/config/MessagingGatewayRegistrar.java
@@ -66,7 +66,7 @@ public class MessagingGatewayRegistrar implements ImportBeanDefinitionRegistrar
List> valuesHierarchy = captureMetaAnnotationValues(importingClassMetadata);
Map annotationAttributes =
importingClassMetadata.getAnnotationAttributes(MessagingGateway.class.getName());
- replaceEmptyOverrides(valuesHierarchy, annotationAttributes);
+ replaceEmptyOverrides(valuesHierarchy, annotationAttributes); // NOSONAR never null
annotationAttributes.put("serviceInterface", importingClassMetadata.getClassName());
BeanDefinitionReaderUtils.registerBeanDefinition(this.parse(annotationAttributes), registry);
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/core/ErrorMessagePublisher.java b/spring-integration-core/src/main/java/org/springframework/integration/core/ErrorMessagePublisher.java
index 6ef96d80c0..e2c17136d4 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/core/ErrorMessagePublisher.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/core/ErrorMessagePublisher.java
@@ -105,6 +105,7 @@ public class ErrorMessagePublisher implements BeanFactoryAware {
return this.messagingTemplate;
}
+ @Nullable
protected DestinationResolver getChannelResolver() {
return this.channelResolver;
}