Fix some Sonar smells
This commit is contained in:
@@ -141,7 +141,6 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageP
|
||||
|
||||
private long expireTimeout;
|
||||
|
||||
@Nullable
|
||||
private Duration expireDuration;
|
||||
|
||||
private MessageGroupProcessor forceReleaseProcessor = new ForceReleaseMessageGroupProcessor();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,15 +40,15 @@ import org.springframework.util.Assert;
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
* @author Diego Belfer
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public abstract class AbstractDispatcher implements MessageDispatcher {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass()); // NOSONAR final
|
||||
|
||||
private volatile int maxSubscribers = Integer.MAX_VALUE;
|
||||
private final OrderedAwareCopyOnWriteArraySet<MessageHandler> handlers = new OrderedAwareCopyOnWriteArraySet<>();
|
||||
|
||||
private final OrderedAwareCopyOnWriteArraySet<MessageHandler> handlers =
|
||||
new OrderedAwareCopyOnWriteArraySet<MessageHandler>();
|
||||
private volatile int maxSubscribers = Integer.MAX_VALUE;
|
||||
|
||||
private volatile MessageHandler theOneHandler;
|
||||
|
||||
@@ -125,7 +125,7 @@ public abstract class AbstractDispatcher implements MessageDispatcher {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getClass().getSimpleName() + " with handlers: " + this.handlers.toString();
|
||||
return getClass().getSimpleName() + " with handlers: " + this.handlers.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,16 +35,16 @@ import org.springframework.messaging.support.MessageHandlingRunnable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A broadcasting dispatcher implementation. If the 'ignoreFailures' property is set to <code>false</code> (the
|
||||
* A broadcasting dispatcher implementation. If the 'ignoreFailures' property is set to false (the
|
||||
* default), it will fail fast such that any Exception thrown by a MessageHandler may prevent subsequent handlers from
|
||||
* receiving the Message. However, when an Executor is provided, the Messages may be dispatched in separate Threads so
|
||||
* that other handlers are invoked even when the 'ignoreFailures' flag is <code>false</code>.
|
||||
* that other handlers are invoked even when the 'ignoreFailures' flag is false.
|
||||
* <p>
|
||||
* If the 'ignoreFailures' flag is set to <code>true</code> on the other hand, it will make a best effort to send the
|
||||
* message to each of its handlers. In other words, when 'ignoreFailures' is <code>true</code>, if it fails to send to
|
||||
* If the 'ignoreFailures' flag is set to true on the other hand, it will make a best effort to send the
|
||||
* message to each of its handlers. In other words, when 'ignoreFailures' is true, if it fails to send to
|
||||
* any one handler, it will simply log a warn-level message but continue to send the Message to any other handlers.
|
||||
* <p>
|
||||
* If the 'requireSubscribers' flag is set to <code>true</code>, the sent message is considered as non-dispatched
|
||||
* If the 'requireSubscribers' flag is set to true, the sent message is considered as non-dispatched
|
||||
* and rejected to the caller with the {@code "Dispatcher has no subscribers"} {@link MessageDispatchingException}.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
@@ -92,15 +92,14 @@ public class BroadcastingDispatcher extends AbstractDispatcher implements BeanFa
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify whether failures for one or more of the handlers should be ignored. By default this is <code>false</code>
|
||||
* Specify whether failures for one or more of the handlers should be ignored. By default this is false
|
||||
* meaning that an Exception will be thrown when a handler fails. To override this and suppress Exceptions, set the
|
||||
* value to <code>true</code>.
|
||||
* value to true.
|
||||
* <p>
|
||||
* Keep in mind that when using an Executor, even without ignoring the failures, other handlers may be invoked after
|
||||
* one throws an Exception. Since the Executor is most likely using a different thread, this flag would only affect
|
||||
* whether an error Message is sent to the error channel or not in the case that such an Executor has been
|
||||
* configured.
|
||||
*
|
||||
* @param ignoreFailures true when failures are to be ignored.
|
||||
*/
|
||||
public void setIgnoreFailures(boolean ignoreFailures) {
|
||||
@@ -108,9 +107,8 @@ public class BroadcastingDispatcher extends AbstractDispatcher implements BeanFa
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify whether to apply sequence numbers to the messages prior to sending to the handlers. By default, sequence
|
||||
* numbers will <em>not</em> be applied.
|
||||
*
|
||||
* Specify whether to apply sequence numbers to the messages prior to sending to the handlers.
|
||||
* By default, sequence numbers will not be applied.
|
||||
* @param applySequence true when sequence information should be applied.
|
||||
*/
|
||||
public void setApplySequence(boolean applySequence) {
|
||||
@@ -226,9 +224,7 @@ public class BroadcastingDispatcher extends AbstractDispatcher implements BeanFa
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
if (!this.ignoreFailures) {
|
||||
if (e instanceof MessagingException
|
||||
&& ((MessagingException) e).getFailedMessage() == null) { // NOSONAR
|
||||
|
||||
if (e instanceof MessagingException && ((MessagingException) e).getFailedMessage() == null) { // NOSONAR
|
||||
throw new MessagingException(message, "Failed to handle Message", e);
|
||||
}
|
||||
throw e;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -35,7 +35,7 @@ import org.springframework.integration.scripting.config.ScriptExecutingProcessor
|
||||
*/
|
||||
public class GroovyIntegrationConfigurationInitializer implements IntegrationConfigurationInitializer {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(GroovyIntegrationConfigurationInitializer.class);
|
||||
private static final Log LOGGER = LogFactory.getLog(GroovyIntegrationConfigurationInitializer.class);
|
||||
|
||||
@Override
|
||||
public void initialize(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
@@ -43,7 +43,7 @@ public class GroovyIntegrationConfigurationInitializer implements IntegrationCon
|
||||
registerScriptExecutorProviderIfNecessary((BeanDefinitionRegistry) beanFactory);
|
||||
}
|
||||
else {
|
||||
logger.warn("The 'ScriptExecutingProcessorFactory' isn't registered because 'beanFactory'" +
|
||||
LOGGER.warn("The 'ScriptExecutingProcessorFactory' isn't registered because 'beanFactory'" +
|
||||
" isn't an instance of `BeanDefinitionRegistry`.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -29,7 +29,7 @@ import org.springframework.core.type.AnnotationMetadata;
|
||||
*/
|
||||
class IntegrationGraphControllerRegistrarImportSelector implements ImportSelector {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(IntegrationGraphControllerRegistrarImportSelector.class);
|
||||
private static final Log LOGGER = LogFactory.getLog(IntegrationGraphControllerRegistrarImportSelector.class);
|
||||
|
||||
@Override
|
||||
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
|
||||
@@ -37,7 +37,7 @@ class IntegrationGraphControllerRegistrarImportSelector implements ImportSelecto
|
||||
return new String[] { IntegrationGraphControllerRegistrar.class.getName() };
|
||||
}
|
||||
else {
|
||||
logger.warn("The 'IntegrationGraphController' isn't registered with the application context because" +
|
||||
LOGGER.warn("The 'IntegrationGraphController' isn't registered with the application context because" +
|
||||
" there is no 'org.springframework.web.servlet.DispatcherServlet' or" +
|
||||
" 'org.springframework.web.reactive.DispatcherHandler' in the classpath.");
|
||||
return new String[0];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -25,23 +25,25 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* {@link MultipartFileReader} implementation that copies the MulitpartFile's
|
||||
* {@link MultipartFileReader} implementation that copies the MultipartFile's
|
||||
* content to a new temporary File in the specified directory. If no directory
|
||||
* is provided, the Files will be created in the default temporary directory.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Artyem Bilan
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public class FileCopyingMultipartFileReader implements MultipartFileReader<MultipartFile> {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(FileCopyingMultipartFileReader.class);
|
||||
private static final Log LOGGER = LogFactory.getLog(FileCopyingMultipartFileReader.class);
|
||||
|
||||
|
||||
private final File directory;
|
||||
|
||||
private volatile String prefix = "si_";
|
||||
private String prefix = "si_";
|
||||
|
||||
private volatile String suffix = ".tmp";
|
||||
private String suffix = ".tmp";
|
||||
|
||||
|
||||
/**
|
||||
@@ -55,7 +57,6 @@ public class FileCopyingMultipartFileReader implements MultipartFileReader<Multi
|
||||
/**
|
||||
* Create a {@link FileCopyingMultipartFileReader} that creates temporary
|
||||
* Files in the given directory.
|
||||
*
|
||||
* @param directory The directory.
|
||||
*/
|
||||
public FileCopyingMultipartFileReader(File directory) {
|
||||
@@ -65,7 +66,6 @@ public class FileCopyingMultipartFileReader implements MultipartFileReader<Multi
|
||||
|
||||
/**
|
||||
* Specify the prefix to use for temporary files.
|
||||
*
|
||||
* @param prefix The prefix.
|
||||
*/
|
||||
public void setPrefix(String prefix) {
|
||||
@@ -74,7 +74,6 @@ public class FileCopyingMultipartFileReader implements MultipartFileReader<Multi
|
||||
|
||||
/**
|
||||
* Specify the suffix to use for temporary files.
|
||||
*
|
||||
* @param suffix The suffix.
|
||||
*/
|
||||
public void setSuffix(String suffix) {
|
||||
@@ -87,8 +86,8 @@ public class FileCopyingMultipartFileReader implements MultipartFileReader<Multi
|
||||
multipartFile.transferTo(upload);
|
||||
UploadedMultipartFile uploadedMultipartFile = new UploadedMultipartFile(upload, multipartFile.getSize(),
|
||||
multipartFile.getContentType(), multipartFile.getName(), multipartFile.getOriginalFilename());
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("copied uploaded file [" + multipartFile.getOriginalFilename() +
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("copied uploaded file [" + multipartFile.getOriginalFilename() +
|
||||
"] to [" + upload.getAbsolutePath() + "]");
|
||||
}
|
||||
return uploadedMultipartFile;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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 Gary Russell
|
||||
* @author Marcin Pilaczynski
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public class UdpOutboundChannelAdapterParser extends AbstractOutboundChannelAdapterParser {
|
||||
@@ -63,20 +64,21 @@ public class UdpOutboundChannelAdapterParser extends AbstractOutboundChannelAdap
|
||||
IpAdapterParserUtils.addConstructorValueIfAttributeDefined(builder, element, IpAdapterParserUtils.ACK_PORT);
|
||||
IpAdapterParserUtils.addConstructorValueIfAttributeDefined(builder, element, IpAdapterParserUtils.ACK_TIMEOUT);
|
||||
String ack = element.getAttribute(IpAdapterParserUtils.ACK);
|
||||
if (ack.equals("true")) {
|
||||
if (!StringUtils.hasText(element
|
||||
.getAttribute(IpAdapterParserUtils.ACK_HOST))
|
||||
|| !StringUtils.hasText(element
|
||||
.getAttribute(IpAdapterParserUtils.ACK_PORT))
|
||||
|| !StringUtils.hasText(element
|
||||
.getAttribute(IpAdapterParserUtils.ACK_TIMEOUT))) {
|
||||
parserContext.getReaderContext().error("When "
|
||||
+ IpAdapterParserUtils.ACK + " is true, "
|
||||
+ IpAdapterParserUtils.ACK_HOST + ", "
|
||||
+ IpAdapterParserUtils.ACK_PORT + ", and "
|
||||
+ IpAdapterParserUtils.ACK_TIMEOUT
|
||||
+ " must be supplied", element);
|
||||
}
|
||||
if (ack.equals("true") &&
|
||||
(!StringUtils.hasText(element
|
||||
.getAttribute(IpAdapterParserUtils.ACK_HOST))
|
||||
|| !StringUtils.hasText(element
|
||||
.getAttribute(IpAdapterParserUtils.ACK_PORT))
|
||||
|| !StringUtils.hasText(element
|
||||
.getAttribute(IpAdapterParserUtils.ACK_TIMEOUT)))) {
|
||||
|
||||
parserContext.getReaderContext()
|
||||
.error("When "
|
||||
+ IpAdapterParserUtils.ACK + " is true, "
|
||||
+ IpAdapterParserUtils.ACK_HOST + ", "
|
||||
+ IpAdapterParserUtils.ACK_PORT + ", and "
|
||||
+ IpAdapterParserUtils.ACK_TIMEOUT
|
||||
+ " must be supplied", element);
|
||||
}
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element,
|
||||
IpAdapterParserUtils.RECEIVE_BUFFER_SIZE);
|
||||
|
||||
Reference in New Issue
Block a user