Sonar fixes

- remaining hidden fields

* Fix copyright
This commit is contained in:
Gary Russell
2019-01-09 13:30:08 -05:00
committed by Artem Bilan
parent e30741f7eb
commit 2766707547
28 changed files with 280 additions and 272 deletions

View File

@@ -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<MessageChannel> channels) {
Assert.notEmpty(channels, "'channels' must not be empty");
List<Recipient> 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;

View File

@@ -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<Message<?>> 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<Message<?>> messages = getMessages();
if (!messages.isEmpty()) {
@@ -175,7 +175,7 @@ public class MessageGroupQueue extends AbstractQueue<Message<?>> implements Bloc
}
}
finally {
storeLock.unlock();
lock.unlock();
}
}
catch (InterruptedException e) {
@@ -188,8 +188,8 @@ public class MessageGroupQueue extends AbstractQueue<Message<?>> 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<Message<?>> implements Bloc
}
}
finally {
storeLock.unlock();
lock.unlock();
}
return message;
}
@@ -207,14 +207,14 @@ public class MessageGroupQueue extends AbstractQueue<Message<?>> 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<Message<?>> implements Bloc
Assert.notNull(collection, "'collection' must not be null");
int originalSize = collection.size();
ArrayList<Message<?>> 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<Message<?>> implements Bloc
this.messageStoreNotFull.signal();
}
finally {
storeLock.unlock();
lock.unlock();
}
}
catch (InterruptedException e) {
@@ -259,14 +259,14 @@ public class MessageGroupQueue extends AbstractQueue<Message<?>> 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<Message<?>> 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<Message<?>> 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<Message<?>> implements Bloc
this.doOffer(message);
}
finally {
storeLock.unlock();
lock.unlock();
}
}
@@ -326,8 +326,8 @@ public class MessageGroupQueue extends AbstractQueue<Message<?>> 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<Message<?>> implements Bloc
}
finally {
storeLock.unlock();
lock.unlock();
}
return message;
}

View File

@@ -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);
}
}

View File

