GH-3132: Remove usage of super();

Fixes https://github.com/spring-projects/spring-integration/issues/3132

It turns out that Checkstyle EmptyBlock doesn't complain about
empty default ctor.
Plus a new check for `super();` call treats it as a violation

* Remove `super();` from all the no-arg ctors
* Code style clean up in the affected classes according
IDEA suggestions

* Fix new Sonar smells
This commit is contained in:
Artem Bilan
2019-12-27 13:04:10 -05:00
committed by Gary Russell
parent 9c68ae4a7d
commit 5ac262f866
127 changed files with 386 additions and 490 deletions

View File

@@ -28,7 +28,7 @@ import java.util.stream.Collectors;
*
* @since 5.3
*/
public enum IntegrationPatternType {
public enum IntegrationPatternType { // NOSONAR Initialization circularity is useful for static view
message_channel(IntegrationPatternCategory.messaging_channel),
@@ -146,7 +146,7 @@ public enum IntegrationPatternType {
private final IntegrationPatternType[] patternTypes;
IntegrationPatternCategory(IntegrationPatternType... patternTypes) {
this.patternTypes = patternTypes;
this.patternTypes = Arrays.copyOf(patternTypes, patternTypes.length);
}
public Set<IntegrationPatternType> getPatternTypes() {

View File

@@ -31,6 +31,7 @@ import org.springframework.util.MimeType;
* creation just to access a header.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 5.0.1
*
@@ -39,7 +40,6 @@ import org.springframework.util.MimeType;
public final class StaticMessageHeaderAccessor {
private StaticMessageHeaderAccessor() {
super();
}
@Nullable

View File

@@ -18,31 +18,19 @@ package org.springframework.integration.acks;
import org.springframework.integration.acks.AcknowledgmentCallback.Status;
import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
/**
* Utility methods for acting on {@link AcknowledgmentCallback} headers.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 5.0.1
*
*/
public final class AckUtils {
private AckUtils() {
super();
}
/**
* Return the {@link AcknowledgmentCallback} header (if present).
* @param message the message.
* @return the callback, or null.
* @deprecated use StaticMessageHeaderAccessor.getAcknowledgmentCallback(message).
*/
@Deprecated
@Nullable
public static AcknowledgmentCallback getAckCallback(Message<?> message) {
throw new UnsupportedOperationException("Use StaticMessageHeaderAccessor.getAcknowledgmentCallback(message)");
}
/**

View File

@@ -960,7 +960,6 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageP
private class ForceReleaseMessageGroupProcessor implements MessageGroupProcessor {
ForceReleaseMessageGroupProcessor() {
super();
}
@Override

View File

@@ -19,24 +19,17 @@ package org.springframework.integration.aggregator;
import org.springframework.integration.store.MessageGroup;
/**
* A {@link ReleaseStrategy} that releases only the first <code>n</code> messages, where <code>n</code> is a threshold.
* A {@link ReleaseStrategy} that releases only the first {@code n} messages, where {@code n} is a threshold.
*
* @author Dave Syer
* @author Oleg Zhurakousky
* @author Artem Bilan
*
*/
public class MessageCountReleaseStrategy implements ReleaseStrategy {
private final int threshold;
/**
* @param threshold the number of messages to accept before releasing
*/
public MessageCountReleaseStrategy(int threshold) {
super();
this.threshold = threshold;
}
/**
* Convenient constructor is only one message is required (threshold=1).
*/
@@ -44,6 +37,14 @@ public class MessageCountReleaseStrategy implements ReleaseStrategy {
this(1);
}
/**
* Construct an instance based on the provided threshold.
* @param threshold the number of messages to accept before releasing
*/
public MessageCountReleaseStrategy(int threshold) {
this.threshold = threshold;
}
/**
* Release the group if it has more messages than the threshold and has not previously been released.
* It is possible that more messages than the threshold could be released, but only if multiple consumers

View File

@@ -35,7 +35,6 @@ public final class ChannelUtils {
public static final String MESSAGE_PUBLISHING_ERROR_HANDLER_BEAN_NAME = "integrationMessagePublishingErrorHandler";
private ChannelUtils() {
super();
}
/**
@@ -56,5 +55,4 @@ public final class ChannelUtils {
return beanFactory.getBean(MESSAGE_PUBLISHING_ERROR_HANDLER_BEAN_NAME, ErrorHandler.class);
}
}

View File

@@ -40,7 +40,6 @@ import reactor.core.scheduler.Schedulers;
public final class MessageChannelReactiveUtils {
private MessageChannelReactiveUtils() {
super();
}
@SuppressWarnings("unchecked")

View File

@@ -58,6 +58,8 @@ import org.springframework.util.StringUtils;
*/
public class MessagingGatewayRegistrar implements ImportBeanDefinitionRegistrar {
private static final String PROXY_DEFAULT_METHODS_ATTR = "proxyDefaultMethods";
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
if (importingClassMetadata != null && importingClassMetadata.isAnnotated(MessagingGateway.class.getName())) {
@@ -68,7 +70,8 @@ public class MessagingGatewayRegistrar implements ImportBeanDefinitionRegistrar
importingClassMetadata.getAnnotationAttributes(MessagingGateway.class.getName());
replaceEmptyOverrides(valuesHierarchy, annotationAttributes); // NOSONAR never null
annotationAttributes.put("serviceInterface", importingClassMetadata.getClassName());
annotationAttributes.put("proxyDefaultMethods", "" + annotationAttributes.remove("proxyDefaultMethods"));
annotationAttributes.put(PROXY_DEFAULT_METHODS_ATTR,
"" + annotationAttributes.remove(PROXY_DEFAULT_METHODS_ATTR));
BeanDefinitionReaderUtils.registerBeanDefinition(parse(annotationAttributes), registry);
}
}
@@ -84,7 +87,7 @@ public class MessagingGatewayRegistrar implements ImportBeanDefinitionRegistrar
String errorChannel = (String) gatewayAttributes.get("errorChannel");
String asyncExecutor = (String) gatewayAttributes.get("asyncExecutor");
String mapper = (String) gatewayAttributes.get("mapper");
String proxyDefaultMethods = (String) gatewayAttributes.get("proxyDefaultMethods");
String proxyDefaultMethods = (String) gatewayAttributes.get(PROXY_DEFAULT_METHODS_ATTR);
boolean hasMapper = StringUtils.hasText(mapper);
boolean hasDefaultPayloadExpression = StringUtils.hasText(defaultPayloadExpression);
@@ -154,7 +157,7 @@ public class MessagingGatewayRegistrar implements ImportBeanDefinitionRegistrar
gatewayProxyBuilder.addPropertyReference("mapper", mapper);
}
if (StringUtils.hasText(proxyDefaultMethods)) {
gatewayProxyBuilder.addPropertyValue("proxyDefaultMethods", proxyDefaultMethods);
gatewayProxyBuilder.addPropertyValue(PROXY_DEFAULT_METHODS_ATTR, proxyDefaultMethods);
}
gatewayProxyBuilder.addPropertyValue("defaultRequestTimeoutExpressionString",

View File

@@ -132,7 +132,6 @@ public final class Channels {
}
private Channels() {
super();
}
}

View File

@@ -38,7 +38,6 @@ public class DirectChannelSpec extends LoadBalancingChannelSpec<DirectChannelSpe
}
DirectChannelSpec() {
super();
}
}

View File

@@ -28,7 +28,6 @@ import org.springframework.messaging.Message;
public final class IntegrationFlowBuilder extends IntegrationFlowDefinition<IntegrationFlowBuilder> {
IntegrationFlowBuilder() {
super();
}
@Override

View File

@@ -39,7 +39,6 @@ public abstract class LoadBalancingChannelSpec<S extends MessageChannelSpec<S, C
protected Integer maxSubscribers; // NOSONAR
protected LoadBalancingChannelSpec() {
super();
}
public S loadBalancer(LoadBalancingStrategy loadBalancingStrategyToSet) {

View File

@@ -54,7 +54,6 @@ public abstract class MessageChannelSpec<S extends MessageChannelSpec<S, C>, C e
private MessageConverter messageConverter;
protected MessageChannelSpec() {
super();
}
public S datatype(Class<?>... types) {
@@ -118,7 +117,7 @@ public abstract class MessageChannelSpec<S extends MessageChannelSpec<S, C>, C e
@Override
protected C doGet() {
this.channel.setDatatypes(this.datatypes.toArray(new Class<?>[this.datatypes.size()]));
this.channel.setDatatypes(this.datatypes.toArray(new Class<?>[0]));
this.channel.setBeanName(getId());
this.channel.setInterceptors(this.interceptors);
this.channel.setMessageConverter(this.messageConverter);

View File

@@ -133,7 +133,6 @@ public final class MessageChannels {
}
private MessageChannels() {
super();
}
}

View File

@@ -81,7 +81,6 @@ public final class PollerFactory {
}
PollerFactory() {
super();
}
}

View File

@@ -38,7 +38,6 @@ public class PriorityChannelSpec extends MessageChannelSpec<PriorityChannelSpec,
private MessageGroupQueue messageGroupQueue;
PriorityChannelSpec() {
super();
}
public PriorityChannelSpec capacity(int capacity) {

View File

@@ -19,6 +19,7 @@ package org.springframework.integration.dsl;
import java.util.concurrent.Executor;
import org.springframework.integration.channel.PublishSubscribeChannel;
import org.springframework.lang.Nullable;
import org.springframework.util.ErrorHandler;
/**
@@ -33,10 +34,10 @@ public class PublishSubscribeChannelSpec<S extends PublishSubscribeChannelSpec<S
extends MessageChannelSpec<S, PublishSubscribeChannel> {
protected PublishSubscribeChannelSpec() {
this.channel = new PublishSubscribeChannel();
this(null);
}
protected PublishSubscribeChannelSpec(Executor executor) {
protected PublishSubscribeChannelSpec(@Nullable Executor executor) {
this.channel = new PublishSubscribeChannel(executor);
}

View File

@@ -20,6 +20,7 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.Executor;
import org.springframework.lang.Nullable;
import org.springframework.messaging.MessageChannel;
import org.springframework.util.Assert;
@@ -36,10 +37,9 @@ public class PublishSubscribeSpec extends PublishSubscribeChannelSpec<PublishSub
private int order;
PublishSubscribeSpec() {
super();
}
PublishSubscribeSpec(Executor executor) {
PublishSubscribeSpec(@Nullable Executor executor) {
super(executor);
}

View File

@@ -36,7 +36,6 @@ public class QueueChannelSpec extends MessageChannelSpec<QueueChannelSpec, Queue
protected Integer capacity; // NOSONAR
QueueChannelSpec() {
super();
}
QueueChannelSpec(Queue<Message<?>> queue) {
@@ -73,7 +72,6 @@ public class QueueChannelSpec extends MessageChannelSpec<QueueChannelSpec, Queue
private Lock storeLock;
MessageStoreSpec(ChannelMessageStore messageGroupStore, Object groupId) {
super();
this.messageGroupStore = messageGroupStore;
this.groupId = groupId;
}

View File

@@ -150,7 +150,6 @@ public class ReactiveStreamsConsumer extends AbstractEndpoint implements Integra
private final Subscriber<Message<?>> delegate = ReactiveStreamsConsumer.this.subscriber;
DelegatingSubscriber() {
super();
}
@Override

View File

@@ -303,7 +303,6 @@ public final class ExpressionEvalMap extends AbstractMap<String, Object> {
private class ExpressionEvalMapFinalBuilderImpl implements ExpressionEvalMapFinalBuilder {
ExpressionEvalMapFinalBuilderImpl() {
super();
}
@Override
@@ -327,7 +326,6 @@ public final class ExpressionEvalMap extends AbstractMap<String, Object> {
implements ExpressionEvalMapComponentsBuilder {
ExpressionEvalMapComponentsBuilderImpl() {
super();
}
@Override

View File

@@ -60,7 +60,6 @@ public final class ExpressionUtils {
private static final Log LOGGER = LogFactory.getLog(ExpressionUtils.class);
private ExpressionUtils() {
super();
}
/**

View File

@@ -19,7 +19,6 @@ package org.springframework.integration.expression;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -53,7 +52,10 @@ import org.springframework.util.StringUtils;
* @author Juergen Hoeller
* @author Mark Fisher
* @author Gary Russell
* @author Artem Bilan
*
* @since 2.0
*
* @see #setCacheSeconds
* @see #setBasenames
* @see #setDefaultEncoding
@@ -70,35 +72,40 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
private static final String XML_SUFFIX = ".xml";
private static final Log logger = LogFactory.getLog(ReloadableResourceBundleExpressionSource.class);
private static final Log LOGGER = LogFactory.getLog(ReloadableResourceBundleExpressionSource.class);
private volatile String[] basenames = new String[0];
/**
* Cache to hold filename lists per Locale
*/
private final Map<String, Map<Locale, List<String>>> cachedFilenames = new HashMap<>();
private volatile String defaultEncoding;
/**
* Cache to hold already loaded properties per filename
*/
private final Map<String, PropertiesHolder> cachedProperties = new HashMap<>();
private volatile Properties fileEncodings;
private volatile boolean fallbackToSystemLocale = true;
private volatile long cacheMillis = -1;
private volatile PropertiesPersister propertiesPersister = new DefaultPropertiesPersister();
private volatile ResourceLoader resourceLoader = new DefaultResourceLoader();
/** Cache to hold filename lists per Locale */
private final Map<String, Map<Locale, List<String>>> cachedFilenames =
new HashMap<String, Map<Locale, List<String>>>();
/** Cache to hold already loaded properties per filename */
private final Map<String, PropertiesHolder> cachedProperties = new HashMap<String, PropertiesHolder>();
/** Cache to hold merged loaded properties per locale */
private final Map<Locale, PropertiesHolder> cachedMergedProperties = new HashMap<Locale, PropertiesHolder>();
/**
* Cache to hold merged loaded properties per locale
*/
private final Map<Locale, PropertiesHolder> cachedMergedProperties = new HashMap<>();
private final ExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
private String[] basenames = { };
private String defaultEncoding;
private Properties fileEncodings;
private boolean fallbackToSystemLocale = true;
private long cacheMillis = -1;
private PropertiesPersister propertiesPersister = new DefaultPropertiesPersister();
private ResourceLoader resourceLoader = new DefaultResourceLoader();
/**
* Set a single basename, following the basic ResourceBundle convention of
@@ -130,7 +137,7 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
* @see #setBasename
* @see java.util.ResourceBundle
*/
public void setBasenames(String[] basenames) {
public void setBasenames(@Nullable String[] basenames) {
if (basenames != null) {
this.basenames = new String[basenames.length];
for (int i = 0; i < basenames.length; i++) {
@@ -182,7 +189,6 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
* desirable in an application server environment, where the system Locale
* is not relevant to the application at all: Set this flag to "false"
* in such a scenario.
*
* @param fallbackToSystemLocale true to fall back.
*/
public void setFallbackToSystemLocale(boolean fallbackToSystemLocale) {
@@ -202,7 +208,6 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
* <li>A value of "0" will check the last-modified timestamp of the file on
* every expression access. <b>Do not use this in a production environment!</b>
* </ul>
*
* @param cacheSeconds The cache seconds.
*/
public void setCacheSeconds(int cacheSeconds) {
@@ -212,12 +217,10 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
/**
* Set the PropertiesPersister to use for parsing properties files.
* <p>The default is a DefaultPropertiesPersister.
*
* @param propertiesPersister The properties persister.
*
* @see org.springframework.util.DefaultPropertiesPersister
*/
public void setPropertiesPersister(PropertiesPersister propertiesPersister) {
public void setPropertiesPersister(@Nullable PropertiesPersister propertiesPersister) {
this.propertiesPersister =
(propertiesPersister != null ? propertiesPersister : new DefaultPropertiesPersister());
}
@@ -232,7 +235,7 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
* @see org.springframework.context.ResourceLoaderAware
*/
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
public void setResourceLoader(@Nullable ResourceLoader resourceLoader) {
this.resourceLoader = (resourceLoader != null ? resourceLoader : new DefaultResourceLoader());
}
@@ -253,10 +256,7 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
private String getExpressionString(String key, Locale locale) {
if (this.cacheMillis < 0) {
PropertiesHolder propHolder = getMergedProperties(locale);
String result = propHolder.getProperty(key);
if (result != null) {
return result;
}
return propHolder.getProperty(key);
}
else {
for (String basename : this.basenames) {
@@ -277,7 +277,7 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
* Get a PropertiesHolder that contains the actually visible properties
* for a Locale, after merging all specified resource bundles.
* Either fetches the holder from the cache or freshly loads it.
* <p>Only used when caching resource bundle contents forever, i.e.
* <p> Only used when caching resource bundle contents forever, i.e.
* with cacheSeconds < 0. Therefore, merged properties are always
* cached forever.
*/
@@ -323,7 +323,7 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
return filenames;
}
}
List<String> filenames = new ArrayList<String>(7);
List<String> filenames = new ArrayList<>(7);
filenames.addAll(calculateFilenamesForLocale(basename, locale));
if (this.fallbackToSystemLocale && !locale.equals(Locale.getDefault())) {
List<String> fallbackFilenames = calculateFilenamesForLocale(basename, Locale.getDefault());
@@ -339,7 +339,7 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
localeMap.put(locale, filenames);
}
else {
localeMap = new HashMap<Locale, List<String>>();
localeMap = new HashMap<>();
localeMap.put(locale, filenames);
this.cachedFilenames.put(basename, localeMap);
}
@@ -358,7 +358,7 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
* @return the List of filenames to check
*/
private List<String> calculateFilenamesForLocale(String basename, Locale locale) {
List<String> result = new ArrayList<String>(3);
List<String> result = new ArrayList<>(3);
String language = locale.getLanguage();
String country = locale.getCountry();
String variant = locale.getVariant();
@@ -423,8 +423,8 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
try {
fileTimestamp = resource.lastModified();
if (propHolder != null && propHolder.getFileTimestamp() == fileTimestamp) {
if (logger.isDebugEnabled()) {
logger.debug("Re-caching properties for filename [" + filename
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Re-caching properties for filename [" + filename
+ "] - file hasn't been modified");
}
propHolder.setRefreshTimestamp(refreshTimestamp);
@@ -433,8 +433,8 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
}
catch (IOException ex) {
// Probably a class path resource: cache it forever.
if (logger.isDebugEnabled()) {
logger.debug(resource
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(resource
+ " could not be resolved in the file system - assuming that is hasn't changed", ex);
}
fileTimestamp = -1;
@@ -445,8 +445,8 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
else {
// Resource does not exist.
if (logger.isDebugEnabled()) {
logger.debug("No properties file found for [" + filename + "] - neither plain properties nor XML");
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("No properties file found for [" + filename + "] - neither plain properties nor XML");
}
// Empty holder representing "not found".
propHolder = new PropertiesHolder();
@@ -472,8 +472,8 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
propHolder = new PropertiesHolder(props, fileTimestamp);
}
catch (IOException ex) {
if (logger.isWarnEnabled()) {
logger.warn("Could not parse properties file [" + resource.getFilename() + "]", ex);
if (LOGGER.isWarnEnabled()) {
LOGGER.warn("Could not parse properties file [" + resource.getFilename() + "]", ex);
}
// Empty holder representing "not valid".
propHolder = new PropertiesHolder();
@@ -489,13 +489,12 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
* @throws IOException if properties loading failed
*/
private Properties loadProperties(Resource resource, String filename) throws IOException {
InputStream is = resource.getInputStream();
Properties props = new Properties();
try {
try (InputStream is = resource.getInputStream()) {
Properties props = new Properties();
String resourceFilename = resource.getFilename();
if (resourceFilename != null && resourceFilename.endsWith(XML_SUFFIX)) {
if (logger.isDebugEnabled()) {
logger.debug("Loading properties [" + resourceFilename + "]");
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Loading properties [" + resourceFilename + "]");
}
this.propertiesPersister.loadFromXml(props, is);
}
@@ -504,13 +503,11 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
}
return props;
}
finally {
is.close();
}
}
private void loadFromProperties(Resource resource, String filename, InputStream is, Properties props,
String resourceFilename) throws IOException, UnsupportedEncodingException {
@Nullable String resourceFilename) throws IOException {
String encoding = null;
if (this.fileEncodings != null) {
encoding = this.fileEncodings.getProperty(filename);
@@ -519,16 +516,16 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
encoding = this.defaultEncoding;
}
if (encoding != null) {
if (logger.isDebugEnabled()) {
logger.debug("Loading properties ["
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Loading properties ["
+ (resourceFilename == null ? resource : resourceFilename)
+ "] with encoding '" + encoding + "'");
}
this.propertiesPersister.load(props, new InputStreamReader(is, encoding));
}
else {
if (logger.isDebugEnabled()) {
logger.debug("Loading properties [" + (resourceFilename == null ? resource : resourceFilename)
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Loading properties [" + (resourceFilename == null ? resource : resourceFilename)
+ "]");
}
this.propertiesPersister.load(props, is);
@@ -541,7 +538,7 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
* Subsequent resolve calls will lead to reloading of the properties files.
*/
public void clearCache() {
logger.debug("Clearing entire resource bundle cache");
LOGGER.debug("Clearing entire resource bundle cache");
synchronized (this.cachedProperties) {
this.cachedProperties.clear();
}
@@ -571,7 +568,6 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
private long refreshTimestamp = -1;
PropertiesHolder() {
super();
}
PropertiesHolder(Properties properties, long fileTimestamp) {
@@ -579,6 +575,7 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
this.fileTimestamp = fileTimestamp;
}
@Nullable
public Properties getProperties() {
return this.properties;
}

View File

@@ -85,7 +85,7 @@ class DefaultMethodInvokingMethodInterceptor implements MethodInterceptor {
ENCAPSULATED {
@Nullable
private final Method privateLookupIn =
private final transient Method privateLookupIn =
ReflectionUtils.findMethod(MethodHandles.class, "privateLookupIn", Class.class, Lookup.class);
@Override
@@ -120,7 +120,7 @@ class DefaultMethodInvokingMethodInterceptor implements MethodInterceptor {
OPEN {
@Nullable
private final Constructor<Lookup> constructor;
private final transient Constructor<Lookup> constructor;
{
Constructor<Lookup> ctor = null;
@@ -140,11 +140,13 @@ class DefaultMethodInvokingMethodInterceptor implements MethodInterceptor {
@Override
MethodHandle lookup(Method method) throws ReflectiveOperationException {
if (!isAvailable()) {
if (this.constructor != null) {
return this.constructor.newInstance(method.getDeclaringClass())
.unreflectSpecial(method, method.getDeclaringClass());
}
else {
throw new IllegalStateException("Could not obtain MethodHandles.lookup constructor!");
}
return this.constructor.newInstance(method.getDeclaringClass())
.unreflectSpecial(method, method.getDeclaringClass());
}
@Override
@@ -158,6 +160,7 @@ class DefaultMethodInvokingMethodInterceptor implements MethodInterceptor {
* Fallback {@link MethodHandle} lookup using {@link MethodHandles#lookup() public lookup}.
*/
FALLBACK {
@Override
MethodHandle lookup(Method method) throws ReflectiveOperationException {
return doLookup(method, MethodHandles.lookup());

View File

@@ -509,7 +509,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
try {
return invocation.proceed();
}
catch (Throwable throwable) {
catch (Throwable throwable) { // NOSONAR
throw new IllegalStateException(throwable);
}
}

View File

@@ -843,7 +843,6 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
private volatile MessageBuilderFactory messageBuilderFactory = new DefaultMessageBuilderFactory();
DefaultRequestMapper() {
super();
}
void setMessageBuilderFactory(MessageBuilderFactory messageBuilderFactory) {
@@ -865,7 +864,6 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
private final MonoProcessor<Message<?>> replyMono = MonoProcessor.create();
MonoReplyChannel() {
super();
}
@Override

View File

@@ -354,7 +354,6 @@ public class IntegrationGraphServer implements ApplicationContextAware, Applicat
private final AtomicInteger nodeId = new AtomicInteger();
NodeFactory() {
super();
}
MessageChannelNode channelNode(String name, MessageChannel channel) {

View File

@@ -77,7 +77,7 @@ public abstract class IntegrationNode {
IntegrationPatternType patternType = null;
if (nodeObject instanceof IntegrationPattern) {
patternType = ((IntegrationPattern) nodeObject).getIntegrationPatternType();
patternType = ((IntegrationPattern) nodeObject).getIntegrationPatternType(); // NOSONAR
}
else if (nodeObject instanceof MessageHandler) {
patternType = IntegrationPatternType.service_activator;

View File

@@ -35,19 +35,22 @@ public abstract class AbstractReactiveMessageHandler extends MessageHandlerSuppo
implements ReactiveMessageHandler {
@Override
public Mono<Void> handleMessage(Message<?> message) {
Assert.notNull(message, "Message must not be null");
public Mono<Void> handleMessage(final Message<?> message) {
Assert.notNull(message, "message must not be null");
if (isLoggingEnabled() && this.logger.isDebugEnabled()) {
this.logger.debug(this + " received message: " + message);
}
final Message<?> messageToUse;
if (shouldTrack()) {
message = MessageHistory.write(message, this, getMessageBuilderFactory());
messageToUse = MessageHistory.write(message, this, getMessageBuilderFactory());
}
final Message<?> msg = message;
return handleMessageInternal(msg)
else {
messageToUse = message;
}
return handleMessageInternal(messageToUse)
.doOnError(e -> this.logger.error(
"An error occurred in message handler [" + this + "] on message [" + msg + "]", e));
"An error occurred in message handler [" + this + "] on message [" + messageToUse + "]", e));
}
protected abstract Mono<Void> handleMessageInternal(Message<?> message);

View File

@@ -127,9 +127,6 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
protected void doInit() {
}
/**
* {@inheritDoc}
*/
@Override
protected final void handleMessageInternal(Message<?> message) {
Object result;
@@ -192,7 +189,6 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
* {@code ((AbstractReplyProducingMessageHandler.RequestHandler)
* invocation.getThis()).getAdvisedHandler().getComponentName()}
* @return the outer class instance.
*
* @since 4.3.2
*/
AbstractReplyProducingMessageHandler getAdvisedHandler();
@@ -202,7 +198,6 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
private class AdvisedRequestHandler implements RequestHandler {
AdvisedRequestHandler() {
super();
}
@Override

View File

@@ -602,7 +602,6 @@ public class DelayHandler extends AbstractReplyProducingMessageHandler implement
private class ReleaseMessageHandler implements MessageHandler {
ReleaseMessageHandler() {
super();
}
@Override

View File

@@ -238,7 +238,6 @@ public class MessageHandlerChain extends AbstractMessageProducingHandler
private final class ReplyForwardingMessageChannel implements MessageChannel {
ReplyForwardingMessageChannel() {
super();
}
@Override

View File

@@ -40,7 +40,7 @@ public class RequestHandlerCircuitBreakerAdvice extends AbstractRequestHandlerAd
private volatile long halfOpenAfter = 1000;
private final ConcurrentMap<Object, AdvisedMetadata> metadataMap = new ConcurrentHashMap<Object, AdvisedMetadata>();
private final ConcurrentMap<Object, AdvisedMetadata> metadataMap = new ConcurrentHashMap<>();
public void setThreshold(int threshold) {
this.threshold = threshold;
@@ -88,7 +88,6 @@ public class RequestHandlerCircuitBreakerAdvice extends AbstractRequestHandlerAd
private volatile long lastFailure;
AdvisedMetadata() {
super();
}
private long getLastFailure() {

View File

@@ -43,7 +43,6 @@ public final class SimpleJsonSerializer {
private static final Log logger = LogFactory.getLog(SimpleJsonSerializer.class);
private SimpleJsonSerializer() {
super();
}
/**

View File

@@ -25,6 +25,7 @@ import org.apache.commons.logging.LogFactory;
*
* @author Janne Valkealahti
* @author Artem Bilan
*
* @since 4.2
*/
public class DefaultCandidate extends AbstractCandidate {
@@ -37,7 +38,6 @@ public class DefaultCandidate extends AbstractCandidate {
* Instantiate a default candidate.
*/
public DefaultCandidate() {
super();
}
/**

View File

@@ -26,12 +26,12 @@ import java.util.Collections;
*
* @author Artem Bilan
* @author Gary Russell
*
* @since 3.0
*/
public final class JsonHeaders {
private JsonHeaders() {
super();
}
public static final String PREFIX = "json";

View File

@@ -27,6 +27,8 @@ import org.apache.commons.logging.LogFactory;
* polling when some downstream condition exists in the flow.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 4.1
*
*/
@@ -65,7 +67,6 @@ public class PollSkipAdvice implements MethodInterceptor {
private static final class DefaultPollSkipStrategy implements PollSkipStrategy {
DefaultPollSkipStrategy() {
super();
}
@Override

View File

@@ -52,7 +52,6 @@ public abstract class AbstractMessageGroupStore extends AbstractBatchingMessageG
private boolean lazyLoadMessageGroups = true;
protected AbstractMessageGroupStore() {
super();
}
protected AbstractMessageGroupStore(boolean lazyLoadMessageGroups) {

View File

@@ -173,7 +173,6 @@ class PersistentMessageGroup implements MessageGroup {
private volatile Collection<Message<?>> collection;
PersistentCollection() {
super();
}
private void load() {

View File

@@ -25,6 +25,7 @@ import org.springframework.messaging.Message;
* Utilities for building error messages.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 4.3.10
*
@@ -41,7 +42,6 @@ public final class ErrorMessageUtils {
public static final String INPUT_MESSAGE_CONTEXT_KEY = "inputMessage";
private ErrorMessageUtils() {
super();
}
/**
@@ -67,7 +67,6 @@ public final class ErrorMessageUtils {
private static class ErrorMessageAttributes extends AttributeAccessorSupport {
ErrorMessageAttributes() {
super();
}
}

View File

@@ -26,6 +26,7 @@ import org.springframework.util.Assert;
*
* @author Artem Bilan
* @author Gary Russell
*
* @since 5.2
*
*/
@@ -34,7 +35,6 @@ public final class ChannelResolverUtils {
public static final String CHANNEL_RESOLVER_BEAN_NAME = "integrationChannelResolver";
private ChannelResolverUtils() {
super();
}
/**

View File

@@ -130,11 +130,10 @@ public class SimpleMessageConverter implements MessageConverter, BeanFactoryAwar
private class DefaultInboundMessageMapper implements InboundMessageMapper<Object> {
DefaultInboundMessageMapper() {
super();
}
@Override
public Message<?> toMessage(Object object, @Nullable Map<String, Object> headers) {
public Message<?> toMessage(@Nullable Object object, @Nullable Map<String, Object> headers) {
if (object == null) {
return null;
}
@@ -153,11 +152,10 @@ public class SimpleMessageConverter implements MessageConverter, BeanFactoryAwar
private static class DefaultOutboundMessageMapper implements OutboundMessageMapper<Object> {
DefaultOutboundMessageMapper() {
super();
}
@Override
public Object fromMessage(Message<?> message) {
public Object fromMessage(@Nullable Message<?> message) {
return (message != null) ? message.getPayload() : null;
}

View File

@@ -52,7 +52,6 @@ import com.fasterxml.jackson.databind.module.SimpleModule;
public final class JacksonJsonUtils {
private JacksonJsonUtils() {
super();
}
/**

View File

@@ -47,7 +47,6 @@ public final class JacksonPresent {
private JacksonPresent() {
super();
}
}

View File

@@ -40,7 +40,6 @@ public final class JsonObjectMapperProvider {
ClassUtils.isPresent("org.boon.json.ObjectMapper", classLoader);
private JsonObjectMapperProvider() {
super();
}
/**

View File

@@ -508,7 +508,6 @@ public class LockRegistryLeaderInitiator implements SmartLifecycle, DisposableBe
private class LockContext implements Context {
LockContext() {
super();
}
@Override

View File

@@ -29,6 +29,7 @@ import java.util.concurrent.locks.Lock;
*
* @author Oleg Zhurakousky
* @author Gary Russell
*
* @since 2.2
*
*/
@@ -42,7 +43,6 @@ public final class PassThruLockRegistry implements LockRegistry {
private static final class PassThruLock implements Lock {
PassThruLock() {
super();
}
@Override
@@ -74,6 +74,7 @@ public final class PassThruLockRegistry implements LockRegistry {
public void lock() {
// noop
}
}
}

View File

@@ -62,7 +62,6 @@ public final class IntegrationUtils {
Boolean.parseBoolean(System.getenv("SI_FATAL_WHEN_NO_BEANFACTORY"));
private IntegrationUtils() {
super();
}
/**

View File

@@ -20,6 +20,7 @@ import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.context.Lifecycle;
@@ -231,7 +232,6 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler implem
* If more sophisticated logic is required (e.g. changing the message headers etc.)
* please use additional downstream transformers.
* @param requestPayloadExpression The request payload expression.
*
*/
public void setRequestPayloadExpression(Expression requestPayloadExpression) {
this.requestPayloadExpression = requestPayloadExpression;
@@ -283,6 +283,9 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler implem
Assert.state(this.requestChannel != null || this.requestChannelName != null,
"If the errorChannel is set, then the requestChannel must not be null");
}
BeanFactory beanFactory = getBeanFactory();
if (this.requestChannel != null || this.requestChannelName != null) {
this.gateway = new Gateway();
if (this.requestChannel != null) {
@@ -309,23 +312,24 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler implem
this.gateway.setErrorChannelName(this.errorChannelName);
}
if (this.getBeanFactory() != null) {
this.gateway.setBeanFactory(this.getBeanFactory());
if (beanFactory != null) {
this.gateway.setBeanFactory(beanFactory);
}
this.gateway.afterPropertiesSet();
}
if (this.sourceEvaluationContext == null) {
this.sourceEvaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
this.sourceEvaluationContext = ExpressionUtils.createStandardEvaluationContext(beanFactory);
}
StandardEvaluationContext targetContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
StandardEvaluationContext targetContext = ExpressionUtils.createStandardEvaluationContext(beanFactory);
// bean resolution is NOT allowed for the target of the enrichment
targetContext.setBeanResolver(null); // NOSONAR (null)
this.targetEvaluationContext = targetContext;
if (getBeanFactory() != null) {
if (beanFactory != null) {
boolean checkReadOnlyHeaders = getMessageBuilderFactory() instanceof DefaultMessageBuilderFactory;
for (Map.Entry<String, HeaderValueMessageProcessor<?>> entry : this.headerExpressions.entrySet()) {
@@ -337,7 +341,7 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler implem
+ "] configuration for " + getComponentName());
}
if (entry.getValue() instanceof BeanFactoryAware) {
((BeanFactoryAware) entry.getValue()).setBeanFactory(getBeanFactory());
((BeanFactoryAware) entry.getValue()).setBeanFactory(beanFactory);
}
}
@@ -351,7 +355,7 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler implem
+ "] configuration for " + getComponentName());
}
if (entry.getValue() instanceof BeanFactoryAware) {
((BeanFactoryAware) entry.getValue()).setBeanFactory(getBeanFactory());
((BeanFactoryAware) entry.getValue()).setBeanFactory(beanFactory);
}
}
}
@@ -406,8 +410,7 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler implem
return targetPayload;
}
else {
Map<String, Object> targetHeaders = new HashMap<>(
this.nullResultHeaderExpressions.size());
Map<String, Object> targetHeaders = new HashMap<>(this.nullResultHeaderExpressions.size());
for (Map.Entry<String, HeaderValueMessageProcessor<?>> entry : this.nullResultHeaderExpressions
.entrySet()) {
String header = entry.getKey();
@@ -435,7 +438,7 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler implem
return targetPayload;
}
else {
Map<String, Object> targetHeaders = new HashMap<String, Object>(this.headerExpressions.size());
Map<String, Object> targetHeaders = new HashMap<>(this.headerExpressions.size());
for (Map.Entry<String, HeaderValueMessageProcessor<?>> entry : this.headerExpressions.entrySet()) {
String header = entry.getKey();
HeaderValueMessageProcessor<?> valueProcessor = entry.getValue();
@@ -490,7 +493,6 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler implem
private static final class Gateway extends MessagingGatewaySupport {
Gateway() {
super();
}
@Override

View File

@@ -20,6 +20,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.integration.IntegrationPattern;
@@ -103,7 +104,24 @@ public class HeaderEnricher extends IntegrationObjectSupport implements Transfor
public void onInit() {
boolean shouldOverwrite = this.defaultOverwrite;
boolean checkReadOnlyHeaders = getMessageBuilderFactory() instanceof DefaultMessageBuilderFactory;
shouldOverwrite = initializeHeadersToAdd(shouldOverwrite, checkReadOnlyHeaders);
BeanFactory beanFactory = getBeanFactory();
if (this.messageProcessor != null
&& this.messageProcessor instanceof BeanFactoryAware
&& beanFactory != null) {
((BeanFactoryAware) this.messageProcessor).setBeanFactory(beanFactory);
}
if (!shouldOverwrite && !this.shouldSkipNulls && logger.isWarnEnabled()) {
logger.warn(getComponentName() +
" is configured to not overwrite existing headers. 'shouldSkipNulls = false' will have no effect");
}
}
private boolean initializeHeadersToAdd(boolean shouldOverwrite, boolean checkReadOnlyHeaders) {
boolean overwrite = shouldOverwrite;
BeanFactory beanFactory = getBeanFactory();
for (Entry<String, ? extends HeaderValueMessageProcessor<?>> entry : this.headersToAdd.entrySet()) {
if (checkReadOnlyHeaders &&
(MessageHeaders.ID.equals(entry.getKey()) || MessageHeaders.TIMESTAMP.equals(entry.getKey()))) {
@@ -114,25 +132,15 @@ public class HeaderEnricher extends IntegrationObjectSupport implements Transfor
}
HeaderValueMessageProcessor<?> processor = entry.getValue();
if (processor instanceof BeanFactoryAware && getBeanFactory() != null) {
((BeanFactoryAware) processor).setBeanFactory(getBeanFactory());
if (processor instanceof BeanFactoryAware && beanFactory != null) {
((BeanFactoryAware) processor).setBeanFactory(beanFactory);
}
Boolean processorOverwrite = processor.isOverwrite();
if (processorOverwrite != null) {
shouldOverwrite |= processorOverwrite;
overwrite |= processorOverwrite;
}
}
if (this.messageProcessor != null
&& this.messageProcessor instanceof BeanFactoryAware
&& getBeanFactory() != null) {
((BeanFactoryAware) this.messageProcessor).setBeanFactory(getBeanFactory());
}
if (!shouldOverwrite && !this.shouldSkipNulls && logger.isWarnEnabled()) {
logger.warn(getComponentName() +
" is configured to not overwrite existing headers. 'shouldSkipNulls = false' will have no effect");
}
return overwrite;
}
@Override

View File

@@ -27,7 +27,6 @@ package org.springframework.integration.transformer.support;
public final class AvroHeaders {
private AvroHeaders() {
super();
}
/**

View File

@@ -41,7 +41,6 @@ public final class JavaUtils {
public static final JavaUtils INSTANCE = new JavaUtils();
private JavaUtils() {
super();
}
/**