Fix Checkstyle violations
* Add `validateOnlyOverlapping = false` for `RequireThis` Checkstyle rule * Add `this.` to caught places * Use `CustomizableThreadFactory` instead of raw interface in the `UnicastSendingMessageHandler`
This commit is contained in:
@@ -333,14 +333,14 @@ public abstract class AbstractAmqpOutboundEndpoint extends AbstractReplyProducin
|
||||
|
||||
protected MessageChannel getConfirmAckChannel() {
|
||||
if (this.confirmAckChannel == null && this.confirmAckChannelName != null) {
|
||||
this.confirmAckChannel = getChannelResolver().resolveDestination(confirmAckChannelName);
|
||||
this.confirmAckChannel = getChannelResolver().resolveDestination(this.confirmAckChannelName);
|
||||
}
|
||||
return this.confirmAckChannel;
|
||||
}
|
||||
|
||||
protected MessageChannel getConfirmNackChannel() {
|
||||
if (this.confirmNackChannel == null && this.confirmNackChannelName != null) {
|
||||
this.confirmNackChannel = getChannelResolver().resolveDestination(confirmNackChannelName);
|
||||
this.confirmNackChannel = getChannelResolver().resolveDestination(this.confirmNackChannelName);
|
||||
}
|
||||
return this.confirmNackChannel;
|
||||
}
|
||||
|
||||
@@ -106,9 +106,6 @@ public class PublisherAnnotationBeanPostProcessor extends ProxyConfig
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
Class<?> targetClass = AopUtils.getTargetClass(bean);
|
||||
if (targetClass == null) {
|
||||
return bean;
|
||||
}
|
||||
|
||||
// the set will hold records of prior class scans and will contain the bean classes that can not
|
||||
// be assigned to the Advisor interface and therefore can be short circuited
|
||||
@@ -131,7 +128,7 @@ public class PublisherAnnotationBeanPostProcessor extends ProxyConfig
|
||||
}
|
||||
else {
|
||||
// cannot apply advisor
|
||||
nonApplicableCache.add(targetClass);
|
||||
this.nonApplicableCache.add(targetClass);
|
||||
return bean;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ public class MessagingAnnotationPostProcessor implements BeanPostProcessor, Bean
|
||||
ReflectionUtils.doWithMethods(beanClass, method -> {
|
||||
Map<Class<? extends Annotation>, List<Annotation>> annotationChains = new HashMap<>();
|
||||
for (Class<? extends Annotation> annotationType :
|
||||
MessagingAnnotationPostProcessor.this.postProcessors.keySet()) {
|
||||
this.postProcessors.keySet()) {
|
||||
if (AnnotatedElementUtils.isAnnotated(method, annotationType.getName())) {
|
||||
List<Annotation> annotationChain = getAnnotationChain(method, annotationType);
|
||||
if (annotationChain.size() > 0) {
|
||||
@@ -179,7 +179,7 @@ public class MessagingAnnotationPostProcessor implements BeanPostProcessor, Bean
|
||||
}
|
||||
|
||||
if (annotationChains.size() == 0) {
|
||||
noAnnotationsCache.add(beanClass);
|
||||
this.noAnnotationsCache.add(beanClass);
|
||||
}
|
||||
}, ReflectionUtils.USER_DECLARED_METHODS);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,6 +31,8 @@ import org.springframework.messaging.MessageHandler;
|
||||
* @author Iwein Fuld
|
||||
* @author Mark Fisher
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 1.0.3
|
||||
*/
|
||||
public class RoundRobinLoadBalancingStrategy implements LoadBalancingStrategy {
|
||||
@@ -43,7 +45,7 @@ public class RoundRobinLoadBalancingStrategy implements LoadBalancingStrategy {
|
||||
* iteration, so it guarantees all handlers are returned once on subsequent
|
||||
* <code>next()</code> invocations.
|
||||
*/
|
||||
public final Iterator<MessageHandler> getHandlerIterator(final Message<?> message, final Collection<MessageHandler> handlers) {
|
||||
public final Iterator<MessageHandler> getHandlerIterator(Message<?> message, Collection<MessageHandler> handlers) {
|
||||
int size = handlers.size();
|
||||
if (size < 2) {
|
||||
this.getNextHandlerStartIndex(size);
|
||||
@@ -54,28 +56,29 @@ public class RoundRobinLoadBalancingStrategy implements LoadBalancingStrategy {
|
||||
}
|
||||
|
||||
private Iterator<MessageHandler> buildHandlerIterator(int size, final MessageHandler[] handlers) {
|
||||
|
||||
int nextHandlerStartIndex = getNextHandlerStartIndex(size);
|
||||
|
||||
final MessageHandler[] reorderedHandlers = new MessageHandler[size];
|
||||
MessageHandler[] reorderedHandlers = new MessageHandler[size];
|
||||
|
||||
System.arraycopy(handlers, nextHandlerStartIndex, reorderedHandlers, 0, size - nextHandlerStartIndex);
|
||||
System.arraycopy(handlers, 0, reorderedHandlers, size - nextHandlerStartIndex, 0 + nextHandlerStartIndex);
|
||||
System.arraycopy(handlers, 0, reorderedHandlers, size - nextHandlerStartIndex, nextHandlerStartIndex);
|
||||
|
||||
return new Iterator<MessageHandler>() {
|
||||
|
||||
int currentIndex = 0;
|
||||
|
||||
public boolean hasNext() {
|
||||
return currentIndex < reorderedHandlers.length;
|
||||
return this.currentIndex < reorderedHandlers.length;
|
||||
}
|
||||
|
||||
public MessageHandler next() {
|
||||
return reorderedHandlers[currentIndex++];
|
||||
return reorderedHandlers[this.currentIndex++];
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException("Remove is not supported by this Iterator");
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -93,4 +96,5 @@ public class RoundRobinLoadBalancingStrategy implements LoadBalancingStrategy {
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ public class FileSplitter extends AbstractMessageSplitter {
|
||||
|
||||
boolean markers = FileSplitter.this.markers;
|
||||
|
||||
boolean sof = markers;
|
||||
boolean sof = this.markers;
|
||||
|
||||
boolean eof;
|
||||
|
||||
|
||||
@@ -31,9 +31,7 @@ import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.springframework.expression.EvaluationContext;
|
||||
import org.springframework.expression.Expression;
|
||||
@@ -43,6 +41,7 @@ import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
import org.springframework.messaging.MessageHandlingException;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -57,6 +56,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Gary Russell
|
||||
* @author Marcin Pilaczynski
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public class UnicastSendingMessageHandler extends
|
||||
@@ -231,21 +231,11 @@ public class UnicastSendingMessageHandler extends
|
||||
public void doStart() {
|
||||
if (this.acknowledge) {
|
||||
if (this.taskExecutor == null) {
|
||||
Executor executor = Executors
|
||||
.newSingleThreadExecutor(new ThreadFactory() {
|
||||
|
||||
private final AtomicInteger n = new AtomicInteger();
|
||||
CustomizableThreadFactory threadFactory = new CustomizableThreadFactory("UDP-Ack-Handler-");
|
||||
threadFactory.setDaemon(true);
|
||||
|
||||
@Override
|
||||
public Thread newThread(Runnable runner) {
|
||||
Thread thread = new Thread(runner);
|
||||
thread.setName("UDP-Ack-Handler-" + n.getAndIncrement());
|
||||
thread.setDaemon(true);
|
||||
return thread;
|
||||
}
|
||||
|
||||
});
|
||||
this.taskExecutor = executor;
|
||||
this.taskExecutor = Executors.newSingleThreadExecutor(threadFactory);
|
||||
}
|
||||
startAckThread();
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
</module>
|
||||
<module name="MultipleVariableDeclarations" />
|
||||
<module name="RequireThis">
|
||||
<property name="validateOnlyOverlapping" value="false" />
|
||||
<property name="checkMethods" value="false" />
|
||||
</module>
|
||||
<module name="OneStatementPerLine" />
|
||||
|
||||
Reference in New Issue
Block a user