Skip to content

Commit 5be0ed1

Browse files
committed
Fix some Sonar smells
1 parent c278d91 commit 5be0ed1

File tree

7 files changed

+47
-51
lines changed

7 files changed

+47
-51
lines changed

spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractCorrelatingMessageHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageP
141141

142142
private long expireTimeout;
143143

144-
@Nullable
145144
private Duration expireDuration;
146145

147146
private MessageGroupProcessor forceReleaseProcessor = new ForceReleaseMessageGroupProcessor();

spring-integration-core/src/main/java/org/springframework/integration/dispatcher/AbstractDispatcher.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,15 +40,15 @@
4040
* @author Oleg Zhurakousky
4141
* @author Gary Russell
4242
* @author Diego Belfer
43+
* @author Artem Bilan
4344
*/
4445
public abstract class AbstractDispatcher implements MessageDispatcher {
4546

4647
protected final Log logger = LogFactory.getLog(getClass()); // NOSONAR final
4748

48-
private volatile int maxSubscribers = Integer.MAX_VALUE;
49+
private final OrderedAwareCopyOnWriteArraySet<MessageHandler> handlers = new OrderedAwareCopyOnWriteArraySet<>();
4950

50-
private final OrderedAwareCopyOnWriteArraySet<MessageHandler> handlers =
51-
new OrderedAwareCopyOnWriteArraySet<MessageHandler>();
51+
private volatile int maxSubscribers = Integer.MAX_VALUE;
5252

5353
private volatile MessageHandler theOneHandler;
5454

@@ -125,7 +125,7 @@ protected boolean tryOptimizedDispatch(Message<?> message) {
125125

126126
@Override
127127
public String toString() {
128-
return this.getClass().getSimpleName() + " with handlers: " + this.handlers.toString();
128+
return getClass().getSimpleName() + " with handlers: " + this.handlers.toString();
129129
}
130130

131131
@Override

spring-integration-core/src/main/java/org/springframework/integration/dispatcher/BroadcastingDispatcher.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@
3535
import org.springframework.util.Assert;
3636

3737
/**
38-
* A broadcasting dispatcher implementation. If the 'ignoreFailures' property is set to <code>false</code> (the
38+
* A broadcasting dispatcher implementation. If the 'ignoreFailures' property is set to false (the
3939
* default), it will fail fast such that any Exception thrown by a MessageHandler may prevent subsequent handlers from
4040
* receiving the Message. However, when an Executor is provided, the Messages may be dispatched in separate Threads so
41-
* that other handlers are invoked even when the 'ignoreFailures' flag is <code>false</code>.
41+
* that other handlers are invoked even when the 'ignoreFailures' flag is false.
4242
* <p>
43-
* If the 'ignoreFailures' flag is set to <code>true</code> on the other hand, it will make a best effort to send the
44-
* message to each of its handlers. In other words, when 'ignoreFailures' is <code>true</code>, if it fails to send to
43+
* If the 'ignoreFailures' flag is set to true on the other hand, it will make a best effort to send the
44+
* message to each of its handlers. In other words, when 'ignoreFailures' is true, if it fails to send to
4545
* any one handler, it will simply log a warn-level message but continue to send the Message to any other handlers.
4646
* <p>
47-
* If the 'requireSubscribers' flag is set to <code>true</code>, the sent message is considered as non-dispatched
47+
* If the 'requireSubscribers' flag is set to true, the sent message is considered as non-dispatched
4848
* and rejected to the caller with the {@code "Dispatcher has no subscribers"} {@link MessageDispatchingException}.
4949
*
5050
* @author Mark Fisher
@@ -92,25 +92,23 @@ public BroadcastingDispatcher(Executor executor, boolean requireSubscribers) {
9292
}
9393

9494
/**
95-
* Specify whether failures for one or more of the handlers should be ignored. By default this is <code>false</code>
95+
* Specify whether failures for one or more of the handlers should be ignored. By default this is false
9696
* meaning that an Exception will be thrown when a handler fails. To override this and suppress Exceptions, set the
97-
* value to <code>true</code>.
97+
* value to true.
9898
* <p>
9999
* Keep in mind that when using an Executor, even without ignoring the failures, other handlers may be invoked after
100100
* one throws an Exception. Since the Executor is most likely using a different thread, this flag would only affect
101101
* whether an error Message is sent to the error channel or not in the case that such an Executor has been
102102
* configured.
103-
*
104103
* @param ignoreFailures true when failures are to be ignored.
105104
*/
106105
public void setIgnoreFailures(boolean ignoreFailures) {
107106
this.ignoreFailures = ignoreFailures;
108107
}
109108

110109
/**
111-
* Specify whether to apply sequence numbers to the messages prior to sending to the handlers. By default, sequence
112-
* numbers will <em>not</em> be applied.
113-
*
110+
* Specify whether to apply sequence numbers to the messages prior to sending to the handlers.
111+
* By default, sequence numbers will not be applied.
114112
* @param applySequence true when sequence information should be applied.
115113
*/
116114
public void setApplySequence(boolean applySequence) {
@@ -226,9 +224,7 @@ private boolean invokeHandler(MessageHandler handler, Message<?> message) {
226224
}
227225
catch (RuntimeException e) {
228226
if (!this.ignoreFailures) {
229-
if (e instanceof MessagingException
230-
&& ((MessagingException) e).getFailedMessage() == null) { // NOSONAR
231-
227+
if (e instanceof MessagingException && ((MessagingException) e).getFailedMessage() == null) { // NOSONAR
232228
throw new MessagingException(message, "Failed to handle Message", e);
233229
}
234230
throw e;

spring-integration-groovy/src/main/java/org/springframework/integration/groovy/config/GroovyIntegrationConfigurationInitializer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2019 the original author or authors.
2+
* Copyright 2016-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,15 +35,15 @@
3535
*/
3636
public class GroovyIntegrationConfigurationInitializer implements IntegrationConfigurationInitializer {
3737

38-
private static final Log logger = LogFactory.getLog(GroovyIntegrationConfigurationInitializer.class);
38+
private static final Log LOGGER = LogFactory.getLog(GroovyIntegrationConfigurationInitializer.class);
3939

4040
@Override
4141
public void initialize(ConfigurableListableBeanFactory beanFactory) throws BeansException {
4242
if (beanFactory instanceof BeanDefinitionRegistry) {
4343
registerScriptExecutorProviderIfNecessary((BeanDefinitionRegistry) beanFactory);
4444
}
4545
else {
46-
logger.warn("The 'ScriptExecutingProcessorFactory' isn't registered because 'beanFactory'" +
46+
LOGGER.warn("The 'ScriptExecutingProcessorFactory' isn't registered because 'beanFactory'" +
4747
" isn't an instance of `BeanDefinitionRegistry`.");
4848
}
4949
}

spring-integration-http/src/main/java/org/springframework/integration/http/config/IntegrationGraphControllerRegistrarImportSelector.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2019 the original author or authors.
2+
* Copyright 2016-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,15 +29,15 @@
2929
*/
3030
class IntegrationGraphControllerRegistrarImportSelector implements ImportSelector {
3131

32-
private static final Log logger = LogFactory.getLog(IntegrationGraphControllerRegistrarImportSelector.class);
32+
private static final Log LOGGER = LogFactory.getLog(IntegrationGraphControllerRegistrarImportSelector.class);
3333

3434
@Override
3535
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
3636
if (HttpContextUtils.WEB_MVC_PRESENT || HttpContextUtils.WEB_FLUX_PRESENT) {
3737
return new String[] { IntegrationGraphControllerRegistrar.class.getName() };
3838
}
3939
else {
40-
logger.warn("The 'IntegrationGraphController' isn't registered with the application context because" +
40+
LOGGER.warn("The 'IntegrationGraphController' isn't registered with the application context because" +
4141
" there is no 'org.springframework.web.servlet.DispatcherServlet' or" +
4242
" 'org.springframework.web.reactive.DispatcherHandler' in the classpath.");
4343
return new String[0];

spring-integration-http/src/main/java/org/springframework/integration/http/multipart/FileCopyingMultipartFileReader.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,23 +25,25 @@
2525
import org.springframework.web.multipart.MultipartFile;
2626

2727
/**
28-
* {@link MultipartFileReader} implementation that copies the MulitpartFile's
28+
* {@link MultipartFileReader} implementation that copies the MultipartFile's
2929
* content to a new temporary File in the specified directory. If no directory
3030
* is provided, the Files will be created in the default temporary directory.
3131
*
3232
* @author Mark Fisher
33+
* @author Artyem Bilan
34+
*
3335
* @since 2.0
3436
*/
3537
public class FileCopyingMultipartFileReader implements MultipartFileReader<MultipartFile> {
3638

37-
private static final Log logger = LogFactory.getLog(FileCopyingMultipartFileReader.class);
39+
private static final Log LOGGER = LogFactory.getLog(FileCopyingMultipartFileReader.class);
3840

3941

4042
private final File directory;
4143

42-
private volatile String prefix = "si_";
44+
private String prefix = "si_";
4345

44-
private volatile String suffix = ".tmp";
46+
private String suffix = ".tmp";
4547

4648

4749
/**
@@ -55,7 +57,6 @@ public FileCopyingMultipartFileReader() {
5557
/**
5658
* Create a {@link FileCopyingMultipartFileReader} that creates temporary
5759
* Files in the given directory.
58-
*
5960
* @param directory The directory.
6061
*/
6162
public FileCopyingMultipartFileReader(File directory) {
@@ -65,7 +66,6 @@ public FileCopyingMultipartFileReader(File directory) {
6566

6667
/**
6768
* Specify the prefix to use for temporary files.
68-
*
6969
* @param prefix The prefix.
7070
*/
7171
public void setPrefix(String prefix) {
@@ -74,7 +74,6 @@ public void setPrefix(String prefix) {
7474

7575
/**
7676
* Specify the suffix to use for temporary files.
77-
*
7877
* @param suffix The suffix.
7978
*/
8079
public void setSuffix(String suffix) {
@@ -87,8 +86,8 @@ public MultipartFile readMultipartFile(MultipartFile multipartFile) throws IOExc
8786
multipartFile.transferTo(upload);
8887
UploadedMultipartFile uploadedMultipartFile = new UploadedMultipartFile(upload, multipartFile.getSize(),
8988
multipartFile.getContentType(), multipartFile.getName(), multipartFile.getOriginalFilename());
90-
if (logger.isDebugEnabled()) {
91-
logger.debug("copied uploaded file [" + multipartFile.getOriginalFilename() +
89+
if (LOGGER.isDebugEnabled()) {
90+
LOGGER.debug("copied uploaded file [" + multipartFile.getOriginalFilename() +
9291
"] to [" + upload.getAbsolutePath() + "]");
9392
}
9493
return uploadedMultipartFile;

spring-integration-ip/src/main/java/org/springframework/integration/ip/config/UdpOutboundChannelAdapterParser.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
3131
* @author Gary Russell
3232
* @author Marcin Pilaczynski
3333
* @author Artem Bilan
34+
*
3435
* @since 2.0
3536
*/
3637
public class UdpOutboundChannelAdapterParser extends AbstractOutboundChannelAdapterParser {
@@ -63,20 +64,21 @@ private BeanDefinitionBuilder parseUdp(Element element, ParserContext parserCont
6364
IpAdapterParserUtils.addConstructorValueIfAttributeDefined(builder, element, IpAdapterParserUtils.ACK_PORT);
6465
IpAdapterParserUtils.addConstructorValueIfAttributeDefined(builder, element, IpAdapterParserUtils.ACK_TIMEOUT);
6566
String ack = element.getAttribute(IpAdapterParserUtils.ACK);
66-
if (ack.equals("true")) {
67-
if (!StringUtils.hasText(element
68-
.getAttribute(IpAdapterParserUtils.ACK_HOST))
69-
|| !StringUtils.hasText(element
70-
.getAttribute(IpAdapterParserUtils.ACK_PORT))
71-
|| !StringUtils.hasText(element
72-
.getAttribute(IpAdapterParserUtils.ACK_TIMEOUT))) {
73-
parserContext.getReaderContext().error("When "
74-
+ IpAdapterParserUtils.ACK + " is true, "
75-
+ IpAdapterParserUtils.ACK_HOST + ", "
76-
+ IpAdapterParserUtils.ACK_PORT + ", and "
77-
+ IpAdapterParserUtils.ACK_TIMEOUT
78-
+ " must be supplied", element);
79-
}
67+
if (ack.equals("true") &&
68+
(!StringUtils.hasText(element
69+
.getAttribute(IpAdapterParserUtils.ACK_HOST))
70+
|| !StringUtils.hasText(element
71+
.getAttribute(IpAdapterParserUtils.ACK_PORT))
72+
|| !StringUtils.hasText(element
73+
.getAttribute(IpAdapterParserUtils.ACK_TIMEOUT)))) {
74+
75+
parserContext.getReaderContext()
76+
.error("When "
77+
+ IpAdapterParserUtils.ACK + " is true, "
78+
+ IpAdapterParserUtils.ACK_HOST + ", "
79+
+ IpAdapterParserUtils.ACK_PORT + ", and "
80+
+ IpAdapterParserUtils.ACK_TIMEOUT
81+
+ " must be supplied", element);
8082
}
8183
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element,
8284
IpAdapterParserUtils.RECEIVE_BUFFER_SIZE);

0 commit comments

Comments
 (0)