checkstyle WhiteAround

WhiteAroundCheck script
This commit is contained in:
Gary Russell
2016-04-05 13:29:21 -04:00
parent 842aded9a4
commit 05cc7be644
508 changed files with 2027 additions and 1916 deletions

View File

@@ -69,6 +69,7 @@ subprojects { subproject ->
apply from: "${rootDir}/src/checkstyle/fixModifiers.gradle"
apply from: "${rootDir}/src/checkstyle/fixThis.gradle"
apply from: "${rootDir}/src/checkstyle/fixRightCurly.gradle"
apply from: "${rootDir}/src/checkstyle/fixWhiteAround.gradle"
if (project.hasProperty('platformVersion')) {
apply plugin: 'spring-io'

View File

@@ -331,7 +331,8 @@ public class StubRabbitConnectionFactory implements ConnectionFactory {
@Override
public String getQueue() {
return queue;
}};
}
};
}
@Override

View File

@@ -65,7 +65,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@DirtiesContext(classMode=ClassMode.AFTER_EACH_TEST_METHOD)
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
public class ChannelTests extends LogAdjustingTestSupport {
@ClassRule

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@@ -102,7 +102,7 @@ public class AmqpInboundGatewayParserTests {
@SuppressWarnings("rawtypes")
@Test
public void verifyUsageWithHeaderMapper() throws Exception{
public void verifyUsageWithHeaderMapper() throws Exception {
DirectChannel requestChannel = context.getBean("requestChannel", DirectChannel.class);
requestChannel.subscribe(new MessageHandler() {
@Override
@@ -129,8 +129,8 @@ public class AmqpInboundGatewayParserTests {
MessageProperties properties = amqpReplyMessage.getMessageProperties();
assertEquals("bar", properties.getHeaders().get("bar"));
return null;
}})
.when(amqpTemplate).send(Mockito.any(String.class), Mockito.any(String.class),
}
}).when(amqpTemplate).send(Mockito.any(String.class), Mockito.any(String.class),
Mockito.any(Message.class), Mockito.any(CorrelationData.class));
ReflectionUtils.setField(amqpTemplateField, gateway, amqpTemplate);
@@ -166,6 +166,6 @@ public class AmqpInboundGatewayParserTests {
}
}
private static class TestConverter extends SimpleMessageConverter {}
private static class TestConverter extends SimpleMessageConverter { }
}

View File

@@ -51,7 +51,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@DirtiesContext(classMode=ClassMode.AFTER_EACH_TEST_METHOD)
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
public class AmqpOutboundEndpointTests {
@Rule

View File

@@ -56,7 +56,7 @@ public class ExpressionEvaluatingCorrelationStrategy implements CorrelationStrat
}
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
if (beanFactory != null){
if (beanFactory != null) {
this.processor.setBeanFactory(beanFactory);
}
}

View File

