From a4bfd2cc42dbe5f9a8f4864bc19f43e096fa06cd 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 | 10 ++-- .../integration/amqp/rule/BrokerRunning.java | 10 ++-- .../AbstractCorrelatingMessageHandler.java | 6 +-- .../IdempotentReceiverAutoProxyCreator.java | 4 +- .../integration/dsl/AbstractRouterSpec.java | 4 +- .../integration/dsl/EnricherSpec.java | 14 +++--- .../integration/dsl/FilterEndpointSpec.java | 4 +- .../integration/dsl/HeaderEnricherSpec.java | 23 ++++----- .../dsl/IntegrationFlowDefinition.java | 48 +++++++++---------- .../integration/dsl/IntegrationFlows.java | 8 ++-- .../dsl/RecipientListRouterSpec.java | 6 +-- .../integration/dsl/RouterSpec.java | 10 ++-- .../dsl/channel/MessageChannelSpec.java | 8 ++-- .../dsl/support/MessageChannelReference.java | 4 +- .../endpoint/ReactiveConsumer.java | 4 +- .../expression/ValueExpression.java | 4 +- .../handler/BeanNameMessageProcessor.java | 4 +- .../handler/LambdaMessageProcessor.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 + .../integration/file/dsl/TailAdapterSpec.java | 4 +- .../FileTailingMessageProducerSupport.java | 6 +-- .../session/AbstractFtpSessionFactory.java | 8 ++-- .../ip/udp/DatagramPacketMessageMapper.java | 5 +- .../ip/udp/UnicastSendingMessageHandler.java | 5 +- .../integration/ip/udp/MulticastRule.java | 4 +- .../jms/dsl/JmsInboundChannelAdapterSpec.java | 4 +- .../jms/dsl/JmsInboundGatewaySpec.java | 4 +- .../JmsMessageDrivenChannelAdapterSpec.java | 4 +- .../dsl/JmsOutboundChannelAdapterSpec.java | 4 +- .../jms/dsl/JmsOutboundGatewaySpec.java | 4 +- .../integration/jpa/support/JpaUtils.java | 9 ++-- ...stractConfigurableMongoDbMessageStore.java | 8 ++-- .../integration/scripting/dsl/ScriptSpec.java | 14 +++--- .../sftp/session/SftpFileInfo.java | 4 +- .../websocket/ClientWebSocketContainer.java | 4 +- 42 files changed, 170 insertions(+), 155 deletions(-) diff --git a/build.gradle b/build.gradle index 547c65849b..499ee5a957 100644 --- a/build.gradle +++ b/build.gradle @@ -131,13 +131,13 @@ subprojects { subproject -> slf4jVersion = "1.7.21" smackVersion = '4.1.7' springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '2.0.0.BUILD-SNAPSHOT' - springDataJpaVersion = '2.0.0.M1' - springDataMongoVersion = '2.0.0.M1' - springDataRedisVersion = '2.0.0.M1' + springDataJpaVersion = '2.0.0.BUILD-SNAPSHOT' + springDataMongoVersion = '2.0.0.BUILD-SNAPSHOT' + springDataRedisVersion = '2.0.0.BUILD-SNAPSHOT' springGemfireVersion = '2.0.0.BUILD-SNAPSHOT' - springSecurityVersion = '4.2.0.RELEASE' + springSecurityVersion = '4.2.2.BUILD-SNAPSHOT' springSocialTwitterVersion = '2.0.0.M1' - springRetryVersion = '1.2.0.RC1' + springRetryVersion = '1.2.0.RELEASE' springVersion = project.hasProperty('springVersion') ? project.springVersion : '5.0.0.BUILD-SNAPSHOT' springWsVersion = '2.4.0.RELEASE' tomcatVersion = "8.5.9" 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 a02ec2b022..9ae374f9ad 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 @@ -158,7 +158,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; this.releaseStrategySet = true; 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/dsl/AbstractRouterSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/AbstractRouterSpec.java index 58f505f365..20f4ba239e 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/AbstractRouterSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/AbstractRouterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-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. @@ -97,7 +97,7 @@ public class AbstractRouterSpec, R extends Ab * @since 1.2 */ public S defaultSubFlowMapping(IntegrationFlow subFlow) { - Assert.notNull(subFlow); + Assert.notNull(subFlow, "'subFlow' must not be null"); DirectChannel channel = new DirectChannel(); IntegrationFlowBuilder flowBuilder = IntegrationFlows.from(channel); subFlow.configure(flowBuilder); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/EnricherSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/EnricherSpec.java index 1a0aeefc5b..41d3c8bd8d 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/EnricherSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/EnricherSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-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. @@ -164,7 +164,7 @@ public class EnricherSpec extends MessageHandlerSpec the value type. * @return the enricher spec. * @see ContentEnricher#setHeaderExpressions(Map) */ - public EnricherSpec header(String name, HeaderValueMessageProcessor headerValueMessageProcessor) { - Assert.hasText(name); - this.headerExpressions.put(name, headerValueMessageProcessor); + public EnricherSpec header(String headerName, HeaderValueMessageProcessor headerValueMessageProcessor) { + Assert.hasText(headerName, "'headerName' must not be empty"); + this.headerExpressions.put(headerName, headerValueMessageProcessor); return _this(); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/FilterEndpointSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/FilterEndpointSpec.java index e680c93458..d3c0519fb2 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/FilterEndpointSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/FilterEndpointSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-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. @@ -87,7 +87,7 @@ public final class FilterEndpointSpec extends ConsumerEndpointSpec headers, Boolean overwrite) { - Assert.notNull(headers); + Assert.notNull(headers, "'headers' must not be null"); return headers(headers.get(), overwrite); } @@ -171,7 +171,7 @@ public class HeaderEnricherSpec extends IntegrationComponentSpec headers, Boolean overwrite) { - Assert.notNull(headers); + Assert.notNull(headers, "'headers' must not be null"); for (Entry entry : headers.entrySet()) { String name = entry.getKey(); Object value = entry.getValue(); @@ -209,7 +209,7 @@ public class HeaderEnricherSpec extends IntegrationComponentSpec headers, Boolean overwrite) { - Assert.notNull(headers); + Assert.notNull(headers, "'headers' must not be null"); return headerExpressions(headers.get(), overwrite); } @@ -251,7 +251,7 @@ public class HeaderEnricherSpec extends IntegrationComponentSpec configurer, Boolean overwrite) { - Assert.notNull(configurer); + Assert.notNull(configurer, "'configurer' must not be null"); StringStringMapBuilder builder = new StringStringMapBuilder(); configurer.accept(builder); return headerExpressions(builder.get(), overwrite); @@ -278,7 +278,7 @@ public class HeaderEnricherSpec extends IntegrationComponentSpec headers, Boolean overwrite) { - Assert.notNull(headers); + Assert.notNull(headers, "'headers' must not be null"); for (Entry entry : headers.entrySet()) { AbstractHeaderValueMessageProcessor processor = new ExpressionEvaluatingHeaderValueMessageProcessor(entry.getValue(), null); @@ -336,7 +336,7 @@ public class HeaderEnricherSpec extends IntegrationComponentSpec the value type. * @return the header enricher spec. */ - public HeaderEnricherSpec header(String name, HeaderValueMessageProcessor headerValueMessageProcessor) { - Assert.hasText(name); - this.headerToAdd.put(name, headerValueMessageProcessor); + public HeaderEnricherSpec header(String headerName, + HeaderValueMessageProcessor headerValueMessageProcessor) { + Assert.hasText(headerName, "'headerName' must not be empty"); + this.headerToAdd.put(headerName, headerValueMessageProcessor); return _this(); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlowDefinition.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlowDefinition.java index a11cb21c18..13b076bc66 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlowDefinition.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlowDefinition.java @@ -194,7 +194,7 @@ public abstract class IntegrationFlowDefinition messageChannelSpec) { - Assert.notNull(messageChannelSpec); + Assert.notNull(messageChannelSpec, "'messageChannelSpec' must not be null"); return channel(messageChannelSpec.get()); } @@ -208,7 +208,7 @@ public abstract class IntegrationFlowDefinition> channels) { - Assert.notNull(channels); + Assert.notNull(channels, "'channels' must not be null"); return channel(channels.apply(new Channels())); } @@ -250,7 +250,7 @@ public abstract class IntegrationFlowDefinition publishSubscribeChannelConfigurer) { - Assert.notNull(publishSubscribeChannelConfigurer); + Assert.notNull(publishSubscribeChannelConfigurer, "'publishSubscribeChannelConfigurer' must not be null"); PublishSubscribeSpec spec = new PublishSubscribeSpec(executor); publishSubscribeChannelConfigurer.accept(spec); return addComponents(spec.getComponentsToRegister()).channel(spec); @@ -468,7 +468,7 @@ public abstract class IntegrationFlowDefinition> endpointConfigurer) { - Assert.hasText(expression); + Assert.hasText(expression, "'expression' must not be empty"); return transform(new ExpressionEvaluatingTransformer(PARSER.parseExpression(expression)), endpointConfigurer); } @@ -564,7 +564,7 @@ public abstract class IntegrationFlowDefinition messageProcessorSpec, Consumer> endpointConfigurer) { - Assert.notNull(messageProcessorSpec); + Assert.notNull(messageProcessorSpec, "'messageProcessorSpec' must not be null"); MessageProcessor processor = messageProcessorSpec.get(); return addComponent(processor) .transform(new MethodInvokingTransformer(processor), endpointConfigurer); @@ -618,7 +618,7 @@ public abstract class IntegrationFlowDefinition B transform(Class

payloadType, GenericTransformer genericTransformer, Consumer> endpointConfigurer) { - Assert.notNull(genericTransformer); + Assert.notNull(genericTransformer, "'genericTransformer' must not be null"); Transformer transformer = genericTransformer instanceof Transformer ? (Transformer) genericTransformer : (isLambda(genericTransformer) ? new MethodInvokingTransformer(new LambdaMessageProcessor(genericTransformer, payloadType)) @@ -650,7 +650,7 @@ public abstract class IntegrationFlowDefinition endpointConfigurer) { - Assert.hasText(expression); + Assert.hasText(expression, "'expression' must not be empty"); return filter(new ExpressionEvaluatingSelector(expression), endpointConfigurer); } @@ -746,7 +746,7 @@ public abstract class IntegrationFlowDefinition messageProcessorSpec, Consumer endpointConfigurer) { - Assert.notNull(messageProcessorSpec); + Assert.notNull(messageProcessorSpec, "'messageProcessorSpec' must not be null"); MessageProcessor processor = messageProcessorSpec.get(); return addComponent(processor) .filter(new MethodInvokingSelector(processor), endpointConfigurer); @@ -811,7 +811,7 @@ public abstract class IntegrationFlowDefinition B filter(Class

payloadType, GenericSelector

genericSelector, Consumer endpointConfigurer) { - Assert.notNull(genericSelector); + Assert.notNull(genericSelector, "'genericSelector' must not be null"); MessageSelector selector = genericSelector instanceof MessageSelector ? (MessageSelector) genericSelector : (isLambda(genericSelector) ? new MethodInvokingSelector(new LambdaMessageProcessor(genericSelector, payloadType)) @@ -1053,7 +1053,7 @@ public abstract class IntegrationFlowDefinition messageProcessorSpec, Consumer> endpointConfigurer) { - Assert.notNull(messageProcessorSpec); + Assert.notNull(messageProcessorSpec, "'messageProcessorSpec' must not be null"); MessageProcessor processor = messageProcessorSpec.get(); return addComponent(processor) .handle(new ServiceActivatingHandler(processor), endpointConfigurer); @@ -1078,7 +1078,7 @@ public abstract class IntegrationFlowDefinition B handle(MessageHandlerSpec messageHandlerSpec, Consumer> endpointConfigurer) { - Assert.notNull(messageHandlerSpec); + Assert.notNull(messageHandlerSpec, "'messageHandlerSpec' must not be null"); if (messageHandlerSpec instanceof ComponentsRegistration) { addComponents(((ComponentsRegistration) messageHandlerSpec).getComponentsToRegister()); } @@ -1188,7 +1188,7 @@ public abstract class IntegrationFlowDefinition enricherConfigurer, Consumer> endpointConfigurer) { - Assert.notNull(enricherConfigurer); + Assert.notNull(enricherConfigurer, "'enricherConfigurer' must not be null"); EnricherSpec enricherSpec = new EnricherSpec(); enricherConfigurer.accept(enricherSpec); return this.handle(enricherSpec.get(), endpointConfigurer); @@ -1315,7 +1315,7 @@ public abstract class IntegrationFlowDefinition headerEnricherConfigurer, Consumer> endpointConfigurer) { - Assert.notNull(headerEnricherConfigurer); + Assert.notNull(headerEnricherConfigurer, "'headerEnricherConfigurer' must not be null"); HeaderEnricherSpec headerEnricherSpec = new HeaderEnricherSpec(); headerEnricherConfigurer.accept(headerEnricherSpec); return transform(headerEnricherSpec.get(), endpointConfigurer); @@ -1370,7 +1370,7 @@ public abstract class IntegrationFlowDefinition> endpointConfigurer) { - Assert.hasText(expression); + Assert.hasText(expression, "'expression' must not be empty"); return split(new ExpressionEvaluatingSplitter(PARSER.parseExpression(expression)), endpointConfigurer); } @@ -1485,7 +1485,7 @@ public abstract class IntegrationFlowDefinition messageProcessorSpec, Consumer> endpointConfigurer) { - Assert.notNull(messageProcessorSpec); + Assert.notNull(messageProcessorSpec, "'messageProcessorSpec' must not be null"); MessageProcessor processor = messageProcessorSpec.get(); return addComponent(processor) .split(new MethodInvokingSplitter(processor), endpointConfigurer); @@ -1598,7 +1598,7 @@ public abstract class IntegrationFlowDefinition B split(MessageHandlerSpec splitterMessageHandlerSpec, Consumer> endpointConfigurer) { - Assert.notNull(splitterMessageHandlerSpec); + Assert.notNull(splitterMessageHandlerSpec, "'splitterMessageHandlerSpec' must not be null"); return split(splitterMessageHandlerSpec.get(), endpointConfigurer); } @@ -1624,7 +1624,7 @@ public abstract class IntegrationFlowDefinition B split(S splitter, Consumer> endpointConfigurer) { - Assert.notNull(splitter); + Assert.notNull(splitter, "'splitter' must not be null"); return this.register(new SplitterEndpointSpec<>(splitter), endpointConfigurer); } @@ -2128,7 +2128,7 @@ public abstract class IntegrationFlowDefinition messageProcessorSpec, Consumer> routerConfigurer, Consumer> endpointConfigurer) { - Assert.notNull(messageProcessorSpec); + Assert.notNull(messageProcessorSpec, "'messageProcessorSpec' must not be null"); MessageProcessor processor = messageProcessorSpec.get(); return addComponent(processor) .route(new MethodInvokingRouter(processor), routerConfigurer, endpointConfigurer); @@ -2354,7 +2354,7 @@ public abstract class IntegrationFlowDefinition endpointConfigurer) { - Assert.notNull(flow); + Assert.notNull(flow, "'flow' must not be null"); final DirectChannel requestChannel = new DirectChannel(); IntegrationFlowBuilder flowBuilder = IntegrationFlows.from(requestChannel); flow.configure(flowBuilder); @@ -2429,7 +2429,7 @@ public abstract class IntegrationFlowDefinition B log(Function, Object> function) { - Assert.notNull(function); + Assert.notNull(function, "'function' must not be null"); return log(new FunctionExpression<>(function)); } @@ -2545,7 +2545,7 @@ public abstract class IntegrationFlowDefinition B log(LoggingHandler.Level level, String category, Function, Object> function) { - Assert.notNull(function); + Assert.notNull(function, "'function' must not be null"); return log(level, category, new FunctionExpression<>(function)); } @@ -2665,7 +2665,7 @@ public abstract class IntegrationFlowDefinition scatterer, Consumer gatherer, Consumer scatterGather) { - Assert.notNull(scatterer); + Assert.notNull(scatterer, "'scatterer' must not be null"); RecipientListRouterSpec recipientListRouterSpec = new RecipientListRouterSpec(); scatterer.accept(recipientListRouterSpec); AggregatorSpec aggregatorSpec = new AggregatorSpec(); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlows.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlows.java index ab4dc76c2a..09e9a781a2 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlows.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlows.java @@ -89,7 +89,7 @@ public final class IntegrationFlows { * @see org.springframework.integration.dsl.channel.MessageChannels */ public static IntegrationFlowBuilder from(MessageChannelSpec messageChannelSpec) { - Assert.notNull(messageChannelSpec); + Assert.notNull(messageChannelSpec, "'messageChannelSpec' must not be null"); return from(messageChannelSpec.get()); } @@ -128,7 +128,7 @@ public final class IntegrationFlows { */ public static IntegrationFlowBuilder from(MessageSourceSpec> messageSourceSpec, Consumer endpointConfigurer) { - Assert.notNull(messageSourceSpec); + Assert.notNull(messageSourceSpec, "'messageSourceSpec' must not be null"); return from(messageSourceSpec.get(), endpointConfigurer, registerComponents(messageSourceSpec)); } @@ -158,8 +158,8 @@ public final class IntegrationFlows { */ public static IntegrationFlowBuilder from(Object service, String methodName, Consumer endpointConfigurer) { - Assert.notNull(service); - Assert.hasText(methodName); + Assert.notNull(service, "'service' must not be null"); + Assert.hasText(methodName, "'methodName' must not be empty"); MethodInvokingMessageSource messageSource = new MethodInvokingMessageSource(); messageSource.setObject(service); messageSource.setMethodName(methodName); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/RecipientListRouterSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/RecipientListRouterSpec.java index 758dbb8eee..83a49ce512 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/RecipientListRouterSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/RecipientListRouterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-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. @@ -204,7 +204,7 @@ public class RecipientListRouterSpec extends AbstractRouterSpec RecipientListRouterSpec recipientFlow(GenericSelector

selector, IntegrationFlow subFlow) { - Assert.notNull(subFlow); + Assert.notNull(subFlow, "'subFlow' must not be null"); DirectChannel channel = populateSubFlow(subFlow); return recipient(channel, selector); } @@ -238,7 +238,7 @@ public class RecipientListRouterSpec extends AbstractRouterSpec * @see AbstractMappingMessageRouter#setChannelMapping(String, String) */ public RouterSpec channelMapping(K key, final String channelName) { - Assert.notNull(key); - Assert.hasText(channelName); + Assert.notNull(key, "'key' must not be null"); + Assert.hasText(channelName, "'channelName' must not be null"); if (key instanceof String) { this.target.setChannelMapping((String) key, channelName); } @@ -131,8 +131,8 @@ public final class RouterSpec * @return the router spec. */ public RouterSpec subFlowMapping(K key, IntegrationFlow subFlow) { - Assert.notNull(key); - Assert.notNull(subFlow); + Assert.notNull(key, "'key' must not be null"); + Assert.notNull(subFlow, "'subFlow' must not be null"); Assert.state(!(StringUtils.hasText(this.prefix) || StringUtils.hasText(this.suffix)), "The 'prefix'('suffix') and 'subFlowMapping' are mutually exclusive"); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/channel/MessageChannelSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/channel/MessageChannelSpec.java index 8efc0a38dc..85010e75f0 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/channel/MessageChannelSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/channel/MessageChannelSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-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. @@ -64,13 +64,15 @@ public abstract class MessageChannelSpec, C e } public S datatype(Class... datatypes) { - Assert.noNullElements(datatypes); + Assert.notNull(datatypes, "'datatypes' must not be null"); + Assert.noNullElements(datatypes, "'datatypes' must not contain null elements"); this.datatypes.addAll(Arrays.asList(datatypes)); return _this(); } public S interceptor(ChannelInterceptor... interceptors) { - Assert.noNullElements(interceptors); + Assert.notNull(interceptors, "'interceptors' must not be null"); + Assert.noNullElements(interceptors, "'interceptors' must not contain null elements"); this.interceptors.addAll(Arrays.asList(interceptors)); return _this(); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/support/MessageChannelReference.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/support/MessageChannelReference.java index 065b105309..d357a2824e 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/support/MessageChannelReference.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/support/MessageChannelReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-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. @@ -36,7 +36,7 @@ public class MessageChannelReference implements MessageChannel { private final String name; public MessageChannelReference(String name) { - Assert.notNull(name); + Assert.notNull(name, "'name' must not be null"); this.name = name; } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/ReactiveConsumer.java b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/ReactiveConsumer.java index deb7f835ed..d927d3bb7b 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/ReactiveConsumer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/ReactiveConsumer.java @@ -63,8 +63,8 @@ public class ReactiveConsumer extends AbstractEndpoint { @SuppressWarnings("unchecked") public ReactiveConsumer(MessageChannel inputChannel, Subscriber> subscriber) { - Assert.notNull(inputChannel); - Assert.notNull(subscriber); + Assert.notNull(inputChannel, "'inputChannel' must not be null"); + Assert.notNull(subscriber, "'subscriber' must not be null"); Publisher messagePublisher = MessageChannelReactiveUtils.toPublisher(inputChannel); this.publisher = (Publisher>) messagePublisher; 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/BeanNameMessageProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/BeanNameMessageProcessor.java index 984504bd93..9fcb67228e 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/handler/BeanNameMessageProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/BeanNameMessageProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-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 @@ public class BeanNameMessageProcessor implements MessageProcessor, BeanFac @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { - Assert.notNull(beanFactory); + Assert.notNull(beanFactory, "'beanFactory' must not be null"); this.beanFactory = beanFactory; } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/LambdaMessageProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/LambdaMessageProcessor.java index dd94340559..bab1829b01 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/handler/LambdaMessageProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/LambdaMessageProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-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. @@ -55,7 +55,7 @@ public class LambdaMessageProcessor implements MessageProcessor, BeanFac private ConversionService conversionService; public LambdaMessageProcessor(Object target, Class payloadType) { - Assert.notNull(target); + Assert.notNull(target, "'target' must not be null"); this.target = target; final AtomicReference methodValue = new AtomicReference<>(); ReflectionUtils.doWithMethods(target.getClass(), 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 362fe089d0..1af078eb66 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 f340cd4e25..fbe6b41606 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 925dc30537..0bd0671f62 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 @@ -642,6 +642,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/dsl/TailAdapterSpec.java b/spring-integration-file/src/main/java/org/springframework/integration/file/dsl/TailAdapterSpec.java index f5926abf65..5a63526b56 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/dsl/TailAdapterSpec.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/dsl/TailAdapterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-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. @@ -49,7 +49,7 @@ public class TailAdapterSpec extends MessageProducerSpec 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 bac767bb98..5479048d3c 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-jms/src/main/java/org/springframework/integration/jms/dsl/JmsInboundChannelAdapterSpec.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsInboundChannelAdapterSpec.java index 9963669651..fe106f6bfc 100644 --- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsInboundChannelAdapterSpec.java +++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsInboundChannelAdapterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-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. @@ -106,7 +106,7 @@ public class JmsInboundChannelAdapterSpec configurer) { - Assert.notNull(configurer); + Assert.notNull(configurer, "'configurer' must not be null"); configurer.accept(this.jmsTemplateSpec); return _this(); } diff --git a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsInboundGatewaySpec.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsInboundGatewaySpec.java index a5cdf0c545..b4d129e908 100644 --- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsInboundGatewaySpec.java +++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsInboundGatewaySpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-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. @@ -214,7 +214,7 @@ public class JmsInboundGatewaySpec> public JmsInboundGatewayListenerContainerSpec configureListenerContainer( Consumer> configurer) { - Assert.notNull(configurer); + Assert.notNull(configurer, "'configurer' must not be null"); configurer.accept(this.spec); return _this(); } diff --git a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsMessageDrivenChannelAdapterSpec.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsMessageDrivenChannelAdapterSpec.java index 06f0e29e2c..511550d4b9 100644 --- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsMessageDrivenChannelAdapterSpec.java +++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsMessageDrivenChannelAdapterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-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. @@ -120,7 +120,7 @@ public class JmsMessageDrivenChannelAdapterSpec configureListenerContainer( Consumer> configurer) { - Assert.notNull(configurer); + Assert.notNull(configurer, "'configurer' must not be null"); configurer.accept(this.spec); return _this(); } diff --git a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsOutboundChannelAdapterSpec.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsOutboundChannelAdapterSpec.java index 42b2a5ef82..be40ad2176 100644 --- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsOutboundChannelAdapterSpec.java +++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsOutboundChannelAdapterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-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. @@ -135,7 +135,7 @@ public class JmsOutboundChannelAdapterSpec configurer) { - Assert.notNull(configurer); + Assert.notNull(configurer, "'configurer' must not be null"); configurer.accept(this.jmsTemplateSpec); return _this(); } diff --git a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsOutboundGatewaySpec.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsOutboundGatewaySpec.java index a0810b608e..1a6967baf1 100644 --- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsOutboundGatewaySpec.java +++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsOutboundGatewaySpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-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. @@ -293,7 +293,7 @@ public class JmsOutboundGatewaySpec extends MessageHandlerSpec configurer) { - Assert.notNull(configurer); + Assert.notNull(configurer, "'configurer' must not be null"); ReplyContainerSpec spec = new ReplyContainerSpec(); configurer.accept(spec); this.target.setReplyContainerProperties(spec.get()); 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 455fcc8dc3..5af8249791 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 @@ -99,8 +99,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; @@ -112,8 +112,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-scripting/src/main/java/org/springframework/integration/scripting/dsl/ScriptSpec.java b/spring-integration-scripting/src/main/java/org/springframework/integration/scripting/dsl/ScriptSpec.java index cb18193593..5ce7ce3eb9 100644 --- a/spring-integration-scripting/src/main/java/org/springframework/integration/scripting/dsl/ScriptSpec.java +++ b/spring-integration-scripting/src/main/java/org/springframework/integration/scripting/dsl/ScriptSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-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. @@ -43,12 +43,12 @@ public class ScriptSpec extends MessageProcessorSpec { private Map variables = new HashMap(); ScriptSpec(Resource scriptResource) { - Assert.notNull(scriptResource); + Assert.notNull(scriptResource, "'scriptResource' must not be null"); this.processor = new DslScriptExecutingMessageProcessor(scriptResource); } ScriptSpec(String scriptLocation) { - Assert.hasText(scriptLocation); + Assert.hasText(scriptLocation, "'scriptLocation' must not be empty"); this.processor = new DslScriptExecutingMessageProcessor(scriptLocation); } @@ -59,7 +59,7 @@ public class ScriptSpec extends MessageProcessorSpec { * @see DslScriptExecutingMessageProcessor#setLang */ public ScriptSpec lang(String lang) { - Assert.hasText(lang); + Assert.hasText(lang, "'lang' must not be empty"); this.processor.setLang(lang); return this; } @@ -82,7 +82,7 @@ public class ScriptSpec extends MessageProcessorSpec { * @see org.springframework.integration.scripting.AbstractScriptExecutingMessageProcessor */ public ScriptSpec variableGenerator(ScriptVariableGenerator variableGenerator) { - Assert.notNull(variableGenerator); + Assert.notNull(variableGenerator, "'variableGenerator' must not be null"); Assert.state(this.variables.isEmpty(), "'variableGenerator' and 'variables' are mutually exclusive"); this.variableGenerator = variableGenerator; return this; @@ -105,7 +105,7 @@ public class ScriptSpec extends MessageProcessorSpec { * @see DefaultScriptVariableGenerator */ public ScriptSpec variables(Map variables) { - Assert.notEmpty(variables); + Assert.notEmpty(variables, "'variables' must not be empty"); Assert.state(this.variableGenerator == null, "'variableGenerator' and 'variables' are mutually exclusive"); this.variables.putAll(variables); return this; @@ -119,7 +119,7 @@ public class ScriptSpec extends MessageProcessorSpec { * @see DefaultScriptVariableGenerator */ public ScriptSpec variable(String name, Object value) { - Assert.hasText(name); + Assert.hasText(name, "'name' must not be empty"); Assert.state(this.variableGenerator == null, "'variableGenerator' and 'variables' are mutually exclusive"); this.variables.put(name, value); return this; 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 6540d15c9b..dfcf2ee2f8 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());