From 27667075476627c43bb700dbef3c7a34d7619b1a Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Wed, 9 Jan 2019 13:30:08 -0500 Subject: [PATCH] Sonar fixes - remaining hidden fields * Fix copyright --- .../router/RecipientListRouter.java | 19 +++--- .../integration/store/MessageGroupQueue.java | 50 +++++++-------- .../integration/support/IdGenerators.java | 11 ++-- .../support/SmartLifecycleRoleController.java | 42 ++++++------ ...efaultDatatypeChannelMessageConverter.java | 13 ++-- .../management/ExponentialMovingAverage.java | 28 ++++---- .../ExponentialMovingAverageRate.java | 64 +++++++++---------- .../ExponentialMovingAverageRatio.java | 46 ++++++------- ...ngTransactionSynchronizationProcessor.java | 8 +-- ...outingSlipHeaderValueMessageProcessor.java | 22 +++---- .../tcp/connection/TcpConnectionSupport.java | 8 +-- .../integration/mail/ImapMailReceiver.java | 8 +-- .../mail/config/MailReceiverFactoryBean.java | 36 ++++++----- .../mqtt/outbound/MqttPahoMessageHandler.java | 14 ++-- .../channel/SubscribableRedisChannel.java | 12 ++-- .../outbound/ExpressionArgumentsStrategy.java | 11 ++-- .../session/DefaultSftpSessionFactory.java | 8 +-- .../stomp/AbstractStompSessionManager.java | 10 +-- .../inbound/StompInboundChannelAdapter.java | 13 ++-- .../stomp/outbound/StompMessageHandler.java | 17 ++--- ...logReceivingChannelAdapterFactoryBean.java | 28 ++++---- .../SyslogReceivingChannelAdapterTests.java | 8 +-- .../integration/test/mail/TestMailServer.java | 14 ++-- .../test/matcher/PayloadAndHeaderMatcher.java | 15 +++-- .../ws/AbstractWebServiceOutboundGateway.java | 10 +-- .../transformer/AbstractXmlTransformer.java | 13 ++-- .../config/XmppConnectionFactoryBean.java | 13 ++-- .../inbound/ChatMessageListeningEndpoint.java | 11 ++-- 28 files changed, 280 insertions(+), 272 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/router/RecipientListRouter.java b/spring-integration-core/src/main/java/org/springframework/integration/router/RecipientListRouter.java index 83dd1cdf35..766845b3d2 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/router/RecipientListRouter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/router/RecipientListRouter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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,10 +84,9 @@ public class RecipientListRouter extends AbstractMessageRouter */ public void setChannels(List channels) { Assert.notEmpty(channels, "'channels' must not be empty"); - List recipients = channels.stream() + setRecipients(channels.stream() .map(Recipient::new) - .collect(Collectors.toList()); - setRecipients(recipients); + .collect(Collectors.toList())); } /** @@ -300,11 +299,13 @@ public class RecipientListRouter extends AbstractMessageRouter } public MessageChannel getChannel() { - String channelName = this.channelName; - if (channelName != null) { - if (this.channelResolver != null) { - this.channel = this.channelResolver.resolveDestination(channelName); - this.channelName = null; + if (this.channel == null) { + String channelNameForInitialization = this.channelName; + if (channelNameForInitialization != null) { + if (this.channelResolver != null) { + this.channel = this.channelResolver.resolveDestination(channelNameForInitialization); + this.channelName = null; + } } } return this.channel; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/store/MessageGroupQueue.java b/spring-integration-core/src/main/java/org/springframework/integration/store/MessageGroupQueue.java index ce4caf2a78..03ab44c04a 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/store/MessageGroupQueue.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/store/MessageGroupQueue.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -165,9 +165,9 @@ public class MessageGroupQueue extends AbstractQueue> implements Bloc @Override public Message peek() { Message message = null; - final Lock storeLock = this.storeLock; + final Lock lock = this.storeLock; try { - storeLock.lockInterruptibly(); + lock.lockInterruptibly(); try { Collection> messages = getMessages(); if (!messages.isEmpty()) { @@ -175,7 +175,7 @@ public class MessageGroupQueue extends AbstractQueue> implements Bloc } } finally { - storeLock.unlock(); + lock.unlock(); } } catch (InterruptedException e) { @@ -188,8 +188,8 @@ public class MessageGroupQueue extends AbstractQueue> implements Bloc public Message poll(long timeout, TimeUnit unit) throws InterruptedException { Message message = null; long timeoutInNanos = unit.toNanos(timeout); - final Lock storeLock = this.storeLock; - storeLock.lockInterruptibly(); + final Lock lock = this.storeLock; + lock.lockInterruptibly(); try { message = doPoll(); @@ -199,7 +199,7 @@ public class MessageGroupQueue extends AbstractQueue> implements Bloc } } finally { - storeLock.unlock(); + lock.unlock(); } return message; } @@ -207,14 +207,14 @@ public class MessageGroupQueue extends AbstractQueue> implements Bloc @Override public Message poll() { Message message = null; - final Lock storeLock = this.storeLock; + final Lock lock = this.storeLock; try { - storeLock.lockInterruptibly(); + lock.lockInterruptibly(); try { message = this.doPoll(); } finally { - storeLock.unlock(); + lock.unlock(); } } catch (InterruptedException e) { @@ -233,9 +233,9 @@ public class MessageGroupQueue extends AbstractQueue> implements Bloc Assert.notNull(collection, "'collection' must not be null"); int originalSize = collection.size(); ArrayList> list = new ArrayList<>(); - final Lock storeLock = this.storeLock; + final Lock lock = this.storeLock; try { - storeLock.lockInterruptibly(); + lock.lockInterruptibly(); try { Message message = this.messageGroupStore.pollMessageFromGroup(this.groupId); for (int i = 0; i < maxElements && message != null; i++) { @@ -245,7 +245,7 @@ public class MessageGroupQueue extends AbstractQueue> implements Bloc this.messageStoreNotFull.signal(); } finally { - storeLock.unlock(); + lock.unlock(); } } catch (InterruptedException e) { @@ -259,14 +259,14 @@ public class MessageGroupQueue extends AbstractQueue> implements Bloc @Override public boolean offer(Message message) { boolean offered = true; - final Lock storeLock = this.storeLock; + final Lock lock = this.storeLock; try { - storeLock.lockInterruptibly(); + lock.lockInterruptibly(); try { offered = this.doOffer(message); } finally { - storeLock.unlock(); + lock.unlock(); } } catch (InterruptedException e) { @@ -280,8 +280,8 @@ public class MessageGroupQueue extends AbstractQueue> implements Bloc long timeoutInNanos = unit.toNanos(timeout); boolean offered = false; - final Lock storeLock = this.storeLock; - storeLock.lockInterruptibly(); + final Lock lock = this.storeLock; + lock.lockInterruptibly(); try { if (this.capacity != Integer.MAX_VALUE) { while (this.size() == this.capacity && timeoutInNanos > 0) { @@ -293,15 +293,15 @@ public class MessageGroupQueue extends AbstractQueue> implements Bloc } } finally { - storeLock.unlock(); + lock.unlock(); } return offered; } @Override public void put(Message message) throws InterruptedException { - final Lock storeLock = this.storeLock; - storeLock.lockInterruptibly(); + final Lock lock = this.storeLock; + lock.lockInterruptibly(); try { if (this.capacity != Integer.MAX_VALUE) { while (this.size() == this.capacity) { @@ -311,7 +311,7 @@ public class MessageGroupQueue extends AbstractQueue> implements Bloc this.doOffer(message); } finally { - storeLock.unlock(); + lock.unlock(); } } @@ -326,8 +326,8 @@ public class MessageGroupQueue extends AbstractQueue> implements Bloc @Override public Message take() throws InterruptedException { Message message = null; - final Lock storeLock = this.storeLock; - storeLock.lockInterruptibly(); + final Lock lock = this.storeLock; + lock.lockInterruptibly(); try { while (this.size() == 0) { @@ -337,7 +337,7 @@ public class MessageGroupQueue extends AbstractQueue> implements Bloc } finally { - storeLock.unlock(); + lock.unlock(); } return message; } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/IdGenerators.java b/spring-integration-core/src/main/java/org/springframework/integration/support/IdGenerators.java index 2403f89e05..4febb32084 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/IdGenerators.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/IdGenerators.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2015 the original author or authors. + * Copyright 2013-2019 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. @@ -26,6 +26,7 @@ import org.springframework.util.IdGenerator; * Alternative {@link IdGenerator} implementations. * * @author Andy Wilkinson + * @author Gary Russell * @since 4.0 * */ @@ -67,12 +68,12 @@ public class IdGenerators { @Override public UUID generateId() { - long bottomBits = this.bottomBits.incrementAndGet(); - if (bottomBits == 0) { - return new UUID(this.topBits.incrementAndGet(), bottomBits); + long lowerBits = this.bottomBits.incrementAndGet(); + if (lowerBits == 0) { + return new UUID(this.topBits.incrementAndGet(), lowerBits); } else { - return new UUID(this.topBits.get(), bottomBits); + return new UUID(this.topBits.get(), lowerBits); } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/SmartLifecycleRoleController.java b/spring-integration-core/src/main/java/org/springframework/integration/support/SmartLifecycleRoleController.java index a7cdcfe270..3260799b44 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/SmartLifecycleRoleController.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/SmartLifecycleRoleController.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2018 the original author or authors. + * Copyright 2015-2019 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,12 +102,12 @@ public class SmartLifecycleRoleController implements ApplicationListener lifecycles = this.lifecycles.get(role); - if (CollectionUtils.isEmpty(lifecycles)) { + List componentsInRole = this.lifecycles.get(role); + if (CollectionUtils.isEmpty(componentsInRole)) { this.lifecycles.add(role, lifecycle); } else { - lifecycles + componentsInRole .stream() .filter(e -> e == lifecycle || @@ -125,7 +125,7 @@ public class SmartLifecycleRoleController implements ApplicationListener 0) { addLazyLifecycles(); } - List lifecycles = this.lifecycles.get(role); - if (lifecycles != null) { - lifecycles = new ArrayList<>(lifecycles); - lifecycles.sort(Comparator.comparingInt(Phased::getPhase)); + List componentsInRole = this.lifecycles.get(role); + if (componentsInRole != null) { + componentsInRole = new ArrayList<>(componentsInRole); + componentsInRole.sort(Comparator.comparingInt(Phased::getPhase)); if (logger.isDebugEnabled()) { - logger.debug("Starting " + lifecycles + " in role " + role); + logger.debug("Starting " + componentsInRole + " in role " + role); } - lifecycles.forEach(lifecycle -> { + componentsInRole.forEach(lifecycle -> { try { lifecycle.start(); } @@ -189,15 +189,15 @@ public class SmartLifecycleRoleController implements ApplicationListener 0) { addLazyLifecycles(); } - List lifecycles = this.lifecycles.get(role); - if (lifecycles != null) { - lifecycles = new ArrayList<>(lifecycles); - lifecycles.sort((o1, o2) -> Integer.compare(o2.getPhase(), o1.getPhase())); + List componentsInRole = this.lifecycles.get(role); + if (componentsInRole != null) { + componentsInRole = new ArrayList<>(componentsInRole); + componentsInRole.sort((o1, o2) -> Integer.compare(o2.getPhase(), o1.getPhase())); if (logger.isDebugEnabled()) { - logger.debug("Stopping " + lifecycles + " in role " + role); + logger.debug("Stopping " + componentsInRole + " in role " + role); } - lifecycles.forEach(lifecycle -> { + componentsInRole.forEach(lifecycle -> { try { lifecycle.stop(); } @@ -312,10 +312,10 @@ public class SmartLifecycleRoleController implements ApplicationListener lifecycles : this.lifecycles.values()) { - boolean actualRemoved = lifecycles.removeIf(Predicate.isEqual(lifecycle)); - if (!removed) { - removed = actualRemoved; + for (List componentsInRole : this.lifecycles.values()) { + removed = componentsInRole.removeIf(Predicate.isEqual(lifecycle)); + if (removed) { + break; } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/DefaultDatatypeChannelMessageConverter.java b/spring-integration-core/src/main/java/org/springframework/integration/support/converter/DefaultDatatypeChannelMessageConverter.java index 1ba5638580..5606e05cef 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/DefaultDatatypeChannelMessageConverter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/converter/DefaultDatatypeChannelMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2019 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,13 +72,12 @@ public class DefaultDatatypeChannelMessageConverter implements MessageConverter, */ @Override public Object fromMessage(Message message, Class targetClass) { - ConversionService conversionService = this.conversionService; - if (conversionService != null) { - if (conversionService.canConvert(message.getPayload().getClass(), targetClass)) { - return conversionService.convert(message.getPayload(), targetClass); - } + if (this.conversionService.canConvert(message.getPayload().getClass(), targetClass)) { + return this.conversionService.convert(message.getPayload(), targetClass); + } + else { + return null; } - return null; } @Override diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverage.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverage.java index 8625dd8d20..8719578401 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverage.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverage.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2016 the original author or authors. + * Copyright 2009-2019 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. @@ -98,41 +98,41 @@ public class ExponentialMovingAverage { private Statistics calc() { List copy; - long count; + long currentCount; synchronized (this) { copy = new ArrayList(this.samples); - count = this.count; + currentCount = this.count; } double sum = 0; double decay = 1 - 1. / this.window; double sumSquares = 0; double weight = 0; - double min = this.min; - double max = this.max; + double currentMin = this.min; + double currentMax = this.max; for (Double value : copy) { value /= this.factor; - if (value > max) { - max = value; + if (value > currentMax) { + currentMax = value; } - if (value < min) { - min = value; + if (value < currentMin) { + currentMin = value; } sum = decay * sum + value; sumSquares = decay * sumSquares + value * value; weight = decay * weight + 1; } synchronized (this) { - if (max > this.max) { - this.max = max; + if (currentMax > this.max) { + this.max = currentMax; } - if (min < this.min) { - this.min = min; + if (currentMin < this.min) { + this.min = currentMin; } } 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(currentCount, currentMin == Double.MAX_VALUE ? 0 : currentMin, currentMax, mean, standardDeviation); //NOSONAR } /** diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverageRate.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverageRate.java index 44afa0e4a1..ea44a1df52 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverageRate.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverageRate.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2017 the original author or authors. + * Copyright 2009-2019 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,50 +120,50 @@ public class ExponentialMovingAverageRate { private Statistics calcStatic() { List copy; - long count; + long currentCount; synchronized (this) { copy = new ArrayList(this.times); - count = this.count; + currentCount = this.count; } ExponentialMovingAverage rates = new ExponentialMovingAverage(this.window); - double t0 = 0; + double currentT0 = 0; double sum = 0; double weight = 0; - double min = this.min; - double max = this.max; + double currentMin = this.min; + double currentMax = this.max; int size = copy.size(); for (Long time : copy) { double t = time / this.factor; if (size == 1) { - t0 = this.t0; + currentT0 = this.t0; } - else if (t0 == 0) { - t0 = t; + else if (currentT0 == 0) { + currentT0 = t; continue; } - double delta = t - t0; + double delta = t - currentT0; double value = delta > 0 ? delta / this.period : 0; - if (value > max) { - max = value; + if (value > currentMax) { + currentMax = value; } - if (value < min) { - min = value; + if (value < currentMin) { + currentMin = value; } double alpha = Math.exp(-delta * this.lapse); - t0 = t; + currentT0 = t; sum = alpha * sum + value; weight = alpha * weight + 1; rates.append(sum > 0 ? weight / sum : 0); } synchronized (this) { - if (max > this.max) { - this.max = max; + if (currentMax > this.max) { + this.max = currentMax; } - if (min < this.min) { - this.min = min; + if (currentMin < this.min) { + this.min = currentMin; } } - return new Statistics(count, min < Double.MAX_VALUE ? min : 0, max, rates.getMean(), + return new Statistics(currentCount, currentMin < Double.MAX_VALUE ? currentMin : 0, currentMax, rates.getMean(), rates.getStandardDeviation()); } @@ -189,8 +189,8 @@ public class ExponentialMovingAverageRate { if (this.count == 0) { return 0; } - double t0 = lastTime(); - return (System.nanoTime() / this.factor - t0); + double currentT0 = lastTime(); + return (System.nanoTime() / this.factor - currentT0); } /** @@ -206,15 +206,15 @@ public class ExponentialMovingAverageRate { * @return the new mean. */ private double recalcMean(Statistics staticStats) { - long count = this.count; - count = count > this.retention ? this.retention : count; - if (count == 0) { + long currentCount = this.count; + currentCount = currentCount > this.retention ? this.retention : currentCount; + if (currentCount == 0) { return 0; } - double t0 = lastTime(); + double currentT0 = lastTime(); double t = System.nanoTime() / this.factor; - double value = t > t0 ? (t - t0) / this.period : 0; - return count / (count / staticStats.getMean() + value); + double value = t > currentT0 ? (t - currentT0) / this.period : 0; + return currentCount / (currentCount / staticStats.getMean() + value); } private synchronized double lastTime() { @@ -237,16 +237,16 @@ public class ExponentialMovingAverageRate { * @return the maximum value recorded (not weighted) */ public double getMax() { - double min = calcStatic().getMin(); - return min > 0 ? 1 / min : 0; + double currentMin = calcStatic().getMin(); + return currentMin > 0 ? 1 / currentMin : 0; } /** * @return the minimum value recorded (not weighted) */ public double getMin() { - double max = calcStatic().getMax(); - return max > 0 ? 1 / max : 0; + double currentMax = calcStatic().getMax(); + return currentMax > 0 ? 1 / currentMax : 0; } /** diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverageRatio.java b/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverageRatio.java index 6d5d7cccd6..384c0e446d 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverageRatio.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/management/ExponentialMovingAverageRatio.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2017 the original author or authors. + * Copyright 2009-2019 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. @@ -140,52 +140,52 @@ public class ExponentialMovingAverageRatio { private Statistics calcStatic() { List copyTimes; List copyValues; - long count; + long currentCount; synchronized (this) { copyTimes = new ArrayList(this.times); copyValues = new ArrayList(this.values); - count = this.count; + currentCount = this.count; } ExponentialMovingAverage cumulative = new ExponentialMovingAverage(this.window); - double t0 = 0; + double currentT0 = 0; double sum = 0; double weight = 0; - double min = this.min; - double max = this.max; + double currentMin = this.min; + double currentMax = this.max; int size = copyTimes.size(); - Iterator values = copyValues.iterator(); + Iterator valuesIterator = copyValues.iterator(); for (Long time : copyTimes) { double t = time / this.factor; if (size == 1) { - t0 = this.t0; + currentT0 = this.t0; } - else if (t0 == 0) { - t0 = t; - values.next(); + else if (currentT0 == 0) { + currentT0 = t; + valuesIterator.next(); continue; } - double alpha = Math.exp((t0 - t) * this.lapse); - t0 = t; - sum = alpha * sum + values.next(); + double alpha = Math.exp((currentT0 - t) * this.lapse); + currentT0 = t; + sum = alpha * sum + valuesIterator.next(); weight = alpha * weight + 1; double value = sum / weight; - if (value > max) { - max = value; + if (value > currentMax) { + currentMax = value; } - if (value < min) { - min = value; + if (value < currentMin) { + currentMin = value; } cumulative.append(value); } synchronized (this) { - if (max > this.max) { - this.max = max; + if (currentMax > this.max) { + this.max = currentMax; } - if (min < this.min) { - this.min = min; + if (currentMin < this.min) { + this.min = currentMin; } } - return new Statistics(count, min < Double.MAX_VALUE ? min : 0, max, cumulative.getMean(), + return new Statistics(currentCount, currentMin < Double.MAX_VALUE ? currentMin : 0, currentMax, cumulative.getMean(), cumulative.getStandardDeviation()); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transaction/ExpressionEvaluatingTransactionSynchronizationProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/transaction/ExpressionEvaluatingTransactionSynchronizationProcessor.java index 1d8705e887..2b9c7b766d 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/transaction/ExpressionEvaluatingTransactionSynchronizationProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/transaction/ExpressionEvaluatingTransactionSynchronizationProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -201,15 +201,15 @@ public class ExpressionEvaluatingTransactionSynchronizationProcessor extends Int */ private EvaluationContext prepareEvaluationContextToUse(Object resource) { if (resource != null) { - EvaluationContext evaluationContext = createEvaluationContext(); + EvaluationContext evaluationContextWithVariables = createEvaluationContext(); if (resource instanceof IntegrationResourceHolder) { IntegrationResourceHolder holder = (IntegrationResourceHolder) resource; for (Entry entry : holder.getAttributes().entrySet()) { String key = entry.getKey(); - evaluationContext.setVariable(key, entry.getValue()); + evaluationContextWithVariables.setVariable(key, entry.getValue()); } } - return evaluationContext; + return evaluationContextWithVariables; } else { return this.evaluationContext; 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 972f735cca..caf9d242cb 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 @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2019 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. @@ -77,14 +77,14 @@ public class RoutingSlipHeaderValueMessageProcessor @Override public Map, Integer> processMessage(Message message) { // use a local variable to avoid the second access to volatile field on the happy path - Map, Integer> routingSlip = this.routingSlip; - if (routingSlip == null) { + Map, Integer> slip = this.routingSlip; + if (slip == null) { synchronized (this) { - routingSlip = this.routingSlip; - if (routingSlip == null) { - List routingSlipPath = this.routingSlipPath; - List routingSlipValues = new ArrayList(routingSlipPath.size()); - for (Object path : routingSlipPath) { + slip = this.routingSlip; + if (slip == null) { + List slipPath = this.routingSlipPath; + List routingSlipValues = new ArrayList(slipPath.size()); + for (Object path : slipPath) { if (path instanceof String) { String entry = (String) path; if (this.beanFactory.containsBean(entry)) { @@ -114,12 +114,12 @@ public class RoutingSlipHeaderValueMessageProcessor } } - routingSlip = Collections.singletonMap(Collections.unmodifiableList(routingSlipValues), 0); - this.routingSlip = routingSlip; + slip = Collections.singletonMap(Collections.unmodifiableList(routingSlipValues), 0); + this.routingSlip = slip; } } } - return routingSlip; + return slip; } } diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpConnectionSupport.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpConnectionSupport.java index 4843894260..15d270e1dc 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpConnectionSupport.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpConnectionSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2001-2018 the original author or authors. + * Copyright 2001-2019 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. @@ -163,12 +163,12 @@ public abstract class TcpConnectionSupport implements TcpConnection { * @param isException true when this call is the result of an Exception. */ protected void closeConnection(boolean isException) { - TcpListener listener = getListener(); - if (!(listener instanceof TcpConnectionInterceptor)) { + TcpListener tcpListener = getListener(); + if (!(tcpListener instanceof TcpConnectionInterceptor)) { close(); } else { - TcpConnectionInterceptor outerListener = (TcpConnectionInterceptor) listener; + TcpConnectionInterceptor outerListener = (TcpConnectionInterceptor) tcpListener; while (outerListener.getListener() instanceof TcpConnectionInterceptor) { TcpConnectionInterceptor nextListener = (TcpConnectionInterceptor) outerListener.getListener(); if (nextListener == null) { diff --git a/spring-integration-mail/src/main/java/org/springframework/integration/mail/ImapMailReceiver.java b/spring-integration-mail/src/main/java/org/springframework/integration/mail/ImapMailReceiver.java index 19c063aa4e..3e769c2215 100755 --- a/spring-integration-mail/src/main/java/org/springframework/integration/mail/ImapMailReceiver.java +++ b/spring-integration-mail/src/main/java/org/springframework/integration/mail/ImapMailReceiver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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,9 +134,9 @@ public class ImapMailReceiver extends AbstractMailReceiver { super.onInit(); this.scheduler = getTaskScheduler(); if (this.scheduler == null) { - ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler(); - scheduler.initialize(); - this.scheduler = scheduler; + ThreadPoolTaskScheduler tpts = new ThreadPoolTaskScheduler(); + tpts.initialize(); + this.scheduler = tpts; this.isInternalScheduler = true; } Properties javaMailProperties = getJavaMailProperties(); diff --git a/spring-integration-mail/src/main/java/org/springframework/integration/mail/config/MailReceiverFactoryBean.java b/spring-integration-mail/src/main/java/org/springframework/integration/mail/config/MailReceiverFactoryBean.java index 3c1bd536ce..89e40a017c 100644 --- a/spring-integration-mail/src/main/java/org/springframework/integration/mail/config/MailReceiverFactoryBean.java +++ b/spring-integration-mail/src/main/java/org/springframework/integration/mail/config/MailReceiverFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2019 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. @@ -192,31 +192,33 @@ public class MailReceiverFactoryBean implements FactoryBean, Dispo boolean isPop3 = this.protocol.toLowerCase().startsWith("pop3"); boolean isImap = this.protocol.toLowerCase().startsWith("imap"); Assert.isTrue(isPop3 || isImap, "the store URI must begin with 'pop3' or 'imap'"); - AbstractMailReceiver receiver = isPop3 ? new Pop3MailReceiver(this.storeUri) : new ImapMailReceiver(this.storeUri); + AbstractMailReceiver mailReceiver = isPop3 + ? new Pop3MailReceiver(this.storeUri) + : new ImapMailReceiver(this.storeUri); if (this.session != null) { Assert.isNull(this.javaMailProperties, "JavaMail Properties are not allowed when a Session has been provided."); Assert.isNull(this.authenticator, "A JavaMail Authenticator is not allowed when a Session has been provided."); - receiver.setSession(this.session); + mailReceiver.setSession(this.session); } if (this.searchTermStrategy != null) { Assert.isTrue(isImap, "searchTermStrategy is only allowed with imap"); - ((ImapMailReceiver) receiver).setSearchTermStrategy(this.searchTermStrategy); + ((ImapMailReceiver) mailReceiver).setSearchTermStrategy(this.searchTermStrategy); } if (this.javaMailProperties != null) { - receiver.setJavaMailProperties(this.javaMailProperties); + mailReceiver.setJavaMailProperties(this.javaMailProperties); } if (this.authenticator != null) { - receiver.setJavaMailAuthenticator(this.authenticator); + mailReceiver.setJavaMailAuthenticator(this.authenticator); } if (this.shouldDeleteMessages != null) { // always set the value if configured explicitly // otherwise, the default is true for POP3 but false for IMAP - receiver.setShouldDeleteMessages(this.shouldDeleteMessages); + mailReceiver.setShouldDeleteMessages(this.shouldDeleteMessages); } - receiver.setMaxFetchSize(this.maxFetchSize); - receiver.setSelectorExpression(this.selectorExpression); + mailReceiver.setMaxFetchSize(this.maxFetchSize); + mailReceiver.setSelectorExpression(this.selectorExpression); if (StringUtils.hasText(this.userFlag)) { - receiver.setUserFlag(this.userFlag); + mailReceiver.setUserFlag(this.userFlag); } if (isPop3) { @@ -225,22 +227,22 @@ public class MailReceiverFactoryBean implements FactoryBean, Dispo } } else if (isImap) { - ((ImapMailReceiver) receiver).setShouldMarkMessagesAsRead(this.shouldMarkMessagesAsRead); + ((ImapMailReceiver) mailReceiver).setShouldMarkMessagesAsRead(this.shouldMarkMessagesAsRead); } if (this.beanFactory != null) { - receiver.setBeanFactory(this.beanFactory); + mailReceiver.setBeanFactory(this.beanFactory); } if (this.headerMapper != null) { - receiver.setHeaderMapper(this.headerMapper); + mailReceiver.setHeaderMapper(this.headerMapper); } if (this.embeddedPartsAsBytes != null) { - receiver.setEmbeddedPartsAsBytes(this.embeddedPartsAsBytes); + mailReceiver.setEmbeddedPartsAsBytes(this.embeddedPartsAsBytes); } if (this.simpleContent != null) { - receiver.setSimpleContent(this.simpleContent); + mailReceiver.setSimpleContent(this.simpleContent); } - receiver.afterPropertiesSet(); - return receiver; + mailReceiver.afterPropertiesSet(); + return mailReceiver; } @Override diff --git a/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/outbound/MqttPahoMessageHandler.java b/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/outbound/MqttPahoMessageHandler.java index bfffcc5693..afc8b26415 100644 --- a/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/outbound/MqttPahoMessageHandler.java +++ b/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/outbound/MqttPahoMessageHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -146,10 +146,10 @@ public class MqttPahoMessageHandler extends AbstractMqttMessageHandler @Override protected void doStop() { try { - IMqttAsyncClient client = this.client; - if (client != null) { - client.disconnect().waitForCompletion(this.completionTimeout); - client.close(); + IMqttAsyncClient theClient = this.client; + if (theClient != null) { + theClient.disconnect().waitForCompletion(this.completionTimeout); + theClient.close(); this.client = null; } } @@ -191,8 +191,8 @@ public class MqttPahoMessageHandler extends AbstractMqttMessageHandler @Override protected void publish(String topic, Object mqttMessage, Message message) throws Exception { Assert.isInstanceOf(MqttMessage.class, mqttMessage); - IMqttAsyncClient client = checkConnection(); - IMqttDeliveryToken token = client.publish(topic, (MqttMessage) mqttMessage); + IMqttDeliveryToken token = checkConnection() + .publish(topic, (MqttMessage) mqttMessage); if (!this.async) { token.waitForCompletion(this.completionTimeout); } diff --git a/spring-integration-redis/src/main/java/org/springframework/integration/redis/channel/SubscribableRedisChannel.java b/spring-integration-redis/src/main/java/org/springframework/integration/redis/channel/SubscribableRedisChannel.java index c5d513d06d..2b34b480a0 100644 --- a/spring-integration-redis/src/main/java/org/springframework/integration/redis/channel/SubscribableRedisChannel.java +++ b/spring-integration-redis/src/main/java/org/springframework/integration/redis/channel/SubscribableRedisChannel.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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,16 +214,14 @@ public class SubscribableRedisChannel extends AbstractMessageChannel SubscribableRedisChannel.this.dispatcher.dispatch(siMessage); } catch (MessageDispatchingException e) { - String topicName = - StringUtils.hasText(SubscribableRedisChannel.this.topicName) - ? SubscribableRedisChannel.this.topicName - : "unknown"; String exceptionMessage = e.getMessage(); throw new MessageDeliveryException(siMessage, (exceptionMessage == null ? e.getClass().getSimpleName() : exceptionMessage) + " for redis-channel '" - + topicName - + "' (" + getFullChannelName() + ").", e); // NOSONAR false - never null + + (StringUtils.hasText(SubscribableRedisChannel.this.topicName) + ? SubscribableRedisChannel.this.topicName + : "unknown") + + "' (" + getFullChannelName() + ").", e); // NOSONAR false positive - never null } } diff --git a/spring-integration-redis/src/main/java/org/springframework/integration/redis/outbound/ExpressionArgumentsStrategy.java b/spring-integration-redis/src/main/java/org/springframework/integration/redis/outbound/ExpressionArgumentsStrategy.java index c098bc045b..f44fdbb0af 100644 --- a/spring-integration-redis/src/main/java/org/springframework/integration/redis/outbound/ExpressionArgumentsStrategy.java +++ b/spring-integration-redis/src/main/java/org/springframework/integration/redis/outbound/ExpressionArgumentsStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2015 the original author or authors. + * Copyright 2014-2019 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. @@ -34,6 +34,7 @@ import org.springframework.util.Assert; /** * @author Artem Bilan + * @author Gary Russell * @since 4.0 */ public class ExpressionArgumentsStrategy implements ArgumentsStrategy, BeanFactoryAware, InitializingBean { @@ -81,16 +82,16 @@ public class ExpressionArgumentsStrategy implements ArgumentsStrategy, BeanFacto @Override public Object[] resolve(String command, Message message) { - EvaluationContext evaluationContext = this.evaluationContext; + EvaluationContext evaluationContextToUse = this.evaluationContext; if (this.useCommandVariable) { - evaluationContext = IntegrationContextUtils.getEvaluationContext(this.beanFactory); - evaluationContext.setVariable("cmd", command); + evaluationContextToUse = IntegrationContextUtils.getEvaluationContext(this.beanFactory); + evaluationContextToUse.setVariable("cmd", command); } List arguments = new ArrayList(); for (Expression argumentExpression : this.argumentExpressions) { - Object argument = argumentExpression.getValue(evaluationContext, message); + Object argument = argumentExpression.getValue(evaluationContextToUse, message); if (argument != null) { arguments.add(argument); } diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/DefaultSftpSessionFactory.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/DefaultSftpSessionFactory.java index 45458239e8..14472c7d4a 100644 --- a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/DefaultSftpSessionFactory.java +++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/DefaultSftpSessionFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -417,9 +417,9 @@ public class DefaultSftpSessionFactory implements SessionFactory, Share if (this.sessionConfig != null) { jschSession.setConfig(this.sessionConfig); } - String password = this.userInfoWrapper.getPassword(); - if (StringUtils.hasText(password)) { - jschSession.setPassword(password); + String pw = this.userInfoWrapper.getPassword(); + if (StringUtils.hasText(pw)) { + jschSession.setPassword(pw); } jschSession.setUserInfo(this.userInfoWrapper); diff --git a/spring-integration-stomp/src/main/java/org/springframework/integration/stomp/AbstractStompSessionManager.java b/spring-integration-stomp/src/main/java/org/springframework/integration/stomp/AbstractStompSessionManager.java index 2a5205eb0f..39ec5d74a8 100644 --- a/spring-integration-stomp/src/main/java/org/springframework/integration/stomp/AbstractStompSessionManager.java +++ b/spring-integration-stomp/src/main/java/org/springframework/integration/stomp/AbstractStompSessionManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2018 the original author or authors. + * Copyright 2015-2019 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. @@ -181,7 +181,7 @@ public abstract class AbstractStompSessionManager implements StompSessionManager this.logger.debug("Aborting connect; another thread is connecting."); return; } - final int epoch = this.epoch.get(); + final int currentEpoch = this.epoch.get(); this.connecting = true; if (this.logger.isDebugEnabled()) { this.logger.debug("Connecting " + this); @@ -190,7 +190,7 @@ public abstract class AbstractStompSessionManager implements StompSessionManager this.stompSessionListenableFuture = doConnect(this.compositeStompSessionHandler); } catch (Exception e) { - if (epoch == this.epoch.get()) { + if (currentEpoch == this.epoch.get()) { scheduleReconnect(e); } else { @@ -218,7 +218,7 @@ public abstract class AbstractStompSessionManager implements StompSessionManager e -> { AbstractStompSessionManager.this.logger.debug("onFailure", e); connectLatch.countDown(); - if (epoch == AbstractStompSessionManager.this.epoch.get()) { + if (currentEpoch == AbstractStompSessionManager.this.epoch.get()) { scheduleReconnect(e); } }); @@ -226,7 +226,7 @@ public abstract class AbstractStompSessionManager implements StompSessionManager try { if (!connectLatch.await(30, TimeUnit.SECONDS)) { this.logger.error("No response to connection attempt"); - if (epoch == this.epoch.get()) { + if (currentEpoch == this.epoch.get()) { scheduleReconnect(null); } } diff --git a/spring-integration-stomp/src/main/java/org/springframework/integration/stomp/inbound/StompInboundChannelAdapter.java b/spring-integration-stomp/src/main/java/org/springframework/integration/stomp/inbound/StompInboundChannelAdapter.java index a14a5b33ad..590a064239 100644 --- a/spring-integration-stomp/src/main/java/org/springframework/integration/stomp/inbound/StompInboundChannelAdapter.java +++ b/spring-integration-stomp/src/main/java/org/springframework/integration/stomp/inbound/StompInboundChannelAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2018 the original author or authors. + * Copyright 2015-2019 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,6 +61,7 @@ import org.springframework.util.Assert; * if provided {@link StompSessionManager} supports {@code autoReceiptEnabled}. * * @author Artem Bilan + * @author Gary Russell * * @since 4.2 */ @@ -240,19 +241,19 @@ public class StompInboundChannelAdapter extends MessageProducerSupport implement }); if (this.stompSessionManager.isAutoReceiptEnabled()) { - final ApplicationEventPublisher applicationEventPublisher = this.applicationEventPublisher; - if (applicationEventPublisher != null) { + final ApplicationEventPublisher eventPublisher = this.applicationEventPublisher; + if (eventPublisher != null) { subscription.addReceiptTask(() -> { StompReceiptEvent event = new StompReceiptEvent(StompInboundChannelAdapter.this, destination, subscription.getReceiptId(), StompCommand.SUBSCRIBE, false); - applicationEventPublisher.publishEvent(event); + eventPublisher.publishEvent(event); }); } subscription.addReceiptLostTask(() -> { - if (applicationEventPublisher != null) { + if (eventPublisher != null) { StompReceiptEvent event = new StompReceiptEvent(StompInboundChannelAdapter.this, destination, subscription.getReceiptId(), StompCommand.SUBSCRIBE, true); - applicationEventPublisher.publishEvent(event); + eventPublisher.publishEvent(event); } else { logger.error("The receipt [" + subscription.getReceiptId() + "] is lost for [" + diff --git a/spring-integration-stomp/src/main/java/org/springframework/integration/stomp/outbound/StompMessageHandler.java b/spring-integration-stomp/src/main/java/org/springframework/integration/stomp/outbound/StompMessageHandler.java index d48a4d6db5..f5b210ae21 100644 --- a/spring-integration-stomp/src/main/java/org/springframework/integration/stomp/outbound/StompMessageHandler.java +++ b/spring-integration-stomp/src/main/java/org/springframework/integration/stomp/outbound/StompMessageHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2018 the original author or authors. + * Copyright 2015-2019 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. @@ -50,6 +50,7 @@ import org.springframework.util.Assert; * The {@link AbstractMessageHandler} implementation to send messages to STOMP destinations. * * @author Artem Bilan + * @author Gary Russell * * @since 4.2 */ @@ -136,7 +137,7 @@ public class StompMessageHandler extends AbstractMessageHandler implements Appli catch (Exception e) { throw new MessageDeliveryException(message, "The '" + this + "' could not deliver message.", e); } - StompSession stompSession = this.stompSession; + StompSession session = this.stompSession; StompHeaders stompHeaders = new StompHeaders(); this.headerMapper.fromHeaders(message.getHeaders(), stompHeaders); @@ -148,24 +149,24 @@ public class StompMessageHandler extends AbstractMessageHandler implements Appli stompHeaders.setDestination(destination); } - final StompSession.Receiptable receiptable = stompSession.send(stompHeaders, message.getPayload()); + final StompSession.Receiptable receiptable = session.send(stompHeaders, message.getPayload()); if (receiptable.getReceiptId() != null) { final String destination = stompHeaders.getDestination(); - final ApplicationEventPublisher applicationEventPublisher = this.applicationEventPublisher; - if (applicationEventPublisher != null) { + final ApplicationEventPublisher eventPublisher = this.applicationEventPublisher; + if (eventPublisher != null) { receiptable.addReceiptTask(() -> { StompReceiptEvent event = new StompReceiptEvent(StompMessageHandler.this, destination, receiptable.getReceiptId(), StompCommand.SEND, false); event.setMessage(message); - applicationEventPublisher.publishEvent(event); + eventPublisher.publishEvent(event); }); } receiptable.addReceiptLostTask(() -> { - if (applicationEventPublisher != null) { + if (eventPublisher != null) { StompReceiptEvent event = new StompReceiptEvent(StompMessageHandler.this, destination, receiptable.getReceiptId(), StompCommand.SEND, true); event.setMessage(message); - applicationEventPublisher.publishEvent(event); + eventPublisher.publishEvent(event); } else { logger.error("The receipt [" + receiptable.getReceiptId() + "] is lost for [" + diff --git a/spring-integration-syslog/src/main/java/org/springframework/integration/syslog/config/SyslogReceivingChannelAdapterFactoryBean.java b/spring-integration-syslog/src/main/java/org/springframework/integration/syslog/config/SyslogReceivingChannelAdapterFactoryBean.java index 8b2e882d3c..fd4fa913d2 100644 --- a/spring-integration-syslog/src/main/java/org/springframework/integration/syslog/config/SyslogReceivingChannelAdapterFactoryBean.java +++ b/spring-integration-syslog/src/main/java/org/springframework/integration/syslog/config/SyslogReceivingChannelAdapterFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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 SyslogReceivingChannelAdapterFactoryBean extends AbstractFactoryBea udp, tcp } - private volatile SyslogReceivingChannelAdapterSupport adapter; + private volatile SyslogReceivingChannelAdapterSupport syslogAdapter; private final Protocol protocol; @@ -127,22 +127,22 @@ public class SyslogReceivingChannelAdapterFactoryBean extends AbstractFactoryBea @Override public void start() { - if (this.adapter != null) { - this.adapter.start(); + if (this.syslogAdapter != null) { + this.syslogAdapter.start(); } } @Override public void stop() { - if (this.adapter != null) { - this.adapter.stop(); + if (this.syslogAdapter != null) { + this.syslogAdapter.stop(); } } @Override public boolean isRunning() { - if (this.adapter != null) { - return this.adapter.isRunning(); + if (this.syslogAdapter != null) { + return this.syslogAdapter.isRunning(); } return false; } @@ -164,8 +164,8 @@ public class SyslogReceivingChannelAdapterFactoryBean extends AbstractFactoryBea @Override public void stop(Runnable callback) { - if (this.adapter != null) { - this.adapter.stop(callback); + if (this.syslogAdapter != null) { + this.syslogAdapter.stop(callback); } else { callback.run(); @@ -174,9 +174,9 @@ public class SyslogReceivingChannelAdapterFactoryBean extends AbstractFactoryBea @Override public Class getObjectType() { - return this.adapter == null + return this.syslogAdapter == null ? SyslogReceivingChannelAdapterSupport.class - : this.adapter.getClass(); + : this.syslogAdapter.getClass(); } @Override @@ -230,8 +230,8 @@ public class SyslogReceivingChannelAdapterFactoryBean extends AbstractFactoryBea adapter.setBeanFactory(beanFactory); } adapter.afterPropertiesSet(); - this.adapter = adapter; - return this.adapter; + this.syslogAdapter = adapter; + return this.syslogAdapter; } } diff --git a/spring-integration-syslog/src/test/java/org/springframework/integration/syslog/inbound/SyslogReceivingChannelAdapterTests.java b/spring-integration-syslog/src/test/java/org/springframework/integration/syslog/inbound/SyslogReceivingChannelAdapterTests.java index fece360277..c857340544 100644 --- a/spring-integration-syslog/src/test/java/org/springframework/integration/syslog/inbound/SyslogReceivingChannelAdapterTests.java +++ b/spring-integration-syslog/src/test/java/org/springframework/integration/syslog/inbound/SyslogReceivingChannelAdapterTests.java @@ -73,7 +73,7 @@ public class SyslogReceivingChannelAdapterTests { factory.setBeanFactory(mock(BeanFactory.class)); factory.afterPropertiesSet(); factory.start(); - UnicastReceivingChannelAdapter server = TestUtils.getPropertyValue(factory, "adapter.udpAdapter", + UnicastReceivingChannelAdapter server = TestUtils.getPropertyValue(factory, "syslogAdapter.udpAdapter", UnicastReceivingChannelAdapter.class); TestingUtilities.waitListening(server, null); UdpSyslogReceivingChannelAdapter adapter = (UdpSyslogReceivingChannelAdapter) factory.getObject(); @@ -106,7 +106,7 @@ public class SyslogReceivingChannelAdapterTests { factory.setBeanFactory(mock(BeanFactory.class)); factory.afterPropertiesSet(); factory.start(); - AbstractServerConnectionFactory server = TestUtils.getPropertyValue(factory, "adapter.connectionFactory", + AbstractServerConnectionFactory server = TestUtils.getPropertyValue(factory, "syslogAdapter.connectionFactory", AbstractServerConnectionFactory.class); TestingUtilities.waitListening(server, null); TcpSyslogReceivingChannelAdapter adapter = (TcpSyslogReceivingChannelAdapter) factory.getObject(); @@ -144,7 +144,7 @@ public class SyslogReceivingChannelAdapterTests { factory.setBeanFactory(mock(BeanFactory.class)); factory.afterPropertiesSet(); factory.start(); - UnicastReceivingChannelAdapter server = TestUtils.getPropertyValue(factory, "adapter.udpAdapter", + UnicastReceivingChannelAdapter server = TestUtils.getPropertyValue(factory, "syslogAdapter.udpAdapter", UnicastReceivingChannelAdapter.class); TestingUtilities.waitListening(server, null); UdpSyslogReceivingChannelAdapter adapter = (UdpSyslogReceivingChannelAdapter) factory.getObject(); @@ -227,7 +227,7 @@ public class SyslogReceivingChannelAdapterTests { factory.setConverter(new RFC5424MessageConverter()); factory.afterPropertiesSet(); factory.start(); - UnicastReceivingChannelAdapter server = TestUtils.getPropertyValue(factory, "adapter.udpAdapter", + UnicastReceivingChannelAdapter server = TestUtils.getPropertyValue(factory, "syslogAdapter.udpAdapter", UnicastReceivingChannelAdapter.class); TestingUtilities.waitListening(server, null); UdpSyslogReceivingChannelAdapter adapter = (UdpSyslogReceivingChannelAdapter) factory.getObject(); diff --git a/spring-integration-test-support/src/main/java/org/springframework/integration/test/mail/TestMailServer.java b/spring-integration-test-support/src/main/java/org/springframework/integration/test/mail/TestMailServer.java index 0c3cc328fa..849a50cb00 100644 --- a/spring-integration-test-support/src/main/java/org/springframework/integration/test/mail/TestMailServer.java +++ b/spring-integration-test-support/src/main/java/org/springframework/integration/test/mail/TestMailServer.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2018 the original author or authors. + * Copyright 2014-2019 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. @@ -393,7 +393,7 @@ public class TestMailServer { public abstract static class MailServer implements Runnable { - private final ServerSocket socket; + private final ServerSocket serverSocket; private final ExecutorService exec = Executors.newCachedThreadPool(); @@ -404,13 +404,13 @@ public class TestMailServer { private volatile boolean listening; MailServer(int port) throws IOException { - this.socket = ServerSocketFactory.getDefault().createServerSocket(port); + this.serverSocket = ServerSocketFactory.getDefault().createServerSocket(port); this.listening = true; exec.execute(this); } public int getPort() { - return this.socket.getLocalPort(); + return this.serverSocket.getLocalPort(); } public boolean isListening() { @@ -432,8 +432,8 @@ public class TestMailServer { @Override public void run() { try { - while (!socket.isClosed()) { - Socket socket = this.socket.accept(); + while (!serverSocket.isClosed()) { + Socket socket = this.serverSocket.accept(); exec.execute(mailHandler(socket)); } } @@ -446,7 +446,7 @@ public class TestMailServer { public void stop() { try { - this.socket.close(); + this.serverSocket.close(); } catch (IOException e) { e.printStackTrace(); diff --git a/spring-integration-test-support/src/main/java/org/springframework/integration/test/matcher/PayloadAndHeaderMatcher.java b/spring-integration-test-support/src/main/java/org/springframework/integration/test/matcher/PayloadAndHeaderMatcher.java index fefe830de0..5abc528984 100644 --- a/spring-integration-test-support/src/main/java/org/springframework/integration/test/matcher/PayloadAndHeaderMatcher.java +++ b/spring-integration-test-support/src/main/java/org/springframework/integration/test/matcher/PayloadAndHeaderMatcher.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 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,6 +47,7 @@ import org.springframework.messaging.MessageHeaders; * * @author Dave Syer * @author Artem Bilan + * @author Gary Russell * */ public class PayloadAndHeaderMatcher extends BaseMatcher> { @@ -69,23 +70,25 @@ public class PayloadAndHeaderMatcher extends BaseMatcher> { } private Map extractHeadersToAssert(Message operand) { - HashMap headers = new HashMap<>(operand.getHeaders()); - headers.remove(MessageHeaders.ID); - headers.remove(MessageHeaders.TIMESTAMP); + HashMap headersToAssert = new HashMap<>(operand.getHeaders()); + headersToAssert.remove(MessageHeaders.ID); + headersToAssert.remove(MessageHeaders.TIMESTAMP); if (this.ignoreKeys != null) { for (String key : this.ignoreKeys) { - headers.remove(key); + headersToAssert.remove(key); } } - return headers; + return headersToAssert; } + @Override public boolean matches(Object arg) { Message input = (Message) arg; Map inputHeaders = extractHeadersToAssert(input); return input.getPayload().equals(this.payload) && inputHeaders.equals(this.headers); } + @Override public void describeTo(Description description) { description.appendText("a Message with Headers that match except ID and timestamp for payload: ") .appendValue(this.payload) diff --git a/spring-integration-ws/src/main/java/org/springframework/integration/ws/AbstractWebServiceOutboundGateway.java b/spring-integration-ws/src/main/java/org/springframework/integration/ws/AbstractWebServiceOutboundGateway.java index cb3b0d4a4e..cec88f4972 100644 --- a/spring-integration-ws/src/main/java/org/springframework/integration/ws/AbstractWebServiceOutboundGateway.java +++ b/spring-integration-ws/src/main/java/org/springframework/integration/ws/AbstractWebServiceOutboundGateway.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 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. @@ -196,18 +196,18 @@ public abstract class AbstractWebServiceOutboundGateway extends AbstractReplyPro @Override public final Object handleRequestMessage(Message requestMessage) { - URI uri = null; + URI uriWithVariables = null; try { - uri = this.prepareUri(requestMessage); + uriWithVariables = this.prepareUri(requestMessage); } catch (URISyntaxException e) { throw new IllegalArgumentException(e); } - if (uri == null) { + if (uriWithVariables == null) { throw new MessageDeliveryException(requestMessage, "Failed to determine URI for " + "Web Service request in outbound gateway: " + this.getComponentName()); } - Object responsePayload = this.doHandle(uri.toString(), requestMessage, this.requestCallback); + Object responsePayload = this.doHandle(uriWithVariables.toString(), requestMessage, this.requestCallback); if (responsePayload != null) { boolean shouldIgnore = (this.ignoreEmptyResponses && responsePayload instanceof String && !StringUtils.hasText((String) responsePayload)); diff --git a/spring-integration-xml/src/main/java/org/springframework/integration/xml/transformer/AbstractXmlTransformer.java b/spring-integration-xml/src/main/java/org/springframework/integration/xml/transformer/AbstractXmlTransformer.java index 24659e2daa..e4d7353fcc 100644 --- a/spring-integration-xml/src/main/java/org/springframework/integration/xml/transformer/AbstractXmlTransformer.java +++ b/spring-integration-xml/src/main/java/org/springframework/integration/xml/transformer/AbstractXmlTransformer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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. @@ -31,6 +31,7 @@ import org.springframework.util.StringUtils; * @author Mark Fisher * @author Artem Bilan * @author Liujiong + * @author Gary Russell */ public abstract class AbstractXmlTransformer extends AbstractTransformer { @@ -85,22 +86,22 @@ public abstract class AbstractXmlTransformer extends AbstractTransformer { */ private ResultFactory configureResultFactory(String resultType, String resultFactoryName, BeanFactory beanFactory) { boolean bothHaveText = StringUtils.hasText(resultFactoryName) && StringUtils.hasText(resultType); - ResultFactory resultFactory = null; + ResultFactory configuredResultFactory = null; Assert.state(!bothHaveText, "Only one of 'result-factory' or 'result-type' should be specified."); if (StringUtils.hasText(resultType)) { Assert.state(resultType.equals(DOM_RESULT) || resultType.equals(STRING_RESULT), "Result type must be either 'DOMResult' or 'StringResult'"); } if (StringUtils.hasText(resultFactoryName)) { - resultFactory = (ResultFactory) beanFactory.getBean(resultFactoryName); + configuredResultFactory = (ResultFactory) beanFactory.getBean(resultFactoryName); } else if (STRING_RESULT.equals(resultType)) { - resultFactory = new StringResultFactory(); + configuredResultFactory = new StringResultFactory(); } else if (DOM_RESULT.equals(resultType)) { - resultFactory = new DomResultFactory(); + configuredResultFactory = new DomResultFactory(); } - return resultFactory; + return configuredResultFactory; } } diff --git a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/config/XmppConnectionFactoryBean.java b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/config/XmppConnectionFactoryBean.java index 96247d995d..613ac21ccb 100644 --- a/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/config/XmppConnectionFactoryBean.java +++ b/spring-integration-xmpp/src/main/java/org/springframework/integration/xmpp/config/XmppConnectionFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 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.util.StringUtils; * @author Florian Schmaus * @author Artem Bilan * @author Philipp Etschel + * @author Gary Russell * * @since 2.0 * @@ -69,8 +70,6 @@ public class XmppConnectionFactoryBean extends AbstractFactoryBean extensions = xmppMessage.getExtensions(); if (extensions.size() == 1) { ExtensionElement extension = extensions.get(0); - evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory()); - evaluationContext.setVariable("extension", extension); + evaluationContextToUse = ExpressionUtils.createStandardEvaluationContext(getBeanFactory()); + evaluationContextToUse.setVariable("extension", extension); } messageBody = ChatMessageListeningEndpoint.this.payloadExpression - .getValue(evaluationContext, xmppMessage); + .getValue(evaluationContextToUse, xmppMessage); } if (messageBody != null) {