@@ -77,11 +77,11 @@ public class ResequencingMessageHandler extends AbstractCorrelatingMessageHandle
int size = messageGroup.getMessages().size();
int sequenceSize = 0;
Message<?> message = messageGroup.getOne();
if (message != null){
if (message != null) {
sequenceSize = new IntegrationMessageHeaderAccessor(message).getSequenceSize();
}
// If there is no sequence then it must be incomplete or unbounded
if (sequenceSize > 0 && sequenceSize == size){
if (sequenceSize > 0 && sequenceSize == size) {
remove(messageGroup);
}
else {

View File

@@ -38,7 +38,7 @@ public class SequenceNumberComparator implements Comparator<Message<?>> {
public int compare(Message<?> o1, Message<?> o2) {
Integer sequenceNumber1 = new IntegrationMessageHeaderAccessor(o1).getSequenceNumber();
Integer sequenceNumber2 = new IntegrationMessageHeaderAccessor(o2).getSequenceNumber();
if (sequenceNumber1 == sequenceNumber2) {//NOSONAR - early exit optimization
if (sequenceNumber1 == sequenceNumber2) { //NOSONAR - early exit optimization
return 0;
}
if (sequenceNumber1 == null) {

View File

@@ -88,13 +88,13 @@ public class SequenceSizeReleaseStrategy implements ReleaseStrategy {
else {
int size = messages.size();
if (size == 0){
if (size == 0) {
canRelease = true;
}
else {
int sequenceSize = new IntegrationMessageHeaderAccessor(messageGroup.getOne()).getSequenceSize();
// If there is no sequence then it must be incomplete....
if (sequenceSize == size){
if (sequenceSize == size) {
canRelease = true;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@@ -142,7 +142,7 @@ public class MessagePublishingInterceptor implements MethodInterceptor, BeanFact
context.setVariable(PublisherMetadataSource.RETURN_VALUE_VARIABLE_NAME, returnValue);
return returnValue;
}
catch (Throwable t) {//NOSONAR - rethrown below
catch (Throwable t) { //NOSONAR - rethrown below
context.setVariable(PublisherMetadataSource.EXCEPTION_VARIABLE_NAME, t);
throw t;
}
@@ -182,7 +182,7 @@ public class MessagePublishingInterceptor implements MethodInterceptor, BeanFact
}
else {
if (this.defaultChannelName != null) {
synchronized(this) {
synchronized (this) {
if (this.defaultChannelName != null && this.messagingTemplate.getDefaultDestination() == null) {
Assert.state(this.channelResolver != null,
"ChannelResolver is required to resolve channel names.");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@@ -84,7 +84,7 @@ public class PublisherAnnotationBeanPostProcessor extends ProxyConfig
@SuppressWarnings("deprecation")
@Override
public void afterPropertiesSet(){
public void afterPropertiesSet() {
this.advisor = new PublisherAnnotationAdvisor();
this.advisor.setBeanFactory(this.beanFactory);
this.advisor.setDefaultChannelName(this.defaultChannelName);

View File

@@ -159,7 +159,7 @@ public abstract class AbstractExecutorChannel extends AbstractSubscribableChanne
String description = "Failed to handle " + message + " to " + this + " in " + messageHandler;
throw new MessageDeliveryException(message, description, ex);
}
catch (Error ex) {//NOSONAR - ok, we re-throw below
catch (Error ex) { //NOSONAR - ok, we re-throw below
if (!CollectionUtils.isEmpty(interceptorStack)) {
String description = "Failed to handle " + message + " to " + this + " in " + messageHandler;
triggerAfterMessageHandled(message, new MessageDeliveryException(message, description, ex),
@@ -199,7 +199,7 @@ public abstract class AbstractExecutorChannel extends AbstractSubscribableChanne
interceptor.afterMessageHandled(message, AbstractExecutorChannel.this,
this.delegate.getMessageHandler(), ex);
}
catch (Throwable ex2) {//NOSONAR
catch (Throwable ex2) { //NOSONAR
logger.error("Exception from afterMessageHandled in " + interceptor, ex2);
}
}

View File

@@ -88,7 +88,7 @@ public class MessagePublishingErrorHandler implements ErrorHandler, BeanFactoryA
sent = errorChannel.send(new ErrorMessage(t));
}
}
catch (Throwable errorDeliveryError) {//NOSONAR
catch (Throwable errorDeliveryError) { //NOSONAR
// message will be logged only
if (this.logger.isWarnEnabled()) {
this.logger.warn("Error message was not delivered.", errorDeliveryError);

View File

@@ -75,7 +75,7 @@ public class NullChannel implements PollableChannel, MessageChannelMetrics,
@Override
public String getComponentName() {
return StringUtils.hasText(this.beanName) ? this.beanName: "nullChannel";
return StringUtils.hasText(this.beanName) ? this.beanName : "nullChannel";
}
@Override

View File

@@ -97,7 +97,7 @@ public class PriorityChannel extends QueueChannel {
protected Message<?> doReceive(long timeout) {
Message<?> message = super.doReceive(timeout);
if (message != null) {
message = ((MessageWrapper)message).getRootMessage();
message = ((MessageWrapper) message).getRootMessage();
this.upperBound.release();
}
return message;
@@ -107,14 +107,14 @@ public class PriorityChannel extends QueueChannel {
private final Comparator<Message<?>> targetComparator;
private SequenceFallbackComparator(Comparator<Message<?>> targetComparator){
private SequenceFallbackComparator(Comparator<Message<?>> targetComparator) {
this.targetComparator = targetComparator;
}
@Override
public int compare(Message<?> message1, Message<?> message2) {
int compareResult = 0;
if (this.targetComparator != null){
if (this.targetComparator != null) {
compareResult = this.targetComparator.compare(message1, message2);
}
else {
@@ -126,7 +126,7 @@ public class PriorityChannel extends QueueChannel {
compareResult = priority2.compareTo(priority1);
}
if (compareResult == 0){
if (compareResult == 0) {
Long sequence1 = ((MessageWrapper) message1).getSequence();
Long sequence2 = ((MessageWrapper) message2).getSequence();
compareResult = sequence1.compareTo(sequence2);
@@ -140,12 +140,12 @@ public class PriorityChannel extends QueueChannel {
private final Message<?> rootMessage;
private final long sequence;
private MessageWrapper(Message<?> rootMessage){
private MessageWrapper(Message<?> rootMessage) {
this.rootMessage = rootMessage;
this.sequence = PriorityChannel.this.sequenceCounter.incrementAndGet();
}
public Message<?> getRootMessage(){
public Message<?> getRootMessage() {
return this.rootMessage;
}
@@ -159,7 +159,7 @@ public class PriorityChannel extends QueueChannel {
return this.rootMessage.getPayload();
}
long getSequence(){
long getSequence() {
return this.sequence;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -66,7 +66,7 @@ public class PublishSubscribeChannel extends AbstractExecutorChannel {
@Override
public String getComponentType(){
public String getComponentType() {
return "publish-subscribe-channel";
}

View File

@@ -31,6 +31,6 @@ public final class RegistrationIds {
public static final int DEFAULT_MUTABLE_MESSAGEHEADERS_ID = 42;
private RegistrationIds() {}
private RegistrationIds() { }
}

View File

@@ -63,7 +63,7 @@ final class ChannelInitializer implements BeanFactoryAware, InitializingBean {
@Override
public void afterPropertiesSet() throws Exception {
Assert.notNull(this.beanFactory, "'beanFactory' must not be null");
if (!this.autoCreate){
if (!this.autoCreate) {
return;
}
else {
@@ -72,10 +72,10 @@ final class ChannelInitializer implements BeanFactoryAware, InitializingBean {
Assert.notNull(channelCandidatesCollector, "Failed to locate '" + IntegrationContextUtils.AUTO_CREATE_CHANNEL_CANDIDATES_BEAN_NAME);
// at this point channelNames are all resolved with placeholders and SpEL
Collection<String> channelNames = channelCandidatesCollector.getChannelNames();
if (channelNames != null){
if (channelNames != null) {
for (String channelName : channelNames) {
if (!this.beanFactory.containsBean(channelName)){
if (this.logger.isDebugEnabled()){
if (!this.beanFactory.containsBean(channelName)) {
if (this.logger.isDebugEnabled()) {
this.logger.debug("Auto-creating channel '" + channelName + "' as DirectChannel");
}
IntegrationConfigUtils.autoCreateDirectChannel(channelName, (BeanDefinitionRegistry) this.beanFactory);
@@ -92,7 +92,7 @@ final class ChannelInitializer implements BeanFactoryAware, InitializingBean {
private final Collection<String> channelNames;
AutoCreateCandidatesCollector(Collection<String> channelNames){
AutoCreateCandidatesCollector(Collection<String> channelNames) {
this.channelNames = channelNames;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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,7 +70,7 @@ final class GlobalChannelInterceptorProcessor implements BeanFactoryAware, Smart
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
Assert.isInstanceOf(ListableBeanFactory.class, beanFactory);
this.beanFactory = (ListableBeanFactory) beanFactory;//NOSONAR (inconsistent sync)
this.beanFactory = (ListableBeanFactory) beanFactory; //NOSONAR (inconsistent sync)
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2014-2016 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 @@ class IdempotentReceiverAutoProxyCreator extends AbstractAutoProxyCreator {
public void setIdempotentEndpointsMapping(List<Map<String, String>> idempotentEndpointsMapping) {
Assert.notEmpty(idempotentEndpointsMapping);
this.idempotentEndpointsMapping = idempotentEndpointsMapping;//NOSONAR (inconsistent sync)
this.idempotentEndpointsMapping = idempotentEndpointsMapping; //NOSONAR (inconsistent sync)
}
@Override
@@ -82,7 +82,7 @@ class IdempotentReceiverAutoProxyCreator extends AbstractAutoProxyCreator {
}
private void initIdempotentEndpointsIfNecessary() {
if (this.idempotentEndpoints == null) {//NOSONAR (inconsistent sync)
if (this.idempotentEndpoints == null) { //NOSONAR (inconsistent sync)
synchronized (this) {
if (this.idempotentEndpoints == null) {
this.idempotentEndpoints = new LinkedHashMap<String, List<String>>();

View File

@@ -43,7 +43,7 @@ public class MessageHistoryRegistrar implements ImportBeanDefinitionRegistrar {
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
Map<String,Object> annotationAttributes = importingClassMetadata.getAnnotationAttributes(EnableMessageHistory.class.getName());
Map<String, Object> annotationAttributes = importingClassMetadata.getAnnotationAttributes(EnableMessageHistory.class.getName());
Object componentNamePatterns = annotationAttributes.get("value");
if (componentNamePatterns instanceof String[]) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -127,7 +127,7 @@ public class ServiceActivatorFactoryBean extends AbstractStandardMessageHandlerF
handler.setSendTimeout(this.sendTimeout);
}
if (this.requiresReply != null) {
if(handler instanceof AbstractReplyProducingMessageHandler) {
if (handler instanceof AbstractReplyProducingMessageHandler) {
((AbstractReplyProducingMessageHandler) handler).setRequiresReply(this.requiresReply);
}
else {

View File

@@ -175,13 +175,13 @@ public class SourcePollingChannelAdapterFactoryBean implements FactoryBean<Sourc
Assert.notNull(this.pollerMetadata, "No poller has been defined for channel-adapter '"
+ this.beanName + "', and no default poller is available within the context.");
}
if (this.pollerMetadata.getMaxMessagesPerPoll() == Integer.MIN_VALUE){
if (this.pollerMetadata.getMaxMessagesPerPoll() == Integer.MIN_VALUE) {
// the default is 1 since a source might return
// a non-null and non-interruptible value every time it is invoked
this.pollerMetadata.setMaxMessagesPerPoll(1);
}
spca.setMaxMessagesPerPoll(this.pollerMetadata.getMaxMessagesPerPoll());
if (this.sendTimeout != null){
if (this.sendTimeout != null) {
spca.setSendTimeout(this.sendTimeout);
}
spca.setTaskExecutor(this.pollerMetadata.getTaskExecutor());

View File

@@ -119,7 +119,7 @@ public class SplitterFactoryBean extends AbstractStandardMessageHandlerFactoryBe
handler.setSendTimeout(this.sendTimeout);
}
if (this.requiresReply != null) {
if(handler instanceof AbstractReplyProducingMessageHandler) {
if (handler instanceof AbstractReplyProducingMessageHandler) {
((AbstractReplyProducingMessageHandler) handler).setRequiresReply(this.requiresReply);
}
else if (this.requiresReply && logger.isDebugEnabled()) {

View File

@@ -275,7 +275,7 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
return endpoint;
}
protected AbstractEndpoint doCreateEndpoint(MessageHandler handler, MessageChannel inputChannel,List<Annotation> annotations) {
protected AbstractEndpoint doCreateEndpoint(MessageHandler handler, MessageChannel inputChannel, List<Annotation> annotations) {
AbstractEndpoint endpoint;
if (inputChannel instanceof PollableChannel) {
PollingConsumer pollingConsumer = new PollingConsumer((PollableChannel) inputChannel, handler);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 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.
@@ -78,7 +78,7 @@ public class DelayerParser extends AbstractConsumerEndpointParser {
expressionBuilder = BeanDefinitionBuilder.genericBeanDefinition(ExpressionFactoryBean.class);
expressionBuilder.addConstructorArgValue(expression);
}
else if(expressionElement != null) {
else if (expressionElement != null) {
expressionBuilder = BeanDefinitionBuilder.genericBeanDefinition(
DynamicExpression.class);
String key = expressionElement.getAttribute("key");

View File

@@ -341,14 +341,14 @@ public abstract class IntegrationNamespaceUtils {
public static void configureHeaderMapper(Element element, BeanDefinitionBuilder rootBuilder,
ParserContext parserContext, BeanDefinitionBuilder headerMapperBuilder, String replyHeaderValue) {
String defaultMappedReplyHeadersAttributeName = "mapped-reply-headers";
if (!StringUtils.hasText(replyHeaderValue)){
if (!StringUtils.hasText(replyHeaderValue)) {
replyHeaderValue = defaultMappedReplyHeadersAttributeName;
}
boolean hasHeaderMapper = element.hasAttribute("header-mapper");
boolean hasMappedRequestHeaders = element.hasAttribute("mapped-request-headers");
boolean hasMappedReplyHeaders = element.hasAttribute(replyHeaderValue);
if (hasHeaderMapper && (hasMappedRequestHeaders || hasMappedReplyHeaders)){
if (hasHeaderMapper && (hasMappedRequestHeaders || hasMappedReplyHeaders)) {
parserContext.getReaderContext().error("The 'header-mapper' attribute is mutually exclusive with" +
" 'mapped-request-headers' or 'mapped-reply-headers'. " +
"You can only use one or the others", element);
@@ -356,7 +356,7 @@ public abstract class IntegrationNamespaceUtils {
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(rootBuilder, element, "header-mapper");
if (hasMappedRequestHeaders || hasMappedReplyHeaders){
if (hasMappedRequestHeaders || hasMappedReplyHeaders) {
if (hasMappedRequestHeaders) {
headerMapperBuilder.addPropertyValue("requestHeaderNames", element.getAttribute("mapped-request-headers"));
@@ -481,12 +481,12 @@ public abstract class IntegrationNamespaceUtils {
boolean hasAttributeValue = StringUtils.hasText(valueElementValue);
boolean hasAttributeExpression = StringUtils.hasText(expressionElementValue);
if (hasAttributeValue && hasAttributeExpression){
if (hasAttributeValue && hasAttributeExpression) {
parserContext.getReaderContext().error("Only one of '" + valueElementName + "' or '"
+ expressionElementName + "' is allowed", element);
}
if (oneRequired && (!hasAttributeValue && !hasAttributeExpression)){
if (oneRequired && (!hasAttributeValue && !hasAttributeExpression)) {
parserContext.getReaderContext().error("One of '" + valueElementName + "' or '"
+ expressionElementName + "' is required", element);
}
@@ -507,7 +507,7 @@ public abstract class IntegrationNamespaceUtils {
String expressionElementValue = element.getAttribute(expressionElementName);
if (StringUtils.hasText(expressionElementValue)){
if (StringUtils.hasText(expressionElementValue)) {
BeanDefinitionBuilder expressionDefBuilder = BeanDefinitionBuilder.genericBeanDefinition(ExpressionFactoryBean.class);
expressionDefBuilder.addConstructorArgValue(expressionElementValue);
return expressionDefBuilder.getRawBeanDefinition();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -46,7 +46,7 @@ public class ObjectToJsonTransformerParser extends AbstractTransformerParser {
if (StringUtils.hasText(resultType)) {
builder.addConstructorArgValue(resultType);
}
if (element.hasAttribute("content-type")){
if (element.hasAttribute("content-type")) {
builder.addPropertyValue("contentType", element.getAttribute("content-type"));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 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.
@@ -132,10 +132,10 @@ public class PointToPointChannelParser extends AbstractChannelParser {
// configure the default RoundRobinLoadBalancingStrategy
String loadBalancer = dispatcherElement.getAttribute("load-balancer");
String loadBalancerRef = dispatcherElement.getAttribute("load-balancer-ref");
if (StringUtils.hasText(loadBalancer) && StringUtils.hasText(loadBalancerRef)){
if (StringUtils.hasText(loadBalancer) && StringUtils.hasText(loadBalancerRef)) {
parserContext.getReaderContext().error("'load-balancer' and 'load-balancer-ref' are mutually exclusive", element);
}
if (StringUtils.hasText(loadBalancerRef)){
if (StringUtils.hasText(loadBalancerRef)) {
builder.addConstructorArgReference(loadBalancerRef);
}
else {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 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.
@@ -91,11 +91,11 @@ public class PollerParser extends AbstractBeanDefinitionParser {
IntegrationNamespaceUtils.configureAndSetAdviceChainIfPresent(adviceChainElement, txElement,
metadataBuilder.getRawBeanDefinition(), parserContext);
if (txElement != null){
if (txElement != null) {
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(metadataBuilder, txElement,
"synchronization-factory", "transactionSynchronizationFactory");
}
else if (adviceChainElement != null){
else if (adviceChainElement != null) {
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(metadataBuilder, adviceChainElement,
"synchronization-factory", "transactionSynchronizationFactory");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@@ -53,7 +53,7 @@ public class PublishingInterceptorParser extends AbstractBeanDefinitionParser {
MessagePublishingInterceptor.class);
BeanDefinitionBuilder spelSourceBuilder = BeanDefinitionBuilder
.genericBeanDefinition(MethodNameMappingPublisherMetadataSource.class);
Map<String, Map<?,?>> mappings = this.getMappings(element, element.getAttribute("default-channel"), parserContext);
Map<String, Map<?, ?>> mappings = this.getMappings(element, element.getAttribute("default-channel"), parserContext);
spelSourceBuilder.addConstructorArgValue(mappings.get("payload"));
if (mappings.get("headers") != null) {
spelSourceBuilder.addPropertyValue("headerExpressionMap", mappings.get("headers"));
@@ -62,7 +62,7 @@ public class PublishingInterceptorParser extends AbstractBeanDefinitionParser {
BeanDefinitionBuilder chResolverBuilder = BeanDefinitionBuilder.genericBeanDefinition(
BeanFactoryChannelResolver.class);
if (mappings.get("channels") != null){
if (mappings.get("channels") != null) {
spelSourceBuilder.addPropertyValue("channelMap", mappings.get("channels"));
}
String chResolverName =
@@ -75,9 +75,9 @@ public class PublishingInterceptorParser extends AbstractBeanDefinitionParser {
return rootBuilder.getBeanDefinition();
}
private Map<String,Map<?,?>> getMappings(Element element, String defaultChannel, ParserContext parserContext) {
private Map<String, Map<?, ?>> getMappings(Element element, String defaultChannel, ParserContext parserContext) {
List<Element> mappings = DomUtils.getChildElementsByTagName(element, "method");
Map<String, Map<?,?>> interceptorMappings = new HashMap<String, Map<?,?>>();
Map<String, Map<?, ?>> interceptorMappings = new HashMap<String, Map<?, ?>>();
Map<String, String> payloadExpressionMap = new HashMap<String, String>();
Map<String, Map<String, String>> headersExpressionMap = new HashMap<String, Map<String, String>>();
Map<String, String> channelMap = new HashMap<String, String>();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -59,7 +59,7 @@ public class RecipientListRouterParser extends AbstractRouterParser {
}
recipientList.add(recipientBuilder.getBeanDefinition());
}
if(recipientList.size() > 0) {
if (recipientList.size() > 0) {
recipientListRouterBuilder.addPropertyValue("recipients", recipientList);
}
return recipientListRouterBuilder.getBeanDefinition();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2016 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.
@@ -40,9 +40,9 @@ public class ResourceInboundChannelAdapterParser extends AbstractPollingInboundC
sourceBuilder.addConstructorArgValue(element.getAttribute("pattern"));
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(sourceBuilder, element, "pattern-resolver");
boolean hasFilter = element.hasAttribute("filter");
if (hasFilter){
if (hasFilter) {
String filterValue = element.getAttribute("filter");
if (StringUtils.hasText(filterValue)){
if (StringUtils.hasText(filterValue)) {
sourceBuilder.addPropertyReference("filter", filterValue);
}
}

View File

@@ -47,7 +47,7 @@ public class TransactionSynchronizationFactoryParser extends
Element afterCommitElement = DomUtils.getChildElementByTagName(element, "after-commit");
Element afterRollbackElement = DomUtils.getChildElementByTagName(element, "after-rollback");
if (this.elementsNotDefined(beforeCommitElement, afterCommitElement, afterRollbackElement)){
if (this.elementsNotDefined(beforeCommitElement, afterCommitElement, afterRollbackElement)) {
parserContext.getReaderContext().error("At least one sub-element " +
"('before-commit', 'after-commit' and/or 'after-rollback') must be defined", element);
}
@@ -63,21 +63,21 @@ public class TransactionSynchronizationFactoryParser extends
return syncFactoryBuilder.getBeanDefinition();
}
private void processSubElement(Element element, ParserContext parserContext, BeanDefinitionBuilder expressionProcessor, String elementPrefix){
if (element != null){
private void processSubElement(Element element, ParserContext parserContext, BeanDefinitionBuilder expressionProcessor, String elementPrefix) {
if (element != null) {
String expression = element.getAttribute("expression");
String channel = element.getAttribute("channel");
if (this.attributesNotDefined(expression, channel)){
if (this.attributesNotDefined(expression, channel)) {
parserContext.getReaderContext().error("At least one attribute " +
"('expression' and/or 'channel') must be defined", element);
}
if (StringUtils.hasText(expression)){
if (StringUtils.hasText(expression)) {
RootBeanDefinition expressionDef = new RootBeanDefinition(ExpressionFactoryBean.class);
expressionDef.getConstructorArgumentValues().addGenericArgumentValue(expression);
expressionProcessor.addPropertyValue(elementPrefix + "Expression", expressionDef);
}
if (StringUtils.hasText(channel)){
if (StringUtils.hasText(channel)) {
expressionProcessor.addPropertyReference(elementPrefix + "Channel", channel);
}
else {
@@ -86,17 +86,17 @@ public class TransactionSynchronizationFactoryParser extends
}
}
private boolean elementsNotDefined(Element... elements){
private boolean elementsNotDefined(Element... elements) {
for (Object element : elements) {
if (element != null){
if (element != null) {
return false;
}
}
return true;
}
private boolean attributesNotDefined(String... attributes){
private boolean attributesNotDefined(String... attributes) {
for (String attribute : attributes) {
if (StringUtils.hasText(attribute)){
if (StringUtils.hasText(attribute)) {
return false;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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,7 +61,7 @@ public class MessagingTemplate extends GenericMessagingTemplate {
*/
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
this.beanFactory = beanFactory;//NOSONAR - non-sync is ok here
this.beanFactory = beanFactory; //NOSONAR - non-sync is ok here
super.setDestinationResolver(new BeanFactoryChannelResolver(beanFactory));
}

View File

@@ -85,11 +85,11 @@ class OrderedAwareCopyOnWriteArraySet<E> implements Set<E> {
*/
@Override
public boolean add(E o) {
Assert.notNull(o,"Can not add NULL object");
Assert.notNull(o, "Can not add NULL object");
this.writeLock.lock();
try {
boolean present = false;
if (o instanceof Ordered){
if (o instanceof Ordered) {
present = this.addOrderedElement((Ordered) o);
}
else {
@@ -107,7 +107,7 @@ class OrderedAwareCopyOnWriteArraySet<E> implements Set<E> {
*/
@Override
public boolean addAll(Collection<? extends E> c) {
Assert.notNull(c,"Can not merge with NULL set");
Assert.notNull(c, "Can not merge with NULL set");
this.writeLock.lock();
try {
for (E object : c) {
@@ -140,8 +140,8 @@ class OrderedAwareCopyOnWriteArraySet<E> implements Set<E> {
* {@inheritDoc}
*/
@Override
public boolean removeAll(Collection<?> c){
if (CollectionUtils.isEmpty(c)){
public boolean removeAll(Collection<?> c) {
if (CollectionUtils.isEmpty(c)) {
return false;
}
this.writeLock.lock();
@@ -219,7 +219,7 @@ class OrderedAwareCopyOnWriteArraySet<E> implements Set<E> {
}
@Override
public int size(){
public int size() {
return this.elements.size();
}

View File

@@ -53,14 +53,14 @@ public class RoundRobinLoadBalancingStrategy implements LoadBalancingStrategy {
return this.buildHandlerIterator(size, handlers.toArray(new MessageHandler[size]));
}
private Iterator<MessageHandler> buildHandlerIterator(int size, final MessageHandler[] handlers){
private Iterator<MessageHandler> buildHandlerIterator(int size, final MessageHandler[] handlers) {
int nextHandlerStartIndex = getNextHandlerStartIndex(size);
final MessageHandler[] reorderedHandlers = new MessageHandler[size];
System.arraycopy(handlers, nextHandlerStartIndex, reorderedHandlers, 0, size-nextHandlerStartIndex);
System.arraycopy(handlers, 0, reorderedHandlers, size-nextHandlerStartIndex, 0+nextHandlerStartIndex);
System.arraycopy(handlers, nextHandlerStartIndex, reorderedHandlers, 0, size - nextHandlerStartIndex);
System.arraycopy(handlers, 0, reorderedHandlers, size - nextHandlerStartIndex, 0 + nextHandlerStartIndex);
return new Iterator<MessageHandler>() {
int currentIndex = 0;
@@ -85,7 +85,7 @@ public class RoundRobinLoadBalancingStrategy implements LoadBalancingStrategy {
* <code>size</code>.
*/
private int getNextHandlerStartIndex(int size) {
if (size > 0){
if (size > 0) {
int indexTail = this.currentHandlerIndex.getAndIncrement() % size;
return indexTail < 0 ? indexTail + size : indexTail;
}

View File

@@ -194,7 +194,7 @@ public class UnicastingDispatcher extends AbstractDispatcher {
if (allExceptions != null && allExceptions.size() == 1) {
throw allExceptions.get(0);
}
throw new AggregateMessageDeliveryException(message,//NOSONAR - false positive
throw new AggregateMessageDeliveryException(message, //NOSONAR - false positive
"All attempts to deliver Message to MessageHandlers failed.", allExceptions);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 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.
@@ -65,16 +65,16 @@ public class EventDrivenConsumer extends AbstractEndpoint {
}
}
private void logComponentSubscriptionEvent(boolean add){
if (this.handler instanceof NamedComponent && this.inputChannel instanceof NamedComponent){
String channelName = ((NamedComponent)this.inputChannel).getComponentName();
String componentType = ((NamedComponent)this.handler).getComponentType();
private void logComponentSubscriptionEvent(boolean add) {
if (this.handler instanceof NamedComponent && this.inputChannel instanceof NamedComponent) {
String channelName = ((NamedComponent) this.inputChannel).getComponentName();
String componentType = ((NamedComponent) this.handler).getComponentType();
componentType = StringUtils.hasText(componentType) ? componentType : "";
String componentName = ((IntegrationObjectSupport)this).getComponentName();
String componentName = ((IntegrationObjectSupport) this).getComponentName();
componentName = (StringUtils.hasText(componentName) && componentName.contains("#")) ? "" : ":" + componentName;
StringBuffer buffer = new StringBuffer();
buffer.append("{" + componentType + componentName + "} as a subscriber to the '" + channelName + "' channel");
if (add){
if (add) {
buffer.insert(0, "Adding ");
}
else {

View File

@@ -75,7 +75,7 @@ public abstract class ExpressionMessageProducerSupport extends MessageProducerSu
}
}
protected Object evaluatePayloadExpression(Object payload){
protected Object evaluatePayloadExpression(Object payload) {
Object evaluationResult = payload;
if (this.payloadExpression != null) {
evaluationResult = this.payloadExpression.getValue(this.evaluationContext, payload);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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,7 +82,7 @@ public class MethodInvokingMessageSource extends AbstractMessageSource<Object>
+ "' is available on " + this.object.getClass());
}
Assert.isTrue(!void.class.equals(this.method.getReturnType()),
"invalid MessageSource method '"+ this.method.getName() + "', a non-void return is required");
"invalid MessageSource method '" + this.method.getName() + "', a non-void return is required");
this.method.setAccessible(true);
this.initialized = true;
}

View File

@@ -115,7 +115,7 @@ public class PollingConsumer extends AbstractPollingEndpoint {
String description = "Failed to handle " + theMessage + " to " + this + " in " + this.handler;
throw new MessageDeliveryException(theMessage, description, ex);
}
catch (Error ex) {//NOSONAR - ok, we re-throw below
catch (Error ex) { //NOSONAR - ok, we re-throw below
if (!CollectionUtils.isEmpty(interceptorStack)) {
String description = "Failed to handle " + theMessage + " to " + this + " in " + this.handler;
triggerAfterMessageHandled(theMessage,
@@ -154,7 +154,7 @@ public class PollingConsumer extends AbstractPollingEndpoint {
try {
interceptor.afterMessageHandled(message, this.inputChannel, this.handler, ex);
}
catch (Throwable ex2) {//NOSONAR
catch (Throwable ex2) { //NOSONAR
logger.error("Exception from afterMessageHandled in " + interceptor, ex2);
}
}

View File

@@ -78,10 +78,10 @@ public class GatewayCompletableFutureProxyFactoryBean extends GatewayProxyFactor
try {
return doInvoke(this.invocation, false);
}
catch (Error e) {//NOSONAR
catch (Error e) { //NOSONAR
throw e;
}
catch (Throwable t) {//NOSONAR
catch (Throwable t) { //NOSONAR
if (t instanceof RuntimeException) {
throw (RuntimeException) t;
}

View File

@@ -207,7 +207,7 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper<Object[]
for (Entry<?, ?> entry : argumentValue.entrySet()) {
Object key = entry.getKey();
if (!(key instanceof String)) {
if (this.logger.isWarnEnabled()){
if (this.logger.isWarnEnabled()) {
this.logger.warn("Invalid header name [" + key +
"], name type must be String. Skipping mapping of this header to MessageHeaders.");
}
@@ -325,7 +325,7 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper<Object[]
}
else if (Map.class.isAssignableFrom(methodParameter.getParameterType())) {
if (messageOrPayload instanceof Map && !foundPayloadAnnotation) {
if (GatewayMethodInboundMessageMapper.this.payloadExpression == null){
if (GatewayMethodInboundMessageMapper.this.payloadExpression == null) {
throw new MessagingException("Ambiguous method parameters; found more than one " +
"Map-typed parameter and neither one contains a @Payload annotation");
}

View File

@@ -375,7 +375,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
try {
return this.invokeGatewayMethod(invocation, runningOnCallerThread);
}
catch (Throwable e) {//NOSONAR - ok to catch, rethrown below
catch (Throwable e) { //NOSONAR - ok to catch, rethrown below
this.rethrowExceptionCauseIfPossible(e, invocation.getMethod());
return null; // preceding call should always throw something
}
@@ -504,11 +504,11 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
requestChannelName = methodMetadata.getRequestChannelName();
replyChannelName = methodMetadata.getReplyChannelName();
String reqTimeout = methodMetadata.getRequestTimeout();
if (StringUtils.hasText(reqTimeout)){
if (StringUtils.hasText(reqTimeout)) {
requestTimeout = this.convert(reqTimeout, Long.class);
}
String repTimeout = methodMetadata.getReplyTimeout();
if (StringUtils.hasText(repTimeout)){
if (StringUtils.hasText(repTimeout)) {
replyTimeout = this.convert(repTimeout, Long.class);
}
}
@@ -635,10 +635,10 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
try {
return doInvoke(this.invocation, false);
}
catch (Error e) {//NOSONAR
catch (Error e) { //NOSONAR
throw e;
}
catch (Throwable t) {//NOSONAR
catch (Throwable t) { //NOSONAR
if (t instanceof RuntimeException) {
throw (RuntimeException) t;
}

View File

@@ -35,9 +35,9 @@ public final class MethodArgsHolder {
private final Object[] args;
public MethodArgsHolder(Method method, Object[] args) {//NOSONAR - direct storage
public MethodArgsHolder(Method method, Object[] args) { //NOSONAR - direct storage
this.method = method;
this.args = args;//NOSONAR - direct storage
this.args = args; //NOSONAR - direct storage
}
public Method getMethod() {
@@ -45,7 +45,7 @@ public final class MethodArgsHolder {
}
public Object[] getArgs() {
return this.args;//NOSONAR - direct access
return this.args; //NOSONAR - direct access
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@@ -110,7 +110,7 @@ public abstract class AbstractMessageHandler extends IntegrationObjectSupport im
@Override
public final void handleMessage(Message<?> message) {
Assert.notNull(message, "Message must not be null");
Assert.notNull(message.getPayload(), "Message payload must not be null");//NOSONAR - false positive
Assert.notNull(message.getPayload(), "Message payload must not be null"); //NOSONAR - false positive
if (this.loggingEnabled && this.logger.isDebugEnabled()) {
this.logger.debug(this + " received message: " + message);
}

View File

@@ -72,7 +72,7 @@ public abstract class AbstractMessageProducingHandler extends AbstractMessageHan
public void setOutputChannelName(String outputChannelName) {
Assert.hasText(outputChannelName, "'outputChannelName' must not be empty");
this.outputChannelName = outputChannelName;//NOSONAR (inconsistent sync)
this.outputChannelName = outputChannelName; //NOSONAR (inconsistent sync)
}
/**
@@ -98,7 +98,7 @@ public abstract class AbstractMessageProducingHandler extends AbstractMessageHan
@Override
protected void onInit() throws Exception {
super.onInit();
Assert.state(!(this.outputChannelName != null && this.outputChannel != null),//NOSONAR (inconsistent sync)
Assert.state(!(this.outputChannelName != null && this.outputChannel != null), //NOSONAR (inconsistent sync)
"'outputChannelName' and 'outputChannel' are mutually exclusive.");
if (getBeanFactory() != null) {
this.messagingTemplate.setBeanFactory(getBeanFactory());

View File

@@ -220,7 +220,7 @@ public class LoggingHandler extends AbstractMessageHandler {
StringWriter stringWriter = new StringWriter();
if (logMessage instanceof AggregateMessageDeliveryException) {
stringWriter.append(((Throwable) logMessage).getMessage());
for (Exception exception : ((AggregateMessageDeliveryException)logMessage).getAggregatedExceptions()) {
for (Exception exception : ((AggregateMessageDeliveryException) logMessage).getAggregatedExceptions()) {
exception.printStackTrace(new PrintWriter(stringWriter, true));
}
}

View File

@@ -74,10 +74,10 @@ public abstract class AbstractRequestHandlerAdvice extends IntegrationObjectSupp
try {
return invocation.proceed();
}
catch (Exception e) {//NOSONAR - catch necessary so we can wrap Errors
catch (Exception e) { //NOSONAR - catch necessary so we can wrap Errors
throw e;
}
catch (Throwable e) {//NOSONAR - ok to catch; unwrapped and rethrown below
catch (Throwable e) { //NOSONAR - ok to catch; unwrapped and rethrown below
throw new ThrowableHolderException(e);
}
}
@@ -98,10 +98,10 @@ public abstract class AbstractRequestHandlerAdvice extends IntegrationObjectSupp
" so please raise an issue if you see this exception");
}
}
catch (Exception e) {//NOSONAR - catch necessary so we can wrap Errors
catch (Exception e) { //NOSONAR - catch necessary so we can wrap Errors
throw e;
}
catch (Throwable e) {//NOSONAR - ok to catch; unwrapped and rethrown below
catch (Throwable e) { //NOSONAR - ok to catch; unwrapped and rethrown below
throw new ThrowableHolderException(e);
}
}

View File

@@ -83,12 +83,12 @@ public class ExpressionEvaluatingRequestHandlerAdvice extends AbstractRequestHan
}
public void setSuccessChannel(MessageChannel successChannel) {
Assert.notNull(successChannel,"'successChannel' must not be null");
Assert.notNull(successChannel, "'successChannel' must not be null");
this.successChannel = successChannel;
}
public void setFailureChannel(MessageChannel failureChannel) {
Assert.notNull(failureChannel,"'failureChannel' must not be null");
Assert.notNull(failureChannel, "'failureChannel' must not be null");
this.failureChannel = failureChannel;
}
@@ -190,7 +190,7 @@ public class ExpressionEvaluatingRequestHandlerAdvice extends AbstractRequestHan
return evalResult;
}
protected StandardEvaluationContext createEvaluationContext(){
protected StandardEvaluationContext createEvaluationContext() {
return ExpressionUtils.createStandardEvaluationContext(this.getBeanFactory());
}

View File

@@ -97,7 +97,7 @@ public class MessageHistoryConfigurer implements SmartLifecycle, BeanFactoryAwar
* components). Cannot be changed if {@link #isRunning()}; invoke {@link #stop()} first.
* @param componentNamePatterns The patterns.
*/
@ManagedAttribute(description="comma-delimited list of patterns; must invoke stop() before changing.")
@ManagedAttribute(description = "comma-delimited list of patterns; must invoke stop() before changing.")
public void setComponentNamePatternsString(String componentNamePatterns) {
this.setComponentNamePatterns(StringUtils.delimitedListToStringArray(componentNamePatterns, ",", " "));
}

View File

@@ -547,7 +547,7 @@ public abstract class AbstractHeaderMapper<T> implements RequestReplyHeaderMappe
* {@link HeaderMatcher}s matches to the {@code headerName}.
* @since 4.1
*/
protected static class CompositeHeaderMatcher implements HeaderMatcher{
protected static class CompositeHeaderMatcher implements HeaderMatcher {
private static final Log logger = LogFactory.getLog(HeaderMatcher.class);

View File

@@ -51,7 +51,7 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS
@Override
public Message<?> getMessage(UUID id) {
Message<?> message = getRawMessage(id);
if (message != null){
if (message != null) {
return normalizeMessage(message);
}
return null;
@@ -73,7 +73,7 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS
if (message != null) {
Assert.isInstanceOf(Message.class, message);
}
if (message != null){
if (message != null) {
return normalizeMessage((Message<?>) message);
}
return null;
@@ -147,7 +147,7 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS
Message<?> actualMessageToRemove = null;
for (Message<?> message : rawGroup.getMessages()) {
if (message.getHeaders().getId().equals(messageToRemove.getHeaders().getId())){
if (message.getHeaders().getId().equals(messageToRemove.getHeaders().getId())) {
actualMessageToRemove = message;
break;
}
@@ -206,7 +206,7 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS
MessageGroupMetadata messageGroupMetadata = (MessageGroupMetadata) mgm;
Iterator<UUID> messageIds = messageGroupMetadata.messageIdIterator();
while (messageIds.hasNext()){
while (messageIds.hasNext()) {
removeMessage(messageIds.next());
}
}
@@ -230,7 +230,7 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS
MessageGroupMetadata messageGroupMetadata = (MessageGroupMetadata) mgm;
UUID firstId = messageGroupMetadata.firstId();
if (firstId != null){
if (firstId != null) {
messageGroupMetadata.remove(firstId);
messageGroupMetadata.setLastModified(System.currentTimeMillis());
doStore(MESSAGE_GROUP_KEY_PREFIX + groupId, messageGroupMetadata);
@@ -249,14 +249,14 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS
return new MessageGroupIterator(idIterator);
}
private Collection<String> normalizeKeys(Collection<String> keys){
private Collection<String> normalizeKeys(Collection<String> keys) {
Set<String> normalizedKeys = new HashSet<String>();
for (Object key : keys) {
String strKey = (String) key;
if (strKey.startsWith(MESSAGE_GROUP_KEY_PREFIX)){
if (strKey.startsWith(MESSAGE_GROUP_KEY_PREFIX)) {
strKey = strKey.replace(MESSAGE_GROUP_KEY_PREFIX, "");
}
else if (strKey.startsWith(MESSAGE_KEY_PREFIX)){
else if (strKey.startsWith(MESSAGE_KEY_PREFIX)) {
strKey = strKey.replace(MESSAGE_KEY_PREFIX, "");
}
normalizedKeys.add(strKey);
@@ -284,7 +284,7 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS
protected abstract Collection<?> doListKeys(String keyPattern);
@SuppressWarnings({ "rawtypes", "unchecked" })
private Message<?> normalizeMessage(Message<?> message){
private Message<?> normalizeMessage(Message<?> message) {
Message<?> normalizedMessage = getMessageBuilderFactory().fromMessage(message)
.removeHeader("CREATED_DATE")
.build();
@@ -298,7 +298,7 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS
* Will enrich Message with additional meta headers
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
private Message<?> enrichMessage(Message<?> message){
private Message<?> enrichMessage(Message<?> message) {
Message<?> enrichedMessage = getMessageBuilderFactory().fromMessage(message)
.setHeader(CREATED_DATE, System.currentTimeMillis())
.build();
@@ -308,7 +308,7 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS
return enrichedMessage;
}
private MessageGroup buildMessageGroup(Object groupId, boolean raw){
private MessageGroup buildMessageGroup(Object groupId, boolean raw) {
Assert.notNull(groupId, "'groupId' must not be null");
Object mgm = doRetrieve(MESSAGE_GROUP_KEY_PREFIX + groupId);
if (mgm != null) {
@@ -317,10 +317,10 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS
ArrayList<Message<?>> messages = new ArrayList<Message<?>>();
Iterator<UUID> messageIds = messageGroupMetadata.messageIdIterator();
while (messageIds.hasNext()){
while (messageIds.hasNext()) {
UUID next = messageIds.next();
if (next != null) {
if (raw){
if (raw) {
messages.add(getRawMessage(next));
}
else {
@@ -341,7 +341,7 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS
}
}
private MessageGroup normalizeSimpleMessageGroup(MessageGroup messageGroup){
private MessageGroup normalizeSimpleMessageGroup(MessageGroup messageGroup) {
MessageGroup normalizedGroup = getMessageGroupFactory().create(messageGroup.getGroupId());
for (Message<?> message : messageGroup.getMessages()) {
Message<?> normalizedMessage = normalizeMessage(message);

View File

@@ -73,7 +73,7 @@ public class MessageGroupMetadata implements Serializable {
this.first = first;
}
public void remove(UUID messageId){
public void remove(UUID messageId) {
if (!this.hasMessages) {
throw new IllegalStateException("Messages are not available, fetch the entire group");
}
@@ -88,25 +88,25 @@ public class MessageGroupMetadata implements Serializable {
return this.groupId;
}
public Iterator<UUID> messageIdIterator(){
public Iterator<UUID> messageIdIterator() {
if (!this.hasMessages) {
throw new IllegalStateException("Messages are not available, fetch the entire group");
}
return this.messageIds.iterator();
}
public int size(){
public int size() {
return this.messageIds.size();
}
public UUID firstId(){
public UUID firstId() {
if (this.first != null) {
return this.first;
}
if (!this.hasMessages) {
throw new IllegalStateException("Messages are not available, fetch the entire group");
}
if (this.messageIds.size() > 0){
if (this.messageIds.size() > 0) {
return this.messageIds.iterator().next();
}
return null;

View File

@@ -156,7 +156,7 @@ public class MessageGroupQueue extends AbstractQueue<Message<?>> implements Bloc
storeLock.lockInterruptibly();
try {
while (this.size() == 0 && timeoutInNanos > 0){
while (this.size() == 0 && timeoutInNanos > 0) {
timeoutInNanos = this.messageStoreNotEmpty.awaitNanos(timeoutInNanos);
}
message = this.doPoll();
@@ -248,11 +248,11 @@ public class MessageGroupQueue extends AbstractQueue<Message<?>> implements Bloc
storeLock.lockInterruptibly();
try {
if (this.capacity != Integer.MAX_VALUE) {
while (this.size() == this.capacity && timeoutInNanos > 0){
while (this.size() == this.capacity && timeoutInNanos > 0) {
timeoutInNanos = this.messageStoreNotFull.awaitNanos(timeoutInNanos);
}
}
if (timeoutInNanos > 0){
if (timeoutInNanos > 0) {
offered = this.doOffer(message);
}
}
@@ -268,7 +268,7 @@ public class MessageGroupQueue extends AbstractQueue<Message<?>> implements Bloc
storeLock.lockInterruptibly();
try {
if (this.capacity != Integer.MAX_VALUE) {
while (this.size() == this.capacity){
while (this.size() == this.capacity) {
this.messageStoreNotFull.await();
}
}
@@ -294,7 +294,7 @@ public class MessageGroupQueue extends AbstractQueue<Message<?>> implements Bloc
storeLock.lockInterruptibly();
try {
while (this.size() == 0){
while (this.size() == 0) {
this.messageStoreNotEmpty.await();
}
message = this.doPoll();
@@ -306,7 +306,7 @@ public class MessageGroupQueue extends AbstractQueue<Message<?>> implements Bloc
return message;
}
private Collection<Message<?>> getMessages(){
private Collection<Message<?>> getMessages() {
return this.messageGroupStore.getMessageGroup(this.groupId).getMessages();
}
@@ -324,9 +324,9 @@ public class MessageGroupQueue extends AbstractQueue<Message<?>> implements Bloc
* It is assumed that the 'storeLock' is being held by the caller, otherwise
* IllegalMonitorStateException may be thrown
*/
private boolean doOffer(Message<?> message){
private boolean doOffer(Message<?> message) {
boolean offered = false;
if (this.capacity == Integer.MAX_VALUE || this.size() < this.capacity){
if (this.capacity == Integer.MAX_VALUE || this.size() < this.capacity) {
this.messageGroupStore.addMessageToGroup(this.groupId, message);
offered = true;
this.messageStoreNotEmpty.signal();

View File

@@ -79,7 +79,7 @@ public class SimpleMessageGroup implements MessageGroup {
this.timestamp = timestamp;
this.complete = complete;
for (Message<?> message : messages) {
if (message != null){ //see INT-2666
if (message != null) { //see INT-2666
addMessage(message);
}
}
@@ -90,7 +90,7 @@ public class SimpleMessageGroup implements MessageGroup {
return this.timestamp;
}
public void setLastModified(long lastModified){
public void setLastModified(long lastModified) {
this.lastModified = lastModified;
}
@@ -126,7 +126,7 @@ public class SimpleMessageGroup implements MessageGroup {
return Collections.unmodifiableCollection(this.messages);
}
public void setLastReleasedMessageSequenceNumber(int sequenceNumber){
public void setLastReleasedMessageSequenceNumber(int sequenceNumber) {
this.lastReleasedMessageSequence = sequenceNumber;
}
@@ -166,7 +166,7 @@ public class SimpleMessageGroup implements MessageGroup {
}
}
public void clear(){
public void clear() {
this.messages.clear();
}

View File

@@ -111,7 +111,7 @@ public class MapMessageConverter implements MessageConverter, BeanFactoryAware {
@Override
public Object fromMessage(Message<?> message, Class<?> clazz) {
Map<String,Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<String, Object>();
map.put("payload", message.getPayload());
Map<String, Object> headers = new HashMap<String, Object>();
for (String headerName : this.headerNames) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2014 the original author or authors.
* Copyright 2013-2016 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.
@@ -74,7 +74,7 @@ public class Jackson2JsonObjectMapper extends AbstractJacksonJsonObjectMapper<Js
if (json instanceof String) {
return this.objectMapper.readValue((String) json, type);
}
else if(json instanceof byte[]) {
else if (json instanceof byte[]) {
return this.objectMapper.readValue((byte[]) json, type);
}
else if (json instanceof File) {

View File

@@ -43,7 +43,7 @@ public final class DefaultLockRegistry implements LockRegistry {
* Constructs a DefaultLockRegistry with the default
* mask 0xFF with 256 locks.
*/
public DefaultLockRegistry(){
public DefaultLockRegistry() {
this(0xFF);
}
@@ -58,11 +58,11 @@ public final class DefaultLockRegistry implements LockRegistry {
* </ul>
* @param mask The bit mask.
*/
public DefaultLockRegistry(int mask){
public DefaultLockRegistry(int mask) {
String bits = Integer.toBinaryString(mask);
Assert.isTrue(bits.length() < 32 && (mask == 0 || bits.lastIndexOf('0') < bits.indexOf('1') ), "Mask must be a power of 2 - 1");
this.mask = mask;
int arraySize = this.mask+1;
int arraySize = this.mask + 1;
this.lockTable = new ReentrantLock[arraySize];
for (int i = 0; i < arraySize; i++) {
this.lockTable[i] = new ReentrantLock();

View File

@@ -73,7 +73,7 @@ public class ExponentialMovingAverage {
*/
public ExponentialMovingAverage(int window, double factor) {
this.window = window;
this.retention = window * 5;// last retained value contributes just 0.5% to the sum
this.retention = window * 5; // last retained value contributes just 0.5% to the sum
this.factor = factor;
}
@@ -93,7 +93,7 @@ public class ExponentialMovingAverage {
this.samples.poll();
}
this.samples.add(value);
this.count++;//NOSONAR - false positive, we're synchronized
this.count++; //NOSONAR - false positive, we're synchronized
}
private Statistics calc() {
@@ -132,7 +132,7 @@ public class ExponentialMovingAverage {
double mean = weight > 0 ? sum / weight : 0.;
double var = weight > 0 ? sumSquares / weight - mean * mean : 0.;
double standardDeviation = var > 0 ? Math.sqrt(var) : 0;
return new Statistics(count, min == Double.MAX_VALUE ? 0 : min, max, mean, standardDeviation);//NOSONAR
return new Statistics(count, min == Double.MAX_VALUE ? 0 : min, max, mean, standardDeviation); //NOSONAR
}
/**

View File

@@ -117,7 +117,7 @@ public class ExponentialMovingAverageRate {
this.times.poll();
}
this.times.add(t);
this.count++;//NOSONAR - false positive, we're synchronized
this.count++; //NOSONAR - false positive, we're synchronized
}
private Statistics calc() {

View File

@@ -134,7 +134,7 @@ public class ExponentialMovingAverageRatio {
}
this.times.add(t);
this.values.add(value);
this.count++;//NOSONAR - false positive, we're synchronized
this.count++; //NOSONAR - false positive, we're synchronized
}
private Statistics calc() {

View File

@@ -291,7 +291,7 @@ public class IntegrationManagementConfigurer implements SmartInitializingSinglet
}
}
}
return null;//NOSONAR - intentional null return
return null; //NOSONAR - intentional null return
}
public MessageChannelMetrics getChannelMetrics(String name) {

View File

@@ -38,7 +38,7 @@ public class DefaultTransactionSynchronizationFactory implements TransactionSync
private final TransactionSynchronizationProcessor processor;
public DefaultTransactionSynchronizationFactory(TransactionSynchronizationProcessor processor){
public DefaultTransactionSynchronizationFactory(TransactionSynchronizationProcessor processor) {
Assert.notNull(processor, "'processor' must not be null");
this.processor = processor;
}

View File

@@ -56,7 +56,7 @@ public class IntegrationResourceHolder implements ResourceHolder {
* @param key The key.
* @param value The value.
*/
public void addAttribute(String key, Object value){
public void addAttribute(String key, Object value) {
this.attributes.put(key, value);
}

View File

@@ -53,7 +53,7 @@ public class HeaderFilter extends IntegrationObjectSupport implements Transforme
@Override
public Message<?> transform(Message<?> message) {
AbstractIntegrationMessageBuilder<?> builder = this.getMessageBuilderFactory().fromMessage(message);
if (this.patternMatch){
if (this.patternMatch) {
builder.removeHeaders(this.headersToRemove);
}
else {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,7 +54,7 @@ import org.springframework.util.StringUtils;
* @author Gary Russell
* @since 2.0
*/
public class ObjectToMapTransformer extends AbstractPayloadTransformer<Object, Map<?,?>> {
public class ObjectToMapTransformer extends AbstractPayloadTransformer<Object, Map<?, ?>> {
private final JsonObjectMapper<?, ?> jsonObjectMapper = JsonObjectMapperProvider.newInstance();
@@ -67,7 +67,7 @@ public class ObjectToMapTransformer extends AbstractPayloadTransformer<Object, M
@Override
@SuppressWarnings("unchecked")
protected Map<String, Object> transformPayload(Object payload) throws Exception {
Map<String,Object> result = this.jsonObjectMapper.fromJson(this.jsonObjectMapper.toJson(payload), Map.class);
Map<String, Object> result = this.jsonObjectMapper.fromJson(this.jsonObjectMapper.toJson(payload), Map.class);
if (this.shouldFlattenKeys) {
result = this.flattenMap(result);
}
@@ -96,13 +96,13 @@ public class ObjectToMapTransformer extends AbstractPayloadTransformer<Object, M
}
}
private Map<String, Object> flattenMap(Map<String,Object> result){
Map<String,Object> resultMap = new HashMap<String, Object>();
private Map<String, Object> flattenMap(Map<String, Object> result) {
Map<String, Object> resultMap = new HashMap<String, Object>();
this.doFlatten("", result, resultMap);
return resultMap;
}
private void doFlatten(String propertyPrefix, Map<String,Object> inputMap, Map<String,Object> resultMap){
private void doFlatten(String propertyPrefix, Map<String, Object> inputMap, Map<String, Object> resultMap) {
if (StringUtils.hasText(propertyPrefix)) {
propertyPrefix = propertyPrefix + ".";
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2014-2016 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.
@@ -71,7 +71,7 @@ public class RoutingSlipHeaderValueMessageProcessor
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
Assert.notNull(beanFactory, "beanFactory must not be null");
this.beanFactory = beanFactory;//NOSONAR (inconsistent sync)
this.beanFactory = beanFactory; //NOSONAR (inconsistent sync)
}
@Override

View File

@@ -124,7 +124,7 @@ public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware
}
if (!String.class.isAssignableFrom(sourceType.getType())) {
PropertyEditor editor = this.delegate.findCustomEditor(sourceType.getType(), null);
if (editor==null) {
if (editor == null) {
editor = this.getDefaultEditor(sourceType.getType());
}
if (editor != null) { // INT-1441
@@ -147,12 +147,12 @@ public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware
private PropertyEditor getDefaultEditor(Class<?> sourceType) {
PropertyEditor defaultEditor;
if (this.haveCalledDelegateGetDefaultEditor) {
defaultEditor= this.delegate.getDefaultEditor(sourceType);
defaultEditor = this.delegate.getDefaultEditor(sourceType);
}
else {
synchronized(this) {
synchronized (this) {
// not thread-safe - it builds the defaultEditors field in-place (SPR-10191)
defaultEditor= this.delegate.getDefaultEditor(sourceType);
defaultEditor = this.delegate.getDefaultEditor(sourceType);
}
this.haveCalledDelegateGetDefaultEditor = true;
}

View File

@@ -54,7 +54,7 @@ public class ErrorHandlingTaskExecutor implements TaskExecutor {
try {
task.run();
}
catch (Throwable t) {//NOSONAR
catch (Throwable t) { //NOSONAR
ErrorHandlingTaskExecutor.this.errorHandler.handleError(t);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2014-2016 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.
@@ -145,6 +145,6 @@ public final class MessagingAnnotationUtils {
return targetClass;
}
private MessagingAnnotationUtils() {}
private MessagingAnnotationUtils() { }
}

View File

@@ -770,13 +770,13 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
if (this.canProcessMessageList) {
Type type = method.getGenericParameterTypes()[i];
Type parameterizedType = null;
if (type instanceof ParameterizedType){
parameterizedType = ((ParameterizedType)type).getActualTypeArguments()[0];
if (parameterizedType instanceof ParameterizedType){
if (type instanceof ParameterizedType) {
parameterizedType = ((ParameterizedType) type).getActualTypeArguments()[0];
if (parameterizedType instanceof ParameterizedType) {
parameterizedType = ((ParameterizedType) parameterizedType).getRawType();
}
}
if (parameterizedType != null && Message.class.isAssignableFrom((Class<?>) parameterizedType)){
if (parameterizedType != null && Message.class.isAssignableFrom((Class<?>) parameterizedType)) {
sb.append("messages.iterator()");
}
else {

View File

@@ -217,7 +217,7 @@ public class SimplePool<T> implements Pool<T> {
}
}
else {
if (this.logger.isDebugEnabled()){
if (this.logger.isDebugEnabled()) {
this.logger.debug("Releasing " + item + " back to the pool");
}
if (item != null) {
@@ -228,7 +228,7 @@ public class SimplePool<T> implements Pool<T> {
}
}
else {
if (this.logger.isDebugEnabled()){
if (this.logger.isDebugEnabled()) {
this.logger.debug("Ignoring release of " + item + " back to the pool - not in use");
}
}
@@ -242,7 +242,7 @@ public class SimplePool<T> implements Pool<T> {
}
private void doRemoveItem(T item) {
if (this.logger.isDebugEnabled()){
if (this.logger.isDebugEnabled()) {
this.logger.debug("Removing " + item + " from the pool");
}
this.allocated.remove(item);

View File

@@ -25,7 +25,7 @@ package org.springframework.integration.util;
*/
public final class StackTraceUtils {
private StackTraceUtils() {}
private StackTraceUtils() { }
/**
* Traverses the stack trace element array looking for instances that contain the first or second

View File

@@ -44,8 +44,8 @@ public final class UpperBound {
this.semaphore = (capacity > 0) ? new Semaphore(capacity, true) : null;
}
public int availablePermits(){
if (this.semaphore == null){
public int availablePermits() {
if (this.semaphore == null) {
return Integer.MAX_VALUE;
}
return this.semaphore.availablePermits();

View File

@@ -37,11 +37,11 @@ public abstract class WhileLockedProcessor {
private final Object key;
private final LockRegistry lockRegistry;
public WhileLockedProcessor(LockRegistry lockRegistry, Object key){
public WhileLockedProcessor(LockRegistry lockRegistry, Object key) {
this.key = key;
this.lockRegistry = lockRegistry;
}
public final void doWhileLocked() throws IOException{
public final void doWhileLocked() throws IOException {
Lock lock = this.lockRegistry.obtain(this.key);
try {
lock.lockInterruptibly();

View File

@@ -117,7 +117,7 @@ public class AggregatorTests {
Message<?> message = new GenericMessage<String>("foo");
StopWatch stopwatch = new StopWatch();
stopwatch.start();
for (int i=0; i < 120000; i++) {
for (int i = 0; i < 120000; i++) {
if (i % 10000 == 0) {
stopwatch.stop();
logger.warn("Sent " + i + " in " + stopwatch.getTotalTimeSeconds() +
@@ -183,7 +183,7 @@ public class AggregatorTests {
Message<?> message = new GenericMessage<String>("foo");
StopWatch stopwatch = new StopWatch();
stopwatch.start();
for (int i=0; i < 120000; i++) {
for (int i = 0; i < 120000; i++) {
if (i % 10000 == 0) {
stopwatch.stop();
logger.warn("Sent " + i + " in " + stopwatch.getTotalTimeSeconds() +

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2016 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.
@@ -277,7 +277,7 @@ public class BarrierMessageHandlerTests {
return new QueueChannel();
}
@ServiceActivator(inputChannel="in")
@ServiceActivator(inputChannel = "in")
@Bean
public BarrierMessageHandler barrier() {
BarrierMessageHandler barrier = new BarrierMessageHandler(10000);
@@ -285,7 +285,7 @@ public class BarrierMessageHandlerTests {
return barrier;
}
@ServiceActivator (inputChannel="release", poller=@Poller(fixedDelay="0"))
@ServiceActivator (inputChannel = "release", poller = @Poller(fixedDelay = "0"))
@Bean
public MessageHandler releaser() {
return new MessageHandler() {

View File

@@ -126,7 +126,7 @@ public class CorrelatingMessageBarrierTests {
}
private Message<Object> testMessage() {
return MessageBuilder.withPayload((Object)"payload").build();
return MessageBuilder.withPayload((Object) "payload").build();
}

View File

@@ -82,7 +82,7 @@ public class ExpressionEvaluatingCorrelationStrategyTests {
}
public static class CustomCorrelator {
public Object correlate(Object o){
public Object correlate(Object o) {
return o;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -331,7 +331,7 @@ public class MethodInvokingMessageGroupProcessorTests {
MessageGroupProcessor processor = new MethodInvokingMessageGroupProcessor(new UnannotatedAggregator());
when(messageGroupMock.getMessages()).thenReturn(messagesUpForProcessing);
Object result = processor.processMessageGroup(messageGroupMock);
assertTrue(((Message<?>)result).getPayload() instanceof Iterator<?>);
assertTrue(((Message<?>) result).getPayload() instanceof Iterator<?>);
}
@Test

View File

@@ -41,14 +41,14 @@ public class ResequencingMessageGroupProcessorTests {
@Test
public void shouldProcessSequence() {
Message prototypeMessage = MessageBuilder.withPayload("foo").setCorrelationId("x").setSequenceNumber(1).setSequenceSize(3).build();
List<Message<?>> messages= new ArrayList<Message<?>>();
List<Message<?>> messages = new ArrayList<Message<?>>();
Message message1 = MessageBuilder.fromMessage(prototypeMessage).setSequenceNumber(1).build();
Message message2 = MessageBuilder.fromMessage(prototypeMessage).setSequenceNumber(2).build();
Message message3 = MessageBuilder.fromMessage(prototypeMessage).setSequenceNumber(3).build();
messages.add(message1);
messages.add(message2);
messages.add(message3);
SimpleMessageGroup group = new SimpleMessageGroup(messages,"x");
SimpleMessageGroup group = new SimpleMessageGroup(messages, "x");
List<Message> processedMessages = (List<Message>) processor.processMessageGroup(group);
assertThat(processedMessages, hasItems(message1, message2, message3));
}
@@ -57,14 +57,14 @@ public class ResequencingMessageGroupProcessorTests {
@Test
public void shouldPartiallProcessIncompleteSequence() {
Message prototypeMessage = MessageBuilder.withPayload("foo").setCorrelationId("x").setSequenceNumber(1).setSequenceSize(4).build();
List<Message<?>> messages= new ArrayList<Message<?>>();
List<Message<?>> messages = new ArrayList<Message<?>>();
Message message2 = MessageBuilder.fromMessage(prototypeMessage).setSequenceNumber(4).build();
Message message1 = MessageBuilder.fromMessage(prototypeMessage).setSequenceNumber(1).build();
Message message3 = MessageBuilder.fromMessage(prototypeMessage).setSequenceNumber(3).build();
messages.add(message1);
messages.add(message2);
messages.add(message3);
SimpleMessageGroup group = new SimpleMessageGroup(messages,"x");
SimpleMessageGroup group = new SimpleMessageGroup(messages, "x");
List<Message> processedMessages = (List<Message>) processor.processMessageGroup(group);
assertThat(processedMessages, hasItems(message1));
assertThat(processedMessages.size(), is(1));

View File

@@ -46,7 +46,7 @@ public class AggregatorSupportedUseCasesTests {
private AggregatingMessageHandler defaultHandler = new AggregatingMessageHandler(processor, store);
@Test
public void waitForAllDefaultReleaseStrategyWithLateArrivals(){
public void waitForAllDefaultReleaseStrategyWithLateArrivals() {
QueueChannel outputChannel = new QueueChannel();
QueueChannel discardChannel = new QueueChannel();
defaultHandler.setOutputChannel(outputChannel);
@@ -55,7 +55,7 @@ public class AggregatorSupportedUseCasesTests {
for (int i = 0; i < 5; i++) {
defaultHandler.handleMessage(MessageBuilder.withPayload(i).setSequenceSize(5).setCorrelationId("A").setSequenceNumber(i).build());
}
assertEquals(5, ((List<?>)outputChannel.receive(0).getPayload()).size());
assertEquals(5, ((List<?>) outputChannel.receive(0).getPayload()).size());
assertNull(discardChannel.receive(0));
assertEquals(0, store.getMessageGroup("A").getMessages().size());
@@ -71,7 +71,7 @@ public class AggregatorSupportedUseCasesTests {
}
@Test
public void waitForAllCustomReleaseStrategyWithLateArrivals(){
public void waitForAllCustomReleaseStrategyWithLateArrivals() {
QueueChannel outputChannel = new QueueChannel();
QueueChannel discardChannel = new QueueChannel();
defaultHandler.setOutputChannel(outputChannel);
@@ -81,7 +81,7 @@ public class AggregatorSupportedUseCasesTests {
for (int i = 0; i < 5; i++) {
defaultHandler.handleMessage(MessageBuilder.withPayload(i).setCorrelationId("A").build());
}
assertEquals(5, ((List<?>)outputChannel.receive(0).getPayload()).size());
assertEquals(5, ((List<?>) outputChannel.receive(0).getPayload()).size());
assertNull(discardChannel.receive(0));
assertEquals(0, store.getMessageGroup("A").getMessages().size());
@@ -97,7 +97,7 @@ public class AggregatorSupportedUseCasesTests {
}
@Test
public void firstBest(){
public void firstBest() {
QueueChannel outputChannel = new QueueChannel();
QueueChannel discardChannel = new QueueChannel();
defaultHandler.setOutputChannel(outputChannel);
@@ -107,7 +107,7 @@ public class AggregatorSupportedUseCasesTests {
for (int i = 0; i < 5; i++) {
defaultHandler.handleMessage(MessageBuilder.withPayload(i).setCorrelationId("A").build());
}
assertEquals(1, ((List<?>)outputChannel.receive(0).getPayload()).size());
assertEquals(1, ((List<?>) outputChannel.receive(0).getPayload()).size());
assertNotNull(discardChannel.receive(0));
assertNotNull(discardChannel.receive(0));
assertNotNull(discardChannel.receive(0));
@@ -115,7 +115,7 @@ public class AggregatorSupportedUseCasesTests {
}
@Test
public void batchingWithoutLeftovers(){
public void batchingWithoutLeftovers() {
QueueChannel outputChannel = new QueueChannel();
QueueChannel discardChannel = new QueueChannel();
defaultHandler.setOutputChannel(outputChannel);
@@ -126,13 +126,13 @@ public class AggregatorSupportedUseCasesTests {
for (int i = 0; i < 10; i++) {
defaultHandler.handleMessage(MessageBuilder.withPayload(i).setCorrelationId("A").build());
}
assertEquals(5, ((List<?>)outputChannel.receive(0).getPayload()).size());
assertEquals(5, ((List<?>)outputChannel.receive(0).getPayload()).size());
assertEquals(5, ((List<?>) outputChannel.receive(0).getPayload()).size());
assertEquals(5, ((List<?>) outputChannel.receive(0).getPayload()).size());
assertNull(discardChannel.receive(0));
}
@Test
public void batchingWithLeftovers(){
public void batchingWithLeftovers() {
QueueChannel outputChannel = new QueueChannel();
QueueChannel discardChannel = new QueueChannel();
defaultHandler.setOutputChannel(outputChannel);
@@ -143,8 +143,8 @@ public class AggregatorSupportedUseCasesTests {
for (int i = 0; i < 12; i++) {
defaultHandler.handleMessage(MessageBuilder.withPayload(i).setCorrelationId("A").build());
}
assertEquals(5, ((List<?>)outputChannel.receive(0).getPayload()).size());
assertEquals(5, ((List<?>)outputChannel.receive(0).getPayload()).size());
assertEquals(5, ((List<?>) outputChannel.receive(0).getPayload()).size());
assertEquals(5, ((List<?>) outputChannel.receive(0).getPayload()).size());
assertNull(discardChannel.receive(0));
assertEquals(2, store.getMessageGroup("A").getMessages().size());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2016 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,8 +55,8 @@ public class AnnotationAggregatorTests {
@SuppressWarnings("unchecked")
Message<String> result = (Message<String>) output.receive();
String payload = result.getPayload();
assertTrue("Wrong payload: "+payload, payload.matches(".*payload.*?=a.*"));
assertTrue("Wrong payload: "+payload, payload.matches(".*payload.*?=b.*"));
assertTrue("Wrong payload: " + payload, payload.matches(".*payload.*?=a.*"));
assertTrue("Wrong payload: " + payload, payload.matches(".*payload.*?=b.*"));
}
@SuppressWarnings("unused")
@@ -69,7 +69,7 @@ public class AnnotationAggregatorTests {
@ReleaseStrategy
public boolean release(final List<Message<?>> messages) {
return messages.size()>1;
return messages.size() > 1;
}
@CorrelationStrategy

View File

@@ -54,7 +54,7 @@ public class AggregatorWithCustomReleaseStrategyTests {
private boolean shouldRun;
{
for(String value: new String[]{System.getenv(RUN_LONG_PROP), System.getProperty(RUN_LONG_PROP)}) {
for (String value: new String[]{System.getenv(RUN_LONG_PROP), System.getProperty(RUN_LONG_PROP)}) {
if ("true".equalsIgnoreCase(value)) {
this.shouldRun = true;
break;
@@ -88,7 +88,7 @@ public class AggregatorWithCustomReleaseStrategyTests {
}
@Test
public void testAggregatorsUnderStressWithConcurrency() throws Exception{
public void testAggregatorsUnderStressWithConcurrency() throws Exception {
// this is to be sure after INT-2502
for (int i = 0; i < 10; i++) {
this.validateSequenceSizeHasNoAffectCustomCorrelator();
@@ -98,7 +98,7 @@ public class AggregatorWithCustomReleaseStrategyTests {
}
}
public void validateSequenceSizeHasNoAffectCustomCorrelator() throws Exception{
public void validateSequenceSizeHasNoAffectCustomCorrelator() throws Exception {
AbstractApplicationContext context =
new ClassPathXmlApplicationContext("aggregator-with-custom-release-strategy.xml", this.getClass());
final MessageChannel inputChannel = context.getBean("aggregationChannelCustomCorrelation", MessageChannel.class);
@@ -112,7 +112,7 @@ public class AggregatorWithCustomReleaseStrategyTests {
@Override
public void run() {
inputChannel.send(MessageBuilder.withPayload("foo").
setHeader("correlation", "foo"+counter).build());
setHeader("correlation", "foo" + counter).build());
latch.countDown();
}
});
@@ -120,7 +120,7 @@ public class AggregatorWithCustomReleaseStrategyTests {
@Override
public void run() {
inputChannel.send(MessageBuilder.withPayload("bar").
setHeader("correlation", "foo"+counter).build());
setHeader("correlation", "foo" + counter).build());
latch.countDown();
}
});
@@ -128,7 +128,7 @@ public class AggregatorWithCustomReleaseStrategyTests {
@Override
public void run() {
inputChannel.send(MessageBuilder.withPayload("baz").
setHeader("correlation", "foo"+counter).build());
setHeader("correlation", "foo" + counter).build());
latch.countDown();
}
});
@@ -138,7 +138,7 @@ public class AggregatorWithCustomReleaseStrategyTests {
Message<?> message = resultChannel.receive(1000);
int counter = 0;
while(message != null){
while (message != null) {
counter++;
message = resultChannel.receive(1000);
}
@@ -146,7 +146,7 @@ public class AggregatorWithCustomReleaseStrategyTests {
context.close();
}
public void validateSequenceSizeHasNoAffectWithSplitter() throws Exception{
public void validateSequenceSizeHasNoAffectWithSplitter() throws Exception {
AbstractApplicationContext context =
new ClassPathXmlApplicationContext("aggregator-with-custom-release-strategy.xml", this.getClass());
final MessageChannel inputChannel = context.getBean("in", MessageChannel.class);
@@ -182,7 +182,7 @@ public class AggregatorWithCustomReleaseStrategyTests {
Message<?> message = resultChannel.receive(1000);
int counter = 0;
while(message != null && ++counter < 7200){
while (message != null && ++counter < 7200) {
message = resultChannel.receive(1000);
}
assertEquals(7200, counter);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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 AnnotationConfigRegistrationTests {
public static class TestBean {
@Publisher(channel="annotationConfigRegistrationTest")
@Publisher(channel = "annotationConfigRegistrationTest")
@Payload("#return + #args.lname")
public String setName(String fname, String lname, @Header("x") int num) {
return fname + " " + lname;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -81,18 +81,18 @@ public class MessagePublishingAnnotationUsageTests {
public static class TestBean {
@Publisher(channel="messagePublishingAnnotationUsageTestChannel")
@Publisher(channel = "messagePublishingAnnotationUsageTestChannel")
public String defaultPayload(String fname, @Header("last") String lname) {
return fname + " " + lname;
}
@Publisher(channel="messagePublishingAnnotationUsageTestChannel")
@Publisher(channel = "messagePublishingAnnotationUsageTestChannel")
@Payload
public String defaultPayloadButExplicitAnnotation(String fname, @Header String lname) {
return fname + " " + lname;
}
@Publisher(channel="messagePublishingAnnotationUsageTestChannel")
@Publisher(channel = "messagePublishingAnnotationUsageTestChannel")
public String argumentAsPayload(@Payload String fname, @Header String lname) {
return fname + " " + lname;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 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.
@@ -42,7 +42,7 @@ public class MessagePublishingInterceptorUsageTests {
private QueueChannel channel;
@Test
public void demoMessagePublishingInterceptor(){
public void demoMessagePublishingInterceptor() {
String name = testBean.setName("John", "Doe");
Assert.assertNotNull(name);
Message<?> message = channel.receive(1000);
@@ -54,7 +54,7 @@ public class MessagePublishingInterceptorUsageTests {
public static class TestBean {
public String setName(String fname, String lname){
public String setName(String fname, String lname) {
return fname + " " + lname;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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,25 +120,25 @@ public class MethodAnnotationPublisherMetadataSourceTests {
public void methodWithPayloadAnnotation(String arg1, int arg2) {
}
@Publisher(channel="foo")
@Publisher(channel = "foo")
@Payload("#return")
public String methodWithChannelAndExplicitReturnAsPayload() {
return "hello";
}
@Publisher(channel="foo")
@Publisher(channel = "foo")
@Payload
public String methodWithChannelAndEmptyPayloadAnnotation() {
return "hello";
}
@Publisher(channel="foo")
@Publisher(channel = "foo")
@Payload("#method")
public void methodWithVoidReturnAndMethodNameAsPayload() {
}
@Publisher(channel="foo")
@Publisher(channel = "foo")
@Payload("#return")
public void methodWithVoidReturnAndReturnValueAsPayload() {
}

View File

@@ -137,17 +137,17 @@ public class PublisherAnnotationAdvisorTests {
static class AnnotationAtMethodLevelTestBeanImpl implements TestBean, TestVoidBean {
@Publisher(channel="testChannel")
@Publisher(channel = "testChannel")
public String test() {
return "foo";
}
@Publisher(channel="testChannel")
public void testVoidMethod(@Payload String s) {}
@Publisher(channel = "testChannel")
public void testVoidMethod(@Payload String s) { }
}
@Publisher(channel="testChannel")
@Publisher(channel = "testChannel")
static class AnnotationAtClassLevelTestBeanImpl implements TestBean {
public String test() {
@@ -159,7 +159,7 @@ public class PublisherAnnotationAdvisorTests {
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Publisher(channel="testMetaChannel")
@Publisher(channel = "testMetaChannel")
public @interface TestMetaPublisher {
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2016 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.
@@ -134,7 +134,7 @@ public class DirectChannelSubscriptionTests {
@MessageEndpoint
public static class TestEndpoint {
@ServiceActivator(inputChannel="sourceChannel", outputChannel="targetChannel")
@ServiceActivator(inputChannel = "sourceChannel", outputChannel = "targetChannel")
public Message<?> handle(Message<?> message) {
return new GenericMessage<String>(message.getPayload() + "-from-annotated-endpoint");
}
@@ -144,7 +144,7 @@ public class DirectChannelSubscriptionTests {
@MessageEndpoint
public static class FailingTestEndpoint {
@ServiceActivator(inputChannel="sourceChannel", outputChannel="targetChannel")
@ServiceActivator(inputChannel = "sourceChannel", outputChannel = "targetChannel")
public Message<?> handle(Message<?> message) {
throw new RuntimeException("intentional test failure");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2016 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.
@@ -161,13 +161,13 @@ public class ChannelPurgerTests {
assertNotNull(channel2.receive(0));
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testNullChannel() {
QueueChannel channel = null;
new ChannelPurger(channel);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testEmptyChannelArray() {
QueueChannel[] channels = new QueueChannel[0];
new ChannelPurger(channels);

View File

@@ -38,7 +38,7 @@ public class DirectChannelParserTests {
"directChannelParserTests.xml", DirectChannelParserTests.class);
Object channel = context.getBean("channel");
assertEquals(DirectChannel.class, channel.getClass());
DirectFieldAccessor dcAccessor = new DirectFieldAccessor(((DirectChannel)channel).getDispatcher());
DirectFieldAccessor dcAccessor = new DirectFieldAccessor(((DirectChannel) channel).getDispatcher());
assertTrue(dcAccessor.getPropertyValue("loadBalancingStrategy") instanceof RoundRobinLoadBalancingStrategy);
context.close();
}

View File

@@ -109,12 +109,12 @@ public class MixedDispatcherConfigurationScenarioTests {
try {
channel.send(message);
}
catch (Exception e) {/* ignore */
catch (Exception e) { /* ignore */
}
try {
channel.send(message);
}
catch (Exception e) {/* ignore */
catch (Exception e) { /* ignore */
}
verify(handlerA, times(2)).handleMessage(message);
verify(handlerB, times(0)).handleMessage(message);
@@ -232,19 +232,19 @@ public class MixedDispatcherConfigurationScenarioTests {
try {
channel.send(message);
}
catch (Exception e) {/* ignore */
catch (Exception e) { /* ignore */
}
inOrder.verify(handlerA).handleMessage(message);
try {
channel.send(message);
}
catch (Exception e) {/* ignore */
catch (Exception e) { /* ignore */
}
inOrder.verify(handlerB).handleMessage(message);
try {
channel.send(message);
}
catch (Exception e) {/* ignore */
catch (Exception e) { /* ignore */
}
inOrder.verify(handlerC).handleMessage(message);
@@ -383,7 +383,7 @@ public class MixedDispatcherConfigurationScenarioTests {
try {
channel.send(message);
}
catch (Exception e) {/* ignore */
catch (Exception e) { /* ignore */
}
inOrder.verify(handlerA).handleMessage(message);
inOrder.verify(handlerB).handleMessage(message);
@@ -391,7 +391,7 @@ public class MixedDispatcherConfigurationScenarioTests {
try {
channel.send(message);
}
catch (Exception e) {/* ignore */
catch (Exception e) { /* ignore */
}
inOrder.verify(handlerA).handleMessage(message);
inOrder.verify(handlerB).handleMessage(message);

View File

@@ -33,8 +33,9 @@ import org.junit.Test;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.springframework.messaging.MessageHandler;
import org.springframework.integration.dispatcher.MessageDispatcher;
import org.springframework.messaging.MessageHandler;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.ReflectionUtils.FieldCallback;
@@ -78,14 +79,17 @@ public class P2pChannelTests {
when(logger.isInfoEnabled()).thenReturn(true);
final List<String> logs = new ArrayList<String>();
doAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
logs.add((String) invocation.getArguments()[0]);
return null;
}}).when(logger).info(Mockito.anyString());
}
}).when(logger).info(Mockito.anyString());
ReflectionUtils.doWithFields(AbstractMessageChannel.class, new FieldCallback() {
@Override
public void doWith(Field field) throws IllegalArgumentException,
IllegalAccessException {
if ("logger".equals(field.getName())){
if ("logger".equals(field.getName())) {
field.setAccessible(true);
field.set(channel, logger);
}
@@ -120,9 +124,10 @@ public class P2pChannelTests {
when(logger.isInfoEnabled()).thenReturn(true);
ReflectionUtils.doWithFields(AbstractMessageChannel.class, new FieldCallback() {
@Override
public void doWith(Field field) throws IllegalArgumentException,
IllegalAccessException {
if ("logger".equals(field.getName())){
if ("logger".equals(field.getName())) {
field.setAccessible(true);
field.set(channel, logger);
}
@@ -142,9 +147,10 @@ public class P2pChannelTests {
when(logger.isInfoEnabled()).thenReturn(true);
ReflectionUtils.doWithFields(AbstractMessageChannel.class, new FieldCallback() {
@Override
public void doWith(Field field) throws IllegalArgumentException,
IllegalAccessException {
if ("logger".equals(field.getName())){
if ("logger".equals(field.getName())) {
field.setAccessible(true);
field.set(channel, logger);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@@ -53,7 +53,7 @@ public class PriorityChannelTests {
}
@Test
public void testDefaultComparatorWithTimestampFallback() throws Exception{
public void testDefaultComparatorWithTimestampFallback() throws Exception {
PriorityChannel channel = new PriorityChannel();
for (int i = 0; i < 1000; i++) {
channel.send(new GenericMessage<Integer>(i));
@@ -86,7 +86,7 @@ public class PriorityChannelTests {
// although this test has no assertions it results in ConcurrentModificationException
// if executed before changes for INT-2508
@Test
public void testPriorityChannelWithConcurrentModification() throws Exception{
public void testPriorityChannelWithConcurrentModification() throws Exception {
final PriorityChannel channel = new PriorityChannel();
final Message<String> message = new GenericMessage<String>("hello");
for (int i = 0; i < 1000; i++) {

View File

@@ -54,7 +54,7 @@ public class ChannelCapacityPlaceholderTests {
public interface TestService {
@org.springframework.integration.annotation.Gateway(requestChannel="channel")
@org.springframework.integration.annotation.Gateway(requestChannel = "channel")
void test();
}

View File

@@ -63,7 +63,7 @@ public class ChannelWithCustomQueueParserTests {
Object queue = accessor.getPropertyValue("queue");
assertNotNull(queue);
assertThat(queue, is(instanceOf(ArrayBlockingQueue.class)));
assertThat(((BlockingQueue<?>)queue).remainingCapacity(), is(2));
assertThat(((BlockingQueue<?>) queue).remainingCapacity(), is(2));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2016 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.
@@ -110,7 +110,7 @@ public class ThreadLocalChannelParserTests {
public void testInterceptor() {
int before = interceptor.getSendCount();
channelWithInterceptor.send(new GenericMessage<String>("test"));
assertEquals(before+1, interceptor.getSendCount());
assertEquals(before + 1, interceptor.getSendCount());
}
}

Some files were not shown because too many files have changed in this diff Show More