@@ -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<Abstrac
* @param lifecycle the {@link SmartLifecycle}.
*/
public final void addLifecycleToRole(String role, SmartLifecycle lifecycle) {
List<SmartLifecycle> lifecycles = this.lifecycles.get(role);
if (CollectionUtils.isEmpty(lifecycles)) {
List<SmartLifecycle> 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<Abstrac
+ "' is already present.");
});
lifecycles.add(lifecycle);
componentsInRole.add(lifecycle);
}
}
@@ -157,15 +157,15 @@ public class SmartLifecycleRoleController implements ApplicationListener<Abstrac
if (this.lazyLifecycles.size() > 0) {
addLazyLifecycles();
}
List<SmartLifecycle> lifecycles = this.lifecycles.get(role);
if (lifecycles != null) {
lifecycles = new ArrayList<>(lifecycles);
lifecycles.sort(Comparator.comparingInt(Phased::getPhase));
List<SmartLifecycle> 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<Abstrac
if (this.lazyLifecycles.size() > 0) {
addLazyLifecycles();
}
List<SmartLifecycle> lifecycles = this.lifecycles.get(role);
if (lifecycles != null) {
lifecycles = new ArrayList<>(lifecycles);
lifecycles.sort((o1, o2) -> Integer.compare(o2.getPhase(), o1.getPhase()));
List<SmartLifecycle> 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<Abstrac
public boolean removeLifecycle(SmartLifecycle lifecycle) {
boolean removed = false;
for (List<SmartLifecycle> lifecycles : this.lifecycles.values()) {
boolean actualRemoved = lifecycles.removeIf(Predicate.isEqual(lifecycle));
if (!removed) {
removed = actualRemoved;
for (List<SmartLifecycle> componentsInRole : this.lifecycles.values()) {
removed = componentsInRole.removeIf(Predicate.isEqual(lifecycle));
if (removed) {
break;
}
}

View File

@@ -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

View File

@@ -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<Double> copy;
long count;
long currentCount;
synchronized (this) {
copy = new ArrayList<Double>(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
}
/**

View File

@@ -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<Long> copy;
long count;
long currentCount;
synchronized (this) {
copy = new ArrayList<Long>(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;
}
/**

View File

@@ -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<Long> copyTimes;
List<Integer> copyValues;
long count;
long currentCount;
synchronized (this) {
copyTimes = new ArrayList<Long>(this.times);
copyValues = new ArrayList<Integer>(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<Integer> values = copyValues.iterator();
Iterator<Integer> 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());
}

View File

@@ -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<String, Object> 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;

View File

@@ -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<List<Object>, Integer> processMessage(Message<?> message) {
// use a local variable to avoid the second access to volatile field on the happy path
Map<List<Object>, Integer> routingSlip = this.routingSlip;
if (routingSlip == null) {
Map<List<Object>, Integer> slip = this.routingSlip;
if (slip == null) {
synchronized (this) {
routingSlip = this.routingSlip;
if (routingSlip == null) {
List<Object> routingSlipPath = this.routingSlipPath;
List<Object> routingSlipValues = new ArrayList<Object>(routingSlipPath.size());
for (Object path : routingSlipPath) {
slip = this.routingSlip;
if (slip == null) {
List<Object> slipPath = this.routingSlipPath;
List<Object> routingSlipValues = new ArrayList<Object>(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;
}
}

View File

@@ -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) {

View File

@@ -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();

View File

@@ -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<MailReceiver>, 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<MailReceiver>, 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

View File

@@ -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);
}

View File

@@ -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
}
}

View File

@@ -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<Object> arguments = new ArrayList<Object>();
for (Expression argumentExpression : this.argumentExpressions) {
Object argument = argumentExpression.getValue(evaluationContext, message);
Object argument = argumentExpression.getValue(evaluationContextToUse, message);
if (argument != null) {
arguments.add(argument);
}

View File

@@ -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<LsEntry>, 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);

View File

@@ -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);
}
}

View File

@@ -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 [" +

View File

@@ -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 [" +

View File

@@ -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;
}
}

View File

@@ -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();

View File

@@ -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();

View File

@@ -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<T> extends BaseMatcher<Message<?>> {
@@ -69,23 +70,25 @@ public class PayloadAndHeaderMatcher<T> extends BaseMatcher<Message<?>> {
}
private Map<String, Object> extractHeadersToAssert(Message<?> operand) {
HashMap<String, Object> headers = new HashMap<>(operand.getHeaders());
headers.remove(MessageHeaders.ID);
headers.remove(MessageHeaders.TIMESTAMP);
HashMap<String, Object> 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<String, Object> 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)

View File

@@ -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));

View File

@@ -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;
}
}

View File

@@ -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<XMPPConnectio
private volatile boolean running;
private volatile XMPPTCPConnection connection;
public XmppConnectionFactoryBean() {
}
@@ -136,8 +135,8 @@ public class XmppConnectionFactoryBean extends AbstractFactoryBean<XMPPConnectio
@Override
protected XMPPConnection createInstance() throws Exception {
XMPPTCPConnectionConfiguration connectionConfiguration = this.connectionConfiguration;
if (this.connectionConfiguration == null) {
XMPPTCPConnectionConfiguration connectionConfig = this.connectionConfiguration;
if (connectionConfig == null) {
XMPPTCPConnectionConfiguration.Builder builder =
XMPPTCPConnectionConfiguration.builder()
.setHost(this.host)
@@ -156,9 +155,9 @@ public class XmppConnectionFactoryBean extends AbstractFactoryBean<XMPPConnectio
.setXmppDomain(this.user);
}
connectionConfiguration = builder.build();
connectionConfig = builder.build();
}
return new XMPPTCPConnection(connectionConfiguration);
return new XMPPTCPConnection(connectionConfig);
}
protected XMPPTCPConnection getConnection() {

View File

@@ -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.
@@ -41,6 +41,7 @@ import org.springframework.util.Assert;
* @author Mark Fisher
* @author Oleg Zhurakousky
* @author Artem Bilan
* @author Gary Russell
*
* @since 2.0
*/
@@ -130,17 +131,17 @@ public class ChatMessageListeningEndpoint extends AbstractXmppConnectionAwareEnd
Object messageBody = xmppMessage.getBody();
if (ChatMessageListeningEndpoint.this.payloadExpression != null) {
EvaluationContext evaluationContext = ChatMessageListeningEndpoint.this.evaluationContext;
EvaluationContext evaluationContextToUse = ChatMessageListeningEndpoint.this.evaluationContext;
List<ExtensionElement> 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) {