RequireThis rule and fixThis Gradle task

* `gradlew clean check -x test --parallel --continue` - to collect reports
* `gradlew fixThis --parallel` - to fix all possible vulnerabilities. With `-Dfile.encoding=UTF-8` on Windows

Since the `RequireThisCheck` doesn't see parents for anonymous classes (e.g. `Runnable` callback), its report doesn't contains the outer class name with `this.`,
therefore we still have to fix those cases manually.
Thanks to the wrong `replacer` just with `this.` we have uncompilable code enough easy to find problems.
Not so easy to fix for good readability though...

* Upgrade to Grade 2.12
* Upgrade to SonarQube native plugin

The fix contains at about 300 files. So, will be done on merge.

Fix `fixThis.gradle` according PR comments

Apply `fixThis` and also `fixModifiers` for test classes.
 Fix some `this.` inner issues manually.
 Make code polishing for long lines after `fixThis`

Fix conflicts and vulnerabilities after the rebase
This commit is contained in:
Artem Bilan
2016-03-17 17:02:15 -04:00
parent e189307ab6
commit 2b0598291c
348 changed files with 1828 additions and 1781 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@@ -114,7 +114,7 @@ public class ChannelPublishingJmsMessageListener
}
public void setRequestChannelName(String requestChannelName) {
gatewayDelegate.setRequestChannelName(requestChannelName);
this.gatewayDelegate.setRequestChannelName(requestChannelName);
}
public void setReplyChannel(MessageChannel replyChannel) {
@@ -122,7 +122,7 @@ public class ChannelPublishingJmsMessageListener
}
public void setReplyChannelName(String replyChannelName) {
gatewayDelegate.setReplyChannelName(replyChannelName);
this.gatewayDelegate.setReplyChannelName(replyChannelName);
}
public void setErrorChannel(MessageChannel errorChannel) {
@@ -130,7 +130,7 @@ public class ChannelPublishingJmsMessageListener
}
public void setErrorChannelName(String errorChannelName) {
gatewayDelegate.setErrorChannelName(errorChannelName);
this.gatewayDelegate.setErrorChannelName(errorChannelName);
}
public void setRequestTimeout(long requestTimeout) {
@@ -314,13 +314,13 @@ public class ChannelPublishingJmsMessageListener
try {
if (this.extractRequestPayload) {
result = this.messageConverter.fromMessage(jmsMessage);
if (logger.isDebugEnabled()) {
logger.debug("converted JMS Message [" + jmsMessage + "] to integration Message payload ["
if (this.logger.isDebugEnabled()) {
this.logger.debug("converted JMS Message [" + jmsMessage + "] to integration Message payload ["
+ result + "]");
}
}
Map<String, Object> headers = headerMapper.toHeaders(jmsMessage);
Map<String, Object> headers = this.headerMapper.toHeaders(jmsMessage);
requestMessage = (result instanceof Message<?>) ?
this.messageBuilderFactory.fromMessage((Message<?>) result).copyHeaders(headers).build() :
this.messageBuilderFactory.withPayload(result).copyHeaders(headers).build();
@@ -341,8 +341,8 @@ public class ChannelPublishingJmsMessageListener
Message<?> replyMessage = this.gatewayDelegate.sendAndReceiveMessage(requestMessage);
if (replyMessage != null) {
Destination destination = this.getReplyDestination(jmsMessage, session);
if (logger.isDebugEnabled()) {
logger.debug("Reply destination: " + destination);
if (this.logger.isDebugEnabled()) {
this.logger.debug("Reply destination: " + destination);
}
if (destination != null) {
// convert SI Message to JMS Message
@@ -353,18 +353,18 @@ public class ChannelPublishingJmsMessageListener
try {
javax.jms.Message jmsReply = this.messageConverter.toMessage(replyResult, session);
// map SI Message Headers to JMS Message Properties/Headers
headerMapper.fromHeaders(replyMessage.getHeaders(), jmsReply);
this.headerMapper.fromHeaders(replyMessage.getHeaders(), jmsReply);
this.copyCorrelationIdFromRequestToReply(jmsMessage, jmsReply);
this.sendReply(jmsReply, destination, session);
}
catch (RuntimeException e) {
logger.error("Failed to generate JMS Reply Message from: " + replyResult, e);
this.logger.error("Failed to generate JMS Reply Message from: " + replyResult, e);
throw e;
}
}
}
else if (logger.isDebugEnabled()) {
logger.debug("expected a reply but none was received");
else if (this.logger.isDebugEnabled()) {
this.logger.debug("expected a reply but none was received");
}
}
}
@@ -398,8 +398,8 @@ public class ChannelPublishingJmsMessageListener
if (value != null) {
replyMessage.setStringProperty(this.correlationKey, value);
}
else if (logger.isWarnEnabled()) {
logger.warn("No property value available on request Message for correlationKey '"
else if (this.logger.isWarnEnabled()) {
this.logger.warn("No property value available on request Message for correlationKey '"
+ this.correlationKey + "'");
}
}
@@ -511,7 +511,7 @@ public class ChannelPublishingJmsMessageListener
@Override
public String getComponentType() {
if (expectReply) {
if (ChannelPublishingJmsMessageListener.this.expectReply) {
return "jms:inbound-gateway";
}
else {

View File

@@ -119,7 +119,7 @@ public class DefaultJmsHeaderMapper implements JmsHeaderMapper {
jmsMessage.setJMSCorrelationID((String) jmsCorrelationId);
}
catch (Exception e) {
logger.info("failed to set JMSCorrelationID, skipping", e);
this.logger.info("failed to set JMSCorrelationID, skipping", e);
}
}
Object jmsReplyTo = headers.get(JmsHeaders.REPLY_TO);
@@ -128,7 +128,7 @@ public class DefaultJmsHeaderMapper implements JmsHeaderMapper {
jmsMessage.setJMSReplyTo((Destination) jmsReplyTo);
}
catch (Exception e) {
logger.info("failed to set JMSReplyTo, skipping", e);
this.logger.info("failed to set JMSReplyTo, skipping", e);
}
}
Object jmsType = headers.get(JmsHeaders.TYPE);
@@ -137,7 +137,7 @@ public class DefaultJmsHeaderMapper implements JmsHeaderMapper {
jmsMessage.setJMSType((String) jmsType);
}
catch (Exception e) {
logger.info("failed to set JMSType, skipping", e);
this.logger.info("failed to set JMSType, skipping", e);
}
}
for (Entry<String, Object> entry : headers.entrySet()) {
@@ -154,13 +154,13 @@ public class DefaultJmsHeaderMapper implements JmsHeaderMapper {
catch (Exception e) {
if (headerName.startsWith("JMSX")
|| headerName.equals(IntegrationMessageHeaderAccessor.PRIORITY)) {
if (logger.isTraceEnabled()) {
logger.trace("skipping reserved header, it cannot be set by client: "
if (this.logger.isTraceEnabled()) {
this.logger.trace("skipping reserved header, it cannot be set by client: "
+ headerName);
}
}
else if (logger.isWarnEnabled()) {
logger.warn("failed to map Message header '" + headerName + "' to JMS property", e);
else if (this.logger.isWarnEnabled()) {
this.logger.warn("failed to map Message header '" + headerName + "' to JMS property", e);
}
}
}
@@ -173,8 +173,8 @@ public class DefaultJmsHeaderMapper implements JmsHeaderMapper {
}
}
catch (Exception e) {
if (logger.isWarnEnabled()) {
logger.warn("error occurred while mapping from MessageHeaders to JMS properties", e);
if (this.logger.isWarnEnabled()) {
this.logger.warn("error occurred while mapping from MessageHeaders to JMS properties", e);
}
}
}
@@ -190,7 +190,7 @@ public class DefaultJmsHeaderMapper implements JmsHeaderMapper {
}
}
catch (Exception e) {
logger.info("failed to read JMSMessageID property, skipping", e);
this.logger.info("failed to read JMSMessageID property, skipping", e);
}
try {
Destination destination = jmsMessage.getJMSDestination();
@@ -199,7 +199,7 @@ public class DefaultJmsHeaderMapper implements JmsHeaderMapper {
}
}
catch (Exception ex) {
logger.info("failed to read JMSDestination property, skipping", ex);
this.logger.info("failed to read JMSDestination property, skipping", ex);
}
try {
String correlationId = jmsMessage.getJMSCorrelationID();
@@ -208,7 +208,7 @@ public class DefaultJmsHeaderMapper implements JmsHeaderMapper {
}
}
catch (Exception e) {
logger.info("failed to read JMSCorrelationID property, skipping", e);
this.logger.info("failed to read JMSCorrelationID property, skipping", e);
}
try {
Destination replyTo = jmsMessage.getJMSReplyTo();
@@ -217,13 +217,13 @@ public class DefaultJmsHeaderMapper implements JmsHeaderMapper {
}
}
catch (Exception e) {
logger.info("failed to read JMSReplyTo property, skipping", e);
this.logger.info("failed to read JMSReplyTo property, skipping", e);
}
try {
headers.put(JmsHeaders.REDELIVERED, jmsMessage.getJMSRedelivered());
}
catch (Exception e) {
logger.info("failed to read JMSRedelivered property, skipping", e);
this.logger.info("failed to read JMSRedelivered property, skipping", e);
}
try {
String type = jmsMessage.getJMSType();
@@ -232,20 +232,20 @@ public class DefaultJmsHeaderMapper implements JmsHeaderMapper {
}
}
catch (Exception e) {
logger.info("failed to read JMSType property, skipping", e);
this.logger.info("failed to read JMSType property, skipping", e);
}
try {
headers.put(JmsHeaders.TIMESTAMP, jmsMessage.getJMSTimestamp());
}
catch (Exception e) {
logger.info("failed to read JMSTimestamp property, skipping", e);
this.logger.info("failed to read JMSTimestamp property, skipping", e);
}
if (this.mapInboundPriority) {
try {
headers.put(IntegrationMessageHeaderAccessor.PRIORITY, jmsMessage.getJMSPriority());
}
catch (Exception e) {
logger.info("failed to read JMSPriority property, skipping", e);
this.logger.info("failed to read JMSPriority property, skipping", e);
}
}
Enumeration<?> jmsPropertyNames = jmsMessage.getPropertyNames();
@@ -257,8 +257,8 @@ public class DefaultJmsHeaderMapper implements JmsHeaderMapper {
headers.put(headerName, jmsMessage.getObjectProperty(propertyName));
}
catch (Exception e) {
if (logger.isWarnEnabled()) {
logger.warn("error occurred while mapping JMS property '"
if (this.logger.isWarnEnabled()) {
this.logger.warn("error occurred while mapping JMS property '"
+ propertyName + "' to Message header", e);
}
}
@@ -266,8 +266,8 @@ public class DefaultJmsHeaderMapper implements JmsHeaderMapper {
}
}
catch (JMSException e) {
if (logger.isWarnEnabled()) {
logger.warn("error occurred while mapping from JMS properties to MessageHeaders", e);
if (this.logger.isWarnEnabled()) {
this.logger.warn("error occurred while mapping from JMS properties to MessageHeaders", e);
}
}
return headers;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@@ -112,7 +112,7 @@ public class JmsMessageDrivenEndpoint extends AbstractEndpoint implements Dispos
this.listenerContainer.setSessionAcknowledgeMode(acknowledgeMode);
}
}
listener.setComponentName(this.getComponentName());
this.listener.setComponentName(this.getComponentName());
}
@Override

View File

@@ -768,7 +768,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
javax.jms.Message jmsRequest = this.messageConverter.toMessage(objectToSend, session);
// map headers
headerMapper.fromHeaders(requestMessage.getHeaders(), jmsRequest);
this.headerMapper.fromHeaders(requestMessage.getHeaders(), jmsRequest);
jmsRequest.setJMSReplyTo(replyTo);
connection.start();
@@ -824,7 +824,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
javax.jms.Message jmsRequest = this.messageConverter.toMessage(objectToSend, session);
// map headers
headerMapper.fromHeaders(requestMessage.getHeaders(), jmsRequest);
this.headerMapper.fromHeaders(requestMessage.getHeaders(), jmsRequest);
replyTo = this.determineReplyDestination(requestMessage, session);
jmsRequest.setJMSReplyTo(replyTo);
@@ -1122,7 +1122,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
}
private javax.jms.Message receiveReplyMessage(MessageConsumer messageConsumer) throws JMSException {
return (this.receiveTimeout >= 0) ? messageConsumer.receive(receiveTimeout) : messageConsumer.receive();
return (this.receiveTimeout >= 0) ? messageConsumer.receive(this.receiveTimeout) : messageConsumer.receive();
}
/**
@@ -1315,11 +1315,11 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
}
private long getTimeStamp() {
return timeStamp;
return this.timeStamp;
}
private javax.jms.Message getReply() {
return reply;
return this.reply;
}
}
@@ -1330,7 +1330,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
if (logger.isTraceEnabled()) {
logger.trace("Running late reply reaper");
}
Iterator<Entry<String, TimedReply>> lateReplyIterator = earlyOrLateReplies.entrySet().iterator();
Iterator<Entry<String, TimedReply>> lateReplyIterator = JmsOutboundGateway.this.earlyOrLateReplies.entrySet().iterator();
long now = System.currentTimeMillis();
long expired = now - (JmsOutboundGateway.this.receiveTimeout * 2);
while (lateReplyIterator.hasNext()) {
@@ -1355,15 +1355,15 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
@Override
public void run() {
synchronized(JmsOutboundGateway.this.lifeCycleMonitor) {
if (System.currentTimeMillis() - lastSend > idleReplyContainerTimeout
&& replies.size() == 0) {
if (replyContainer.isRunning()) {
if (System.currentTimeMillis() - JmsOutboundGateway.this.lastSend > JmsOutboundGateway.this.idleReplyContainerTimeout
&& JmsOutboundGateway.this.replies.size() == 0) {
if (JmsOutboundGateway.this.replyContainer.isRunning()) {
if (logger.isDebugEnabled()) {
logger.debug(getComponentName() + ": Stopping idle reply container.");
}
replyContainer.stop();
idleTask.cancel(false);
idleTask = null;
JmsOutboundGateway.this.replyContainer.stop();
JmsOutboundGateway.this.idleTask.cancel(false);
JmsOutboundGateway.this.idleTask = null;
}
}
}
@@ -1398,7 +1398,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
private volatile Executor taskExecutor;
public String getSessionAcknowledgeModeName() {
return sessionAcknowledgeModeName;
return this.sessionAcknowledgeModeName;
}
public void setSessionAcknowledgeModeName(String sessionAcknowledgeModeName) {
@@ -1406,7 +1406,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
}
public Boolean isSessionTransacted() {
return sessionTransacted;
return this.sessionTransacted;
}
public void setSessionTransacted(Boolean sessionTransacted) {
@@ -1414,7 +1414,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
}
public Integer getSessionAcknowledgeMode() {
return sessionAcknowledgeMode;
return this.sessionAcknowledgeMode;
}
public void setSessionAcknowledgeMode(Integer sessionAcknowledgeMode) {
@@ -1422,7 +1422,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
}
public Long getReceiveTimeout() {
return receiveTimeout;
return this.receiveTimeout;
}
public void setReceiveTimeout(Long receiveTimeout) {
@@ -1430,7 +1430,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
}
public Long getRecoveryInterval() {
return recoveryInterval;
return this.recoveryInterval;
}
public void setRecoveryInterval(Long recoveryInterval) {
@@ -1438,7 +1438,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
}
public Integer getCacheLevel() {
return cacheLevel;
return this.cacheLevel;
}
public void setCacheLevel(Integer cacheLevel) {
@@ -1446,7 +1446,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
}
public Integer getConcurrentConsumers() {
return concurrentConsumers;
return this.concurrentConsumers;
}
public void setConcurrentConsumers(Integer concurrentConsumers) {
@@ -1454,7 +1454,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
}
public Integer getMaxConcurrentConsumers() {
return maxConcurrentConsumers;
return this.maxConcurrentConsumers;
}
public void setMaxConcurrentConsumers(Integer maxConcurrentConsumers) {
@@ -1462,7 +1462,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
}
public Integer getMaxMessagesPerTask() {
return maxMessagesPerTask;
return this.maxMessagesPerTask;
}
public void setMaxMessagesPerTask(Integer maxMessagesPerTask) {
@@ -1470,7 +1470,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
}
public Integer getIdleConsumerLimit() {
return idleConsumerLimit;
return this.idleConsumerLimit;
}
public void setIdleConsumerLimit(Integer idleConsumerLimit) {
@@ -1478,7 +1478,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
}
public Integer getIdleTaskExecutionLimit() {
return idleTaskExecutionLimit;
return this.idleTaskExecutionLimit;
}
public void setIdleTaskExecutionLimit(Integer idleTaskExecutionLimit) {
@@ -1490,7 +1490,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
}
public Executor getTaskExecutor() {
return taskExecutor;
return this.taskExecutor;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -158,7 +158,7 @@ public class SubscribableJmsChannel extends AbstractJmsChannel implements Subscr
this.dispatcher.dispatch(messageToSend);
}
else if (this.logger.isWarnEnabled()) {
logger.warn("MessageConverter returned null, no Message to dispatch");
this.logger.warn("MessageConverter returned null, no Message to dispatch");
}
}
catch (MessageDispatchingException e) {
@@ -166,8 +166,8 @@ public class SubscribableJmsChannel extends AbstractJmsChannel implements Subscr
+ this.channel.getFullChannelName() + "'.";
if (this.isPubSub) {
// log only for backwards compatibility with pub/sub
if (logger.isWarnEnabled()) {
logger.warn(exceptionMessage, e);
if (this.logger.isWarnEnabled()) {
this.logger.warn(exceptionMessage, e);
}
}
else {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2016 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.
@@ -96,7 +96,7 @@ public class InboundOneWayErrorTests {
@SuppressWarnings("serial")
private static class TestException extends RuntimeException {
public TestException(String message) {
TestException(String message) {
super(message);
}
}