From 6e7653f18f12d91d354d05e2fb7f68d5793784d2 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Mon, 30 Jan 2017 22:27:59 -0500 Subject: [PATCH] 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** --- build.gradle | 4 +-- .../integration/amqp/rule/BrokerRunning.java | 10 +++---- .../AbstractCorrelatingMessageHandler.java | 6 ++-- .../IdempotentReceiverAutoProxyCreator.java | 4 +-- .../expression/ValueExpression.java | 4 +-- .../advice/IdempotentReceiverInterceptor.java | 4 +-- .../scattergather/ScatterGatherHandler.java | 8 +++--- .../selector/MetadataStoreSelector.java | 6 ++-- .../support/MutableMessageBuilder.java | 6 ++-- ...outingSlipHeaderValueMessageProcessor.java | 4 +-- ...ExistingConversionServiceTests-context.xml | 1 + ...serWithExistingConversionServiceTests.java | 28 ++++++++++++------- .../advice/AdvisedMessageHandlerTests.java | 2 ++ .../FileTailingMessageProducerSupport.java | 6 ++-- .../session/AbstractFtpSessionFactory.java | 8 +++--- .../ip/udp/DatagramPacketMessageMapper.java | 5 ++-- .../ip/udp/UnicastSendingMessageHandler.java | 5 ++-- .../integration/ip/udp/MulticastRule.java | 4 +-- .../integration/jpa/support/JpaUtils.java | 9 +++--- ...stractConfigurableMongoDbMessageStore.java | 8 +++--- .../sftp/session/SftpFileInfo.java | 4 +-- .../websocket/ClientWebSocketContainer.java | 4 +-- 22 files changed, 76 insertions(+), 64 deletions(-) diff --git a/build.gradle b/build.gradle index 1b0ce20a31..e2b0881c3f 100644 --- a/build.gradle +++ b/build.gradle @@ -127,7 +127,7 @@ subprojects { subproject -> slf4jVersion = "1.7.21" tomcatVersion = "8.0.33" smackVersion = '4.1.7' - springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '1.6.7.RELEASE' + springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '1.6.8.BUILD-SNAPSHOT' springDataJpaVersion = '1.10.1.RELEASE' springDataMongoVersion = '1.9.1.RELEASE' springDataRedisVersion = '1.7.1.RELEASE' @@ -135,7 +135,7 @@ subprojects { subproject -> springSecurityVersion = '4.1.0.RELEASE' springSocialTwitterVersion = '1.1.2.RELEASE' springRetryVersion = '1.1.3.RELEASE' - springVersion = project.hasProperty('springVersion') ? project.springVersion : '4.3.6.RELEASE' + springVersion = project.hasProperty('springVersion') ? project.springVersion : '4.3.7.BUILD-SNAPSHOT' springWsVersion = '2.3.0.RELEASE' xmlUnitVersion = '1.6' xstreamVersion = '1.4.7' diff --git a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/rule/BrokerRunning.java b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/rule/BrokerRunning.java index 1bbca00c47..71e55e4ebe 100644 --- a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/rule/BrokerRunning.java +++ b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/rule/BrokerRunning.java @@ -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. @@ -61,8 +61,8 @@ public class BrokerRunning extends TestWatcher { * @return a new rule that assumes an existing running broker */ public static BrokerRunning isRunningWithEmptyQueues(Queue... queues) { - Assert.notNull(queues); - Assert.noNullElements(queues); + Assert.notNull(queues, "'queues' must not be null"); + Assert.noNullElements(queues, "'queues' must not contain null elements"); return new BrokerRunning(queues); } @@ -72,8 +72,8 @@ public class BrokerRunning extends TestWatcher { * @return a new rule that assumes an existing running broker */ public static BrokerRunning isRunningWithEmptyQueues(String... queues) { - Assert.notNull(queues); - Assert.noNullElements(queues); + Assert.notNull(queues, "'queues' must not be null"); + Assert.noNullElements(queues, "'queues' must not contain null elements"); return new BrokerRunning(queues); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractCorrelatingMessageHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractCorrelatingMessageHandler.java index b42fa0daac..da6bc5ad96 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractCorrelatingMessageHandler.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractCorrelatingMessageHandler.java @@ -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; } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/IdempotentReceiverAutoProxyCreator.java b/spring-integration-core/src/main/java/org/springframework/integration/config/IdempotentReceiverAutoProxyCreator.java index 55f9ca1da6..0894aced19 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/IdempotentReceiverAutoProxyCreator.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/IdempotentReceiverAutoProxyCreator.java @@ -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> idempotentEndpoints; // double check locking requires volatile public void setIdempotentEndpointsMapping(List> idempotentEndpointsMapping) { - Assert.notEmpty(idempotentEndpointsMapping); + Assert.notEmpty(idempotentEndpointsMapping, "'idempotentEndpointsMapping' must not be empty"); this.idempotentEndpointsMapping = idempotentEndpointsMapping; //NOSONAR (inconsistent sync) } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/expression/ValueExpression.java b/spring-integration-core/src/main/java/org/springframework/integration/expression/ValueExpression.java index a4f8a36872..0e7b272bc3 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/expression/ValueExpression.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/expression/ValueExpression.java @@ -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 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) this.value.getClass(); this.typedResultValue = new TypedValue(this.value); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/IdempotentReceiverInterceptor.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/IdempotentReceiverInterceptor.java index 0a9009098b..134a345d38 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/IdempotentReceiverInterceptor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/IdempotentReceiverInterceptor.java @@ -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; } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/scattergather/ScatterGatherHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/scattergather/ScatterGatherHandler.java index e96acbb822..275c62f139 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/scattergather/ScatterGatherHandler.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/scattergather/ScatterGatherHandler.java @@ -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"); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/selector/MetadataStoreSelector.java b/spring-integration-core/src/main/java/org/springframework/integration/selector/MetadataStoreSelector.java index d56e038017..7d263f5c1d 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/selector/MetadataStoreSelector.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/selector/MetadataStoreSelector.java @@ -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 keyStrategy, MessageProcessor 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; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/MutableMessageBuilder.java b/spring-integration-core/src/main/java/org/springframework/integration/support/MutableMessageBuilder.java index 743518b983..77dde69ff4 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/MutableMessageBuilder.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/MutableMessageBuilder.java @@ -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 extends AbstractIntegrationMessageBu * @return A MutableMessageBuilder. */ public static MutableMessageBuilder fromMessage(Message message) { - Assert.notNull(message, "message must not be null"); + Assert.notNull(message, "'message' must not be null"); return new MutableMessageBuilder(message); } @@ -88,7 +88,7 @@ public final class MutableMessageBuilder extends AbstractIntegrationMessageBu @Override public AbstractIntegrationMessageBuilder setHeader(String headerName, Object headerValue) { - Assert.notNull(headerName); + Assert.notNull(headerName, "'headerName' must not be null"); if (headerValue == null) { this.removeHeader(headerName); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/support/RoutingSlipHeaderValueMessageProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/support/RoutingSlipHeaderValueMessageProcessor.java index 002a31ee64..972f735cca 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/support/RoutingSlipHeaderValueMessageProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/support/RoutingSlipHeaderValueMessageProcessor.java @@ -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 diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ConverterParserWithExistingConversionServiceTests-context.xml b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ConverterParserWithExistingConversionServiceTests-context.xml index fb1007a44d..3a868eb80e 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ConverterParserWithExistingConversionServiceTests-context.xml +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ConverterParserWithExistingConversionServiceTests-context.xml @@ -14,4 +14,5 @@ + diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ConverterParserWithExistingConversionServiceTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ConverterParserWithExistingConversionServiceTests.java index a20022297c..9e6555dc29 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ConverterParserWithExistingConversionServiceTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ConverterParserWithExistingConversionServiceTests.java @@ -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(); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/handler/advice/AdvisedMessageHandlerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/handler/advice/AdvisedMessageHandlerTests.java index 0f9d036de1..3c8d2fafe8 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/handler/advice/AdvisedMessageHandlerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/handler/advice/AdvisedMessageHandlerTests.java @@ -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; diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/tail/FileTailingMessageProducerSupport.java b/spring-integration-file/src/main/java/org/springframework/integration/file/tail/FileTailingMessageProducerSupport.java index 90647f2eea..94ca287881 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/tail/FileTailingMessageProducerSupport.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/tail/FileTailingMessageProducerSupport.java @@ -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. @@ -56,7 +56,7 @@ public abstract class FileTailingMessageProducerSupport extends MessageProducerS * @param file The absolute path of the file. */ public void setFile(File file) { - Assert.notNull("'file' cannot be null"); + Assert.notNull(file, "'file' cannot be null"); this.file = file; } @@ -72,7 +72,7 @@ public abstract class FileTailingMessageProducerSupport extends MessageProducerS * @param taskExecutor The task executor. */ public void setTaskExecutor(TaskExecutor taskExecutor) { - Assert.notNull("'taskExecutor' cannot be null"); + Assert.notNull(taskExecutor, "'taskExecutor' cannot be null"); this.taskExecutor = taskExecutor; } diff --git a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/session/AbstractFtpSessionFactory.java b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/session/AbstractFtpSessionFactory.java index f26ffaef83..e118dcface 100644 --- a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/session/AbstractFtpSessionFactory.java +++ b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/session/AbstractFtpSessionFactory.java @@ -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. @@ -82,12 +82,12 @@ public abstract class AbstractFtpSessionFactory implements } public void setControlEncoding(String controlEncoding) { - Assert.hasText(controlEncoding); + Assert.hasText(controlEncoding, "'controlEncoding' must not be empty"); this.controlEncoding = controlEncoding; } public void setConfig(FTPClientConfig config) { - Assert.notNull(config); + Assert.notNull(config, "'config' must not be null"); this.config = config; } @@ -96,7 +96,7 @@ public abstract class AbstractFtpSessionFactory implements } public void setHost(String host) { - Assert.hasText(host); + Assert.hasText(host, "'host' must not be empty"); this.host = host; } diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/udp/DatagramPacketMessageMapper.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/udp/DatagramPacketMessageMapper.java index 7d6180f369..5096990188 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/udp/DatagramPacketMessageMapper.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/udp/DatagramPacketMessageMapper.java @@ -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. @@ -38,6 +38,7 @@ import org.springframework.messaging.Message; import org.springframework.messaging.MessageHandlingException; import org.springframework.messaging.MessageHeaders; import org.springframework.util.Assert; +import org.springframework.util.StringUtils; /** * Message Mapper for converting to and from UDP DatagramPackets. When @@ -149,7 +150,7 @@ public class DatagramPacketMessageMapper implements InboundMessageMapper message) throws Exception { - Assert.hasLength(this.ackAddress); + Assert.state(StringUtils.hasText(this.ackAddress), "'ackAddress' must not be empty"); byte[] bytes = getPayloadAsBytes(message); ByteBuffer buffer = ByteBuffer.allocate(100 + bytes.length); if (this.lengthCheck) { diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/udp/UnicastSendingMessageHandler.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/udp/UnicastSendingMessageHandler.java index 26baf5b526..c3a45ed70e 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/udp/UnicastSendingMessageHandler.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/udp/UnicastSendingMessageHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2001-2016 the original author or authors. + * Copyright 2001-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. @@ -44,6 +44,7 @@ import org.springframework.messaging.MessageDeliveryException; import org.springframework.messaging.MessageHandlingException; import org.springframework.messaging.MessagingException; import org.springframework.util.Assert; +import org.springframework.util.StringUtils; /** * A {@link org.springframework.messaging.MessageHandler} implementation that maps a Message into @@ -213,7 +214,7 @@ public class UnicastSendingMessageHandler extends } this.acknowledge = acknowledge; if (this.acknowledge) { - Assert.hasLength(ackHost); + Assert.state(StringUtils.hasText(ackHost), "'ackHost' must not be empty"); } } diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/MulticastRule.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/MulticastRule.java index bdfd97ee11..48b0ab15f7 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/MulticastRule.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/MulticastRule.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 the original author or authors. + * Copyright 2015-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. @@ -47,7 +47,7 @@ public class MulticastRule extends TestWatcher { } public MulticastRule(String group) { - Assert.hasText(group); + Assert.hasText(group, "'group' must not be empty"); this.group = group; System.setProperty("java.net.preferIPv4Stack", "true"); System.setProperty("multicast.group", this.group); diff --git a/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/support/JpaUtils.java b/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/support/JpaUtils.java index 007634e632..8af17611cd 100644 --- a/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/support/JpaUtils.java +++ b/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/support/JpaUtils.java @@ -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. @@ -103,10 +103,9 @@ public final class JpaUtils { * */ public static Query applyAndBind(String queryString, Iterable entities, EntityManager entityManager) { - - Assert.notNull(queryString); - Assert.notNull(entities); - Assert.notNull(entityManager); + Assert.hasText(queryString, "'queryString' must not be empty"); + Assert.notNull(entities, "'entities' must not be null"); + Assert.notNull(entityManager, "'entityManager' must not be null"); Iterator iterator = entities.iterator(); diff --git a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/AbstractConfigurableMongoDbMessageStore.java b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/AbstractConfigurableMongoDbMessageStore.java index 9845238e21..90725cedd2 100644 --- a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/AbstractConfigurableMongoDbMessageStore.java +++ b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/AbstractConfigurableMongoDbMessageStore.java @@ -94,8 +94,8 @@ public abstract class AbstractConfigurableMongoDbMessageStore extends AbstractMe protected MessageBuilderFactory messageBuilderFactory = new DefaultMessageBuilderFactory(); public AbstractConfigurableMongoDbMessageStore(MongoTemplate mongoTemplate, String collectionName) { - Assert.notNull("'mongoTemplate' must not be null"); - Assert.hasText("'collectionName' must not be empty"); + Assert.notNull(mongoTemplate, "'mongoTemplate' must not be null"); + Assert.hasText(collectionName, "'collectionName' must not be empty"); this.collectionName = collectionName; this.mongoTemplate = mongoTemplate; this.mongoDbFactory = null; @@ -107,8 +107,8 @@ public abstract class AbstractConfigurableMongoDbMessageStore extends AbstractMe public AbstractConfigurableMongoDbMessageStore(MongoDbFactory mongoDbFactory, MappingMongoConverter mappingMongoConverter, String collectionName) { - Assert.notNull("'mongoDbFactory' must not be null"); - Assert.hasText("'collectionName' must not be empty"); + Assert.notNull(mongoDbFactory, "'mongoDbFactory' must not be null"); + Assert.hasText(collectionName, "'collectionName' must not be empty"); this.collectionName = collectionName; this.mongoDbFactory = mongoDbFactory; this.mappingMongoConverter = mappingMongoConverter; diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/SftpFileInfo.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/SftpFileInfo.java index 1fdbab626d..39c1df434a 100644 --- a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/SftpFileInfo.java +++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/SftpFileInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 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. @@ -37,7 +37,7 @@ public class SftpFileInfo extends AbstractFileInfo { public SftpFileInfo(LsEntry lsEntry) { - Assert.notNull("LsEntry must not be null"); + Assert.notNull(lsEntry, "'lsEntry' must not be null"); this.lsEntry = lsEntry; this.attrs = lsEntry.getAttrs(); } diff --git a/spring-integration-websocket/src/main/java/org/springframework/integration/websocket/ClientWebSocketContainer.java b/spring-integration-websocket/src/main/java/org/springframework/integration/websocket/ClientWebSocketContainer.java index 9d576db206..ee6417843b 100644 --- a/spring-integration-websocket/src/main/java/org/springframework/integration/websocket/ClientWebSocketContainer.java +++ b/spring-integration-websocket/src/main/java/org/springframework/integration/websocket/ClientWebSocketContainer.java @@ -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. @@ -76,7 +76,7 @@ public final class ClientWebSocketContainer extends IntegrationWebSocketContaine } public void setHeadersMap(Map headers) { - Assert.notNull(headers); + Assert.notNull(headers, "'headers' must not be null"); HttpHeaders httpHeaders = new HttpHeaders(); for (Map.Entry entry : headers.entrySet()) { String[] values = StringUtils.commaDelimitedListToStringArray(entry.getValue());