Sonar - protected fields

This commit is contained in:
Gary Russell
2019-05-01 16:18:58 -04:00
committed by Artem Bilan
parent 37e49a23f4
commit 0d6faa2e34
58 changed files with 278 additions and 261 deletions

View File

@@ -47,7 +47,7 @@ public class QueueChannel extends AbstractPollableChannel implements QueueChanne
private final Queue<Message<?>> queue;
protected final Semaphore queueSemaphore = new Semaphore(0);
protected final Semaphore queueSemaphore = new Semaphore(0); // NOSONAR final
/**
* Create a channel with the specified queue.

View File

@@ -39,7 +39,7 @@ import com.esotericsoftware.kryo.pool.KryoPool;
*/
public abstract class AbstractKryoCodec implements Codec {
protected final KryoPool pool;
protected final KryoPool pool; // NOSONAR final
protected AbstractKryoCodec() {
KryoFactory factory = () -> {
@@ -53,7 +53,7 @@ public abstract class AbstractKryoCodec implements Codec {
}
@Override
public void encode(final Object object, OutputStream outputStream) throws IOException {
public void encode(final Object object, OutputStream outputStream) {
Assert.notNull(object, "cannot encode a null object");
Assert.notNull(outputStream, "'outputSteam' cannot be null");
final Output output = (outputStream instanceof Output ? (Output) outputStream : new Output(outputStream));
@@ -77,7 +77,7 @@ public abstract class AbstractKryoCodec implements Codec {
}
@Override
public <T> T decode(InputStream inputStream, final Class<T> type) throws IOException {
public <T> T decode(InputStream inputStream, final Class<T> type) {
Assert.notNull(inputStream, "'inputStream' cannot be null");
Assert.notNull(type, "'type' cannot be null");
final Input input = (inputStream instanceof Input ? (Input) inputStream : new Input(inputStream));

View File

@@ -46,7 +46,7 @@ public abstract class AbstractIntegrationNamespaceHandler implements NamespaceHa
private static final String VERSION = "5.2";
protected final Log logger = LogFactory.getLog(this.getClass());
protected final Log logger = LogFactory.getLog(this.getClass()); // NOSONAR final
private final NamespaceHandlerDelegate delegate = new NamespaceHandlerDelegate();

View File

@@ -50,9 +50,9 @@ import org.springframework.util.Assert;
*/
public class ErrorMessagePublisher implements BeanFactoryAware {
protected final Log logger = LogFactory.getLog(getClass());
protected final Log logger = LogFactory.getLog(getClass()); // NOSONAR final
protected final MessagingTemplate messagingTemplate = new MessagingTemplate();
protected final MessagingTemplate messagingTemplate = new MessagingTemplate(); // NOSONAR final
private DestinationResolver<MessageChannel> channelResolver;

View File

@@ -43,7 +43,7 @@ import org.springframework.util.Assert;
*/
public abstract class AbstractDispatcher implements MessageDispatcher {
protected final Log logger = LogFactory.getLog(this.getClass());
protected final Log logger = LogFactory.getLog(getClass()); // NOSONAR final
private volatile int maxSubscribers = Integer.MAX_VALUE;

View File

@@ -65,7 +65,7 @@ public class RoundRobinLoadBalancingStrategy implements LoadBalancingStrategy {
return new Iterator<MessageHandler>() {
int currentIndex = 0;
private int currentIndex = 0;
public boolean hasNext() {
return this.currentIndex < reorderedHandlers.length;

View File

@@ -51,7 +51,7 @@ import reactor.util.function.Tuple2;
public abstract class ConsumerEndpointSpec<S extends ConsumerEndpointSpec<S, H>, H extends MessageHandler>
extends EndpointSpec<S, ConsumerEndpointFactoryBean, H> {
protected final List<Advice> adviceChain = new LinkedList<>();
protected final List<Advice> adviceChain = new LinkedList<>(); // NOSONAR final
protected ConsumerEndpointSpec(H messageHandler) {
super(messageHandler);

View File

@@ -47,11 +47,11 @@ public abstract class EndpointSpec<S extends EndpointSpec<S, F, H>, F extends Be
extends IntegrationComponentSpec<S, Tuple2<F, H>>
implements ComponentsRegistration {
protected final Map<Object, String> componentsToRegister = new LinkedHashMap<>();
protected final Map<Object, String> componentsToRegister = new LinkedHashMap<>(); // NOSONAR final
protected H handler;
protected H handler; // NOSONAR final
protected F endpointFactoryBean;
protected F endpointFactoryBean; // NOSONAR final
@SuppressWarnings("unchecked")
protected EndpointSpec(H handler) {

View File

@@ -32,28 +32,28 @@ import org.springframework.integration.dispatcher.RoundRobinLoadBalancingStrateg
public abstract class LoadBalancingChannelSpec<S extends MessageChannelSpec<S, C>, C extends AbstractMessageChannel>
extends MessageChannelSpec<S, C> {
protected LoadBalancingStrategy loadBalancingStrategy = new RoundRobinLoadBalancingStrategy();
protected LoadBalancingStrategy loadBalancingStrategy = new RoundRobinLoadBalancingStrategy(); // NOSONAR
protected Boolean failover;
protected Boolean failover; // NOSONAR
protected Integer maxSubscribers;
protected Integer maxSubscribers; // NOSONAR
protected LoadBalancingChannelSpec() {
super();
}
public S loadBalancer(LoadBalancingStrategy loadBalancingStrategy) {
this.loadBalancingStrategy = loadBalancingStrategy;
public S loadBalancer(LoadBalancingStrategy loadBalancingStrategyToSet) {
this.loadBalancingStrategy = loadBalancingStrategyToSet;
return _this();
}
public S failover(Boolean failover) {
this.failover = failover;
public S failover(Boolean failoverToSet) {
this.failover = failoverToSet;
return _this();
}
public S maxSubscribers(Integer maxSubscribers) {
this.maxSubscribers = maxSubscribers;
public S maxSubscribers(Integer maxSubscribersToSet) {
this.maxSubscribers = maxSubscribersToSet;
return _this();
}

View File

@@ -49,7 +49,7 @@ public abstract class MessageChannelSpec<S extends MessageChannelSpec<S, C>, C e
private final List<ChannelInterceptor> interceptors = new LinkedList<>();
protected C channel;
protected C channel; // NOSONAR
private MessageConverter messageConverter;

View File

@@ -31,9 +31,9 @@ import org.springframework.messaging.Message;
*/
public class QueueChannelSpec extends MessageChannelSpec<QueueChannelSpec, QueueChannel> {
protected Queue<Message<?>> queue;
protected Queue<Message<?>> queue; // NOSONAR
protected Integer capacity;
protected Integer capacity; // NOSONAR
QueueChannelSpec() {
super();
@@ -84,13 +84,13 @@ public class QueueChannelSpec extends MessageChannelSpec<QueueChannelSpec, Queue
}
public MessageStoreSpec capacity(Integer capacity) {
this.capacity = capacity;
public MessageStoreSpec capacity(Integer capacityToSet) {
this.capacity = capacityToSet;
return this;
}
public MessageStoreSpec storeLock(Lock storeLock) {
this.storeLock = storeLock;
public MessageStoreSpec storeLock(Lock storeLockToSet) {
this.storeLock = storeLockToSet;
return this;
}

View File

@@ -801,7 +801,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
private static final class MethodInvocationGateway extends MessagingGatewaySupport {
Expression receiveTimeoutExpression;
private Expression receiveTimeoutExpression;
MethodInvocationGateway(GatewayMethodInboundMessageMapper messageMapper) {
setRequestMapper(messageMapper);

View File

@@ -66,7 +66,7 @@ public abstract class AbstractHeaderMapper<T> implements RequestReplyHeaderMappe
private static final Collection<String> TRANSIENT_HEADER_NAMES = Arrays.asList(
MessageHeaders.ID, MessageHeaders.TIMESTAMP);
protected final Log logger = LogFactory.getLog(getClass());
protected final Log logger = LogFactory.getLog(getClass()); // NOSONAR final
private final String standardHeaderPrefix;

View File

@@ -40,7 +40,7 @@ import org.springframework.messaging.Message;
public abstract class AbstractMessageGroupStore extends AbstractBatchingMessageGroupStore
implements MessageGroupStore, Iterable<MessageGroup> {
protected final Log logger = LogFactory.getLog(getClass());
protected final Log logger = LogFactory.getLog(getClass()); // NOSONAR final
private final Collection<MessageGroupCallback> expiryCallbacks = new LinkedHashSet<>();

View File

@@ -29,6 +29,7 @@ import org.springframework.util.Assert;
* to a {@link org.springframework.messaging.Message} with the specified payload type.
*
* @author Artem Bilan
* @author Gary Russell
* @since 3.0
*
* @see JsonInboundMessageMapper
@@ -47,11 +48,11 @@ public abstract class AbstractJsonInboundMessageMapper<P> implements InboundMess
DEFAULT_HEADER_TYPES.put(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER, Integer.class);
}
protected final Type payloadType;
protected final Type payloadType; // NOSONAR final
protected final Map<String, Class<?>> headerTypes = DEFAULT_HEADER_TYPES;
protected final Map<String, Class<?>> headerTypes = DEFAULT_HEADER_TYPES; // NOSONAR final
protected volatile boolean mapToPayload = false;
private boolean mapToPayload = false;
public AbstractJsonInboundMessageMapper(Type payloadType) {
Assert.notNull(payloadType, "payloadType must not be null");
@@ -66,6 +67,10 @@ public abstract class AbstractJsonInboundMessageMapper<P> implements InboundMess
this.mapToPayload = mapToPayload;
}
public boolean isMapToPayload() {
return this.mapToPayload;
}
protected abstract Object readPayload(P parser, String jsonMessage);
protected abstract Map<String, Object> readHeaders(P parser, String jsonMessage);

View File

@@ -79,7 +79,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
*/
public class EmbeddedJsonHeadersMessageMapper implements BytesMessageMapper {
protected final Log logger = LogFactory.getLog(getClass());
protected final Log logger = LogFactory.getLog(getClass()); // NOSONAR final
private final ObjectMapper objectMapper;

View File

@@ -52,10 +52,6 @@ public class JsonInboundMessageMapper extends AbstractJsonInboundMessageMapper<J
this.messageParser = messageParser;
}
public boolean isMapToPayload() {
return mapToPayload;
}
public Type getPayloadType() {
return payloadType;
}

View File

@@ -29,11 +29,11 @@ import org.apache.commons.logging.LogFactory;
@SuppressWarnings("deprecation")
public abstract class AbstractMessageHandlerMetrics implements ConfigurableMetrics {
protected final Log logger = LogFactory.getLog(getClass());
protected final Log logger = LogFactory.getLog(getClass()); // NOSONAR final
protected final String name;
protected final String name; // NOSONAR final
private volatile boolean fullStatsEnabled;
private boolean fullStatsEnabled;
public AbstractMessageHandlerMetrics(String name) {
this.name = name;

View File

@@ -99,7 +99,7 @@ public class AggregatingMessageChannelMetrics extends DefaultMessageChannelMetri
protected static class AggregatingChannelMetricsContext extends DefaultChannelMetricsContext {
protected long newCount;
protected long newCount; // NOSONAR
public AggregatingChannelMetricsContext(long start, long newCount) {
super(start);

View File

@@ -37,21 +37,21 @@ public class DefaultMessageChannelMetrics extends AbstractMessageChannelMetrics
public static final int DEFAULT_MOVING_AVERAGE_WINDOW = 10;
protected final ExponentialMovingAverage sendDuration;
protected final ExponentialMovingAverage sendDuration; // NOSONAR final
protected final ExponentialMovingAverageRate sendErrorRate;
protected final ExponentialMovingAverageRate sendErrorRate; // NOSONAR final
protected final ExponentialMovingAverageRatio sendSuccessRatio;
protected final ExponentialMovingAverageRatio sendSuccessRatio; // NOSONAR final
protected final ExponentialMovingAverageRate sendRate;
protected final ExponentialMovingAverageRate sendRate; // NOSONAR final
protected final AtomicLong sendCount = new AtomicLong();
protected final AtomicLong sendCount = new AtomicLong(); // NOSONAR final
protected final AtomicLong sendErrorCount = new AtomicLong();
protected final AtomicLong sendErrorCount = new AtomicLong(); // NOSONAR final
protected final AtomicLong receiveCount = new AtomicLong();
protected final AtomicLong receiveCount = new AtomicLong(); // NOSONAR final
protected final AtomicLong receiveErrorCount = new AtomicLong();
protected final AtomicLong receiveErrorCount = new AtomicLong(); // NOSONAR final
public DefaultMessageChannelMetrics() {
this(null);
@@ -256,7 +256,7 @@ public class DefaultMessageChannelMetrics extends AbstractMessageChannelMetrics
protected static class DefaultChannelMetricsContext implements MetricsContext {
protected final long start;
protected final long start; // NOSONAR
protected DefaultChannelMetricsContext(long start) {
this.start = start;

View File

@@ -31,13 +31,13 @@ public class DefaultMessageHandlerMetrics extends AbstractMessageHandlerMetrics
private static final int DEFAULT_MOVING_AVERAGE_WINDOW = 10;
protected final AtomicLong activeCount = new AtomicLong();
protected final AtomicLong activeCount = new AtomicLong(); // NOSONAR final
protected final AtomicLong handleCount = new AtomicLong();
protected final AtomicLong handleCount = new AtomicLong(); // NOSONAR final
protected final AtomicLong errorCount = new AtomicLong();
protected final AtomicLong errorCount = new AtomicLong(); // NOSONAR final
protected final ExponentialMovingAverage duration;
protected final ExponentialMovingAverage duration; // NOSONAR final
public DefaultMessageHandlerMetrics() {
this(null);
@@ -153,7 +153,7 @@ public class DefaultMessageHandlerMetrics extends AbstractMessageHandlerMetrics
protected static class DefaultHandlerMetricsContext implements MetricsContext {
protected final long start;
protected final long start; // NOSONAR final
protected DefaultHandlerMetricsContext(long start) {
this.start = start;

View File

@@ -85,13 +85,13 @@ public interface IntegrationManagement extends DisposableBean {
*/
class ManagementOverrides {
public boolean loggingConfigured;
public boolean loggingConfigured; // NOSONAR
public boolean countsConfigured;
public boolean countsConfigured; // NOSONAR
public boolean statsConfigured;
public boolean statsConfigured; // NOSONAR
public boolean metricsConfigured;
public boolean metricsConfigured; // NOSONAR
}

View File

@@ -38,7 +38,7 @@ public class LifecycleMessageSourceMetrics implements MessageSourceMetrics, Life
private final Lifecycle lifecycle;
protected final MessageSourceMetrics delegate;
protected final MessageSourceMetrics delegate; // NOSONAR final
public LifecycleMessageSourceMetrics(Lifecycle lifecycle, MessageSourceMetrics delegate) {

View File

@@ -29,7 +29,7 @@ import org.springframework.transaction.support.ResourceHolderSynchronization;
public class IntegrationResourceHolderSynchronization
extends ResourceHolderSynchronization<IntegrationResourceHolder, Object> {
protected final IntegrationResourceHolder resourceHolder;
protected final IntegrationResourceHolder resourceHolder; // NOSONAR final
private boolean shouldUnbindAtCompletion = true;

View File

@@ -41,7 +41,7 @@ import org.springframework.util.Assert;
*/
public class SimplePool<T> implements Pool<T> {
protected final Log logger = LogFactory.getLog(this.getClass());
protected final Log logger = LogFactory.getLog(getClass()); // NOSONAR final
private final Semaphore permits = new Semaphore(0);

View File

@@ -26,12 +26,13 @@ import java.util.concurrent.TimeUnit;
* @author Mark Fisher
* @author Iwein Fuld
* @author Artem Bilan
* @author Gary Russell
*
* @since 2.0
*/
public final class UpperBound {
public final Semaphore semaphore;
private final Semaphore semaphore;
/**