INT-4221: Properly use Spring's Assert class

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

* Upgrade to those versions of Spring project dependencies which potentially will provide similar fix

**Cherry-pick to 4.3.x**
This commit is contained in:
Artem Bilan
2017-01-30 22:27:59 -05:00
parent d9c6ffee74
commit 6e7653f18f
22 changed files with 76 additions and 64 deletions

View File

@@ -154,7 +154,7 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageP
public void setLockRegistry(LockRegistry lockRegistry) {
Assert.isTrue(!this.lockRegistrySet, "'this.lockRegistry' can not be reset once its been set");
Assert.notNull("'lockRegistry' must not be null");
Assert.notNull(lockRegistry, "'lockRegistry' must not be null");
this.lockRegistry = lockRegistry;
this.lockRegistrySet = true;
}
@@ -170,12 +170,12 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageP
}
public void setCorrelationStrategy(CorrelationStrategy correlationStrategy) {
Assert.notNull(correlationStrategy);
Assert.notNull(correlationStrategy, "'correlationStrategy' must not be null");
this.correlationStrategy = correlationStrategy;
}
public void setReleaseStrategy(ReleaseStrategy releaseStrategy) {
Assert.notNull(releaseStrategy);
Assert.notNull(releaseStrategy, "'releaseStrategy' must not be null");
this.releaseStrategy = releaseStrategy;
this.sequenceAware = this.releaseStrategy instanceof SequenceSizeReleaseStrategy;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2014-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.
@@ -48,7 +48,7 @@ class IdempotentReceiverAutoProxyCreator extends AbstractAutoProxyCreator {
private volatile Map<String, List<String>> idempotentEndpoints; // double check locking requires volatile
public void setIdempotentEndpointsMapping(List<Map<String, String>> idempotentEndpointsMapping) {
Assert.notEmpty(idempotentEndpointsMapping);
Assert.notEmpty(idempotentEndpointsMapping, "'idempotentEndpointsMapping' must not be empty");
this.idempotentEndpointsMapping = idempotentEndpointsMapping; //NOSONAR (inconsistent sync)
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014 the original author or authors.
* Copyright 2014-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,7 +45,7 @@ public class ValueExpression<V> implements Expression {
@SuppressWarnings("unchecked")
public ValueExpression(V value) {
Assert.notNull(value);
Assert.notNull(value, "'value' must not be null");
this.value = value;
this.aClass = (Class<V>) this.value.getClass();
this.typedResultValue = new TypedValue(this.value);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2014-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.
@@ -72,7 +72,7 @@ public class IdempotentReceiverInterceptor extends AbstractHandleMessageAdvice i
private BeanFactory beanFactory;
public IdempotentReceiverInterceptor(MessageSelector messageSelector) {
Assert.notNull(messageSelector);
Assert.notNull(messageSelector, "'messageSelector' must not be null");
this.messageSelector = messageSelector;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2014-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.
@@ -63,8 +63,8 @@ public class ScatterGatherHandler extends AbstractReplyProducingMessageHandler i
public ScatterGatherHandler(MessageChannel scatterChannel, MessageHandler gatherer) {
Assert.notNull(scatterChannel);
Assert.notNull(gatherer);
Assert.notNull(scatterChannel, "'scatterChannel' must not be null");
Assert.notNull(gatherer, "'gatherer' must not be null");
Class<?> gathererClass = AopUtils.getTargetClass(gatherer);
checkClass(gathererClass, "org.springframework.integration.aggregator.AggregatingMessageHandler", "gatherer");
this.scatterChannel = scatterChannel;
@@ -73,7 +73,7 @@ public class ScatterGatherHandler extends AbstractReplyProducingMessageHandler i
public ScatterGatherHandler(MessageHandler scatterer, MessageHandler gatherer) {
this(new FixedSubscriberChannel(scatterer), gatherer);
Assert.notNull(scatterer);
Assert.notNull(scatterer, "'scatterer' must not be null");
Class<?> scattererClass = AopUtils.getTargetClass(scatterer);
checkClass(scattererClass, "org.springframework.integration.router.RecipientListRouter", "scatterer");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014 the original author or authors.
* Copyright 2014-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.
@@ -70,8 +70,8 @@ public class MetadataStoreSelector implements MessageSelector {
public MetadataStoreSelector(MessageProcessor<String> keyStrategy, MessageProcessor<String> valueStrategy,
ConcurrentMetadataStore metadataStore) {
Assert.notNull(keyStrategy);
Assert.notNull(metadataStore);
Assert.notNull(keyStrategy, "'keyStrategy' must not be null");
Assert.notNull(metadataStore, "'metadataStore' must not be null");
this.metadataStore = metadataStore;
this.keyStrategy = keyStrategy;
this.valueStrategy = valueStrategy;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2014-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.
@@ -72,7 +72,7 @@ public final class MutableMessageBuilder<T> extends AbstractIntegrationMessageBu
* @return A MutableMessageBuilder.
*/
public static <T> MutableMessageBuilder<T> fromMessage(Message<T> message) {
Assert.notNull(message, "message must not be null");
Assert.notNull(message, "'message' must not be null");
return new MutableMessageBuilder<T>(message);
}
@@ -88,7 +88,7 @@ public final class MutableMessageBuilder<T> extends AbstractIntegrationMessageBu
@Override
public AbstractIntegrationMessageBuilder<T> setHeader(String headerName, Object headerValue) {
Assert.notNull(headerName);
Assert.notNull(headerName, "'headerName' must not be null");
if (headerValue == null) {
this.removeHeader(headerName);
}

View File

@@ -54,8 +54,8 @@ public class RoutingSlipHeaderValueMessageProcessor
private BeanFactory beanFactory;
public RoutingSlipHeaderValueMessageProcessor(Object... routingSlipPath) {
Assert.notNull(routingSlipPath);
Assert.noNullElements(routingSlipPath);
Assert.notNull(routingSlipPath, "'routingSlipPath' must not be null");
Assert.noNullElements(routingSlipPath, "'routingSlipPath' must not contain null elements");
for (Object entry : routingSlipPath) {
if (!(entry instanceof String
|| entry instanceof MessageChannel

View File

@@ -14,4 +14,5 @@
</int:converter>
<bean id="integrationConversionService" class="org.springframework.context.support.ConversionServiceFactoryBean"/>
</beans>

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.
@@ -16,6 +16,8 @@
package org.springframework.integration.config.xml;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -30,16 +32,17 @@ import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.integration.support.utils.IntegrationUtils;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.Assert;
/**
* @author Oleg Zhurakousky
* @author Artem Bilan
*
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
public class ConverterParserWithExistingConversionServiceTests {
@Autowired
private ApplicationContext applicationContext;
@@ -49,9 +52,10 @@ public class ConverterParserWithExistingConversionServiceTests {
@Test
public void testConversionServiceAvailability() {
Assert.isTrue(applicationContext.getBean(IntegrationUtils.INTEGRATION_CONVERSION_SERVICE_BEAN_NAME).equals(conversionService));
Assert.isTrue(conversionService.canConvert(TestBean1.class, TestBean2.class));
Assert.isTrue(conversionService.canConvert(TestBean1.class, TestBean3.class));
assertTrue(applicationContext.getBean(IntegrationUtils.INTEGRATION_CONVERSION_SERVICE_BEAN_NAME)
.equals(conversionService));
assertTrue(conversionService.canConvert(TestBean1.class, TestBean2.class));
assertTrue(conversionService.canConvert(TestBean1.class, TestBean3.class));
}
@Test
public void testParentConversionServiceAvailability() {
@@ -63,13 +67,17 @@ public class ConverterParserWithExistingConversionServiceTests {
childContext.refresh();
GenericConversionService conversionServiceParent = parentContext.getBean(IntegrationUtils.INTEGRATION_CONVERSION_SERVICE_BEAN_NAME, GenericConversionService.class);
GenericConversionService conversionServiceChild = childContext.getBean(IntegrationUtils.INTEGRATION_CONVERSION_SERVICE_BEAN_NAME, GenericConversionService.class);
Assert.isTrue(conversionServiceParent == conversionServiceChild); // validating that they are pointing to the same object
GenericConversionService conversionServiceParent =
parentContext.getBean(IntegrationUtils.INTEGRATION_CONVERSION_SERVICE_BEAN_NAME,
GenericConversionService.class);
GenericConversionService conversionServiceChild =
childContext.getBean(IntegrationUtils.INTEGRATION_CONVERSION_SERVICE_BEAN_NAME,
GenericConversionService.class);
assertTrue(conversionServiceParent == conversionServiceChild); // validating that they are pointing to the same object
conversionServiceChild.addConverter(new TestConverter());
conversionServiceChild.addConverter(new TestConverter3());
Assert.isTrue(conversionServiceChild.canConvert(TestBean1.class, TestBean2.class));
Assert.isTrue(conversionServiceChild.canConvert(TestBean1.class, TestBean3.class));
assertTrue(conversionServiceChild.canConvert(TestBean1.class, TestBean2.class));
assertTrue(conversionServiceChild.canConvert(TestBean1.class, TestBean3.class));
childContext.close();
parentContext.close();
}

View File

@@ -668,6 +668,8 @@ public class AdvisedMessageHandlerTests {
RetryTemplate retryTemplate = new RetryTemplate();
retryTemplate.setRetryPolicy(new SimpleRetryPolicy() {
static final long serialVersionUID = -1;
@Override
public boolean canRetry(RetryContext context) {
return false;