Skip to content

Commit

Permalink
GH-3132: Remove usage of super();
Browse files Browse the repository at this point in the history
Fixes #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
  • Loading branch information
artembilan authored and garyrussell committed Dec 27, 2019
1 parent 9c68ae4 commit 5ac262f
Show file tree
Hide file tree
Showing 127 changed files with 369 additions and 473 deletions.
Expand Up @@ -25,6 +25,7 @@
* Utility methods for messaging endpoints.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 5.1.3
*
Expand All @@ -34,7 +35,6 @@ public final class EndpointUtils {
private static final String LEFE_MESSAGE = "Message conversion failed";

private EndpointUtils() {
super();
}

/**
Expand All @@ -43,16 +43,16 @@ private EndpointUtils() {
* @param message the failed message.
* @param channel the channel.
* @param isManualAck true if the container uses manual acknowledgment.
* @param e the exception.
* @param ex the exception.
* @return the exception.
*/
public static ListenerExecutionFailedException errorMessagePayload(final Message message,
Channel channel, boolean isManualAck, Exception e) {
public static ListenerExecutionFailedException errorMessagePayload(Message message,
Channel channel, boolean isManualAck, Exception ex) {

return isManualAck
? new ManualAckListenerExecutionFailedException(LEFE_MESSAGE, e, message, channel,
? new ManualAckListenerExecutionFailedException(LEFE_MESSAGE, ex, message, channel,
message.getMessageProperties().getDeliveryTag())
: new ListenerExecutionFailedException(LEFE_MESSAGE, e, message);
: new ListenerExecutionFailedException(LEFE_MESSAGE, ex, message);
}

}
Expand Up @@ -38,7 +38,6 @@
public final class MappingUtils {

private MappingUtils() {
super();
}

/**
Expand Down
Expand Up @@ -28,7 +28,7 @@
*
* @since 5.3
*/
public enum IntegrationPatternType {
public enum IntegrationPatternType { // NOSONAR Initialization circularity is useful for static view

message_channel(IntegrationPatternCategory.messaging_channel),

Expand Down Expand Up @@ -146,7 +146,7 @@ public enum IntegrationPatternCategory {
private final IntegrationPatternType[] patternTypes;

IntegrationPatternCategory(IntegrationPatternType... patternTypes) {
this.patternTypes = patternTypes;
this.patternTypes = Arrays.copyOf(patternTypes, patternTypes.length);
}

public Set<IntegrationPatternType> getPatternTypes() {
Expand Down
Expand Up @@ -31,6 +31,7 @@
* creation just to access a header.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 5.0.1
*
Expand All @@ -39,7 +40,6 @@
public final class StaticMessageHeaderAccessor {

private StaticMessageHeaderAccessor() {
super();
}

@Nullable
Expand Down
Expand Up @@ -18,31 +18,19 @@

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

/**
Expand Down
Expand Up @@ -960,7 +960,6 @@ private boolean containsSequenceNumber(Collection<Message<?>> messages, Integer
private class ForceReleaseMessageGroupProcessor implements MessageGroupProcessor {

ForceReleaseMessageGroupProcessor() {
super();
}

@Override
Expand Down
Expand Up @@ -19,29 +19,30 @@
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
* Convenient constructor is only one message is required (threshold=1).
*/
public MessageCountReleaseStrategy(int threshold) {
super();
this.threshold = threshold;
public MessageCountReleaseStrategy() {
this(1);
}

/**
* Convenient constructor is only one message is required (threshold=1).
* Construct an instance based on the provided threshold.
* @param threshold the number of messages to accept before releasing
*/
public MessageCountReleaseStrategy() {
this(1);
public MessageCountReleaseStrategy(int threshold) {
this.threshold = threshold;
}

/**
Expand Down
Expand Up @@ -35,7 +35,6 @@ public final class ChannelUtils {
public static final String MESSAGE_PUBLISHING_ERROR_HANDLER_BEAN_NAME = "integrationMessagePublishingErrorHandler";

private ChannelUtils() {
super();
}

/**
Expand All @@ -56,5 +55,4 @@ public static ErrorHandler getErrorHandler(BeanFactory beanFactory) {
return beanFactory.getBean(MESSAGE_PUBLISHING_ERROR_HANDLER_BEAN_NAME, ErrorHandler.class);
}


}
Expand Up @@ -40,7 +40,6 @@
public final class MessageChannelReactiveUtils {

private MessageChannelReactiveUtils() {
super();
}

@SuppressWarnings("unchecked")
Expand Down
Expand Up @@ -58,6 +58,8 @@
*/
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())) {
Expand All @@ -68,7 +70,8 @@ public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, B
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);
}
}
Expand All @@ -84,7 +87,7 @@ public BeanDefinitionHolder parse(Map<String, Object> gatewayAttributes) { // NO
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);
Expand Down Expand Up @@ -154,7 +157,7 @@ else if (StringUtils.hasText(asyncExecutor)) {
gatewayProxyBuilder.addPropertyReference("mapper", mapper);
}
if (StringUtils.hasText(proxyDefaultMethods)) {
gatewayProxyBuilder.addPropertyValue("proxyDefaultMethods", proxyDefaultMethods);
gatewayProxyBuilder.addPropertyValue(PROXY_DEFAULT_METHODS_ATTR, proxyDefaultMethods);
}

gatewayProxyBuilder.addPropertyValue("defaultRequestTimeoutExpressionString",
Expand Down
Expand Up @@ -132,7 +132,6 @@ public FluxMessageChannelSpec flux(String id) {
}

private Channels() {
super();
}

}
Expand Up @@ -38,7 +38,6 @@ protected DirectChannel doGet() {
}

DirectChannelSpec() {
super();
}

}
Expand Up @@ -28,7 +28,6 @@
public final class IntegrationFlowBuilder extends IntegrationFlowDefinition<IntegrationFlowBuilder> {

IntegrationFlowBuilder() {
super();
}

@Override
Expand Down
Expand Up @@ -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) {
Expand Down
Expand Up @@ -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) {
Expand Down Expand Up @@ -118,7 +117,7 @@ public Map<Object, String> getComponentsToRegister() {

@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);
Expand Down
Expand Up @@ -133,7 +133,6 @@ public static FluxMessageChannelSpec flux(String id) {
}

private MessageChannels() {
super();
}

}
Expand Up @@ -81,7 +81,6 @@ public PollerSpec fixedDelay(long period) {
}

PollerFactory() {
super();
}

}
Expand Up @@ -38,7 +38,6 @@ public class PriorityChannelSpec extends MessageChannelSpec<PriorityChannelSpec,
private MessageGroupQueue messageGroupQueue;

PriorityChannelSpec() {
super();
}

public PriorityChannelSpec capacity(int capacity) {
Expand Down
Expand Up @@ -19,6 +19,7 @@
import java.util.concurrent.Executor;

import org.springframework.integration.channel.PublishSubscribeChannel;
import org.springframework.lang.Nullable;
import org.springframework.util.ErrorHandler;

/**
Expand All @@ -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);
}

Expand Down
Expand Up @@ -20,6 +20,7 @@
import java.util.Map;
import java.util.concurrent.Executor;

import org.springframework.lang.Nullable;
import org.springframework.messaging.MessageChannel;
import org.springframework.util.Assert;

Expand All @@ -36,10 +37,9 @@ public class PublishSubscribeSpec extends PublishSubscribeChannelSpec<PublishSub
private int order;

PublishSubscribeSpec() {
super();
}

PublishSubscribeSpec(Executor executor) {
PublishSubscribeSpec(@Nullable Executor executor) {
super(executor);
}

Expand Down
Expand Up @@ -36,7 +36,6 @@ public class QueueChannelSpec extends MessageChannelSpec<QueueChannelSpec, Queue
protected Integer capacity; // NOSONAR

QueueChannelSpec() {
super();
}

QueueChannelSpec(Queue<Message<?>> queue) {
Expand Down Expand Up @@ -73,7 +72,6 @@ public static class MessageStoreSpec extends QueueChannelSpec {
private Lock storeLock;

MessageStoreSpec(ChannelMessageStore messageGroupStore, Object groupId) {
super();
this.messageGroupStore = messageGroupStore;
this.groupId = groupId;
}
Expand Down
Expand Up @@ -150,7 +150,6 @@ private final class DelegatingSubscriber extends BaseSubscriber<Message<?>> {
private final Subscriber<Message<?>> delegate = ReactiveStreamsConsumer.this.subscriber;

DelegatingSubscriber() {
super();
}

@Override
Expand Down
Expand Up @@ -303,7 +303,6 @@ public ExpressionEvalMapComponentsBuilder withReturnType(Class<?> returnType) {
private class ExpressionEvalMapFinalBuilderImpl implements ExpressionEvalMapFinalBuilder {

ExpressionEvalMapFinalBuilderImpl() {
super();
}

@Override
Expand All @@ -327,7 +326,6 @@ private class ExpressionEvalMapComponentsBuilderImpl extends ExpressionEvalMapFi
implements ExpressionEvalMapComponentsBuilder {

ExpressionEvalMapComponentsBuilderImpl() {
super();
}

@Override
Expand Down
Expand Up @@ -60,7 +60,6 @@ public final class ExpressionUtils {
private static final Log LOGGER = LogFactory.getLog(ExpressionUtils.class);

private ExpressionUtils() {
super();
}

/**
Expand Down

0 comments on commit 5ac262f

Please sign in to comment.