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

@@ -155,7 +155,7 @@ public abstract class AbstractStompSessionManager implements StompSessionManager
}
public long getRecoveryInterval() {
return recoveryInterval;
return this.recoveryInterval;
}
@Override
@@ -175,29 +175,29 @@ public abstract class AbstractStompSessionManager implements StompSessionManager
private synchronized void connect() {
if (this.connecting || this.connected) {
if (logger.isDebugEnabled()) {
logger.debug("Aborting connect; another thread is connecting.");
if (this.logger.isDebugEnabled()) {
this.logger.debug("Aborting connect; another thread is connecting.");
}
return;
}
final int epoch = this.epoch.get();
this.connecting = true;
if (logger.isDebugEnabled()) {
logger.debug("Connecting " + this);
if (this.logger.isDebugEnabled()) {
this.logger.debug("Connecting " + this);
}
try {
this.stompSessionListenableFuture = doConnect(this.compositeStompSessionHandler);
}
catch (Exception e) {
logger.error("doConnect() error for " + this, e);
this.logger.error("doConnect() error for " + this, e);
}
final CountDownLatch latch = new CountDownLatch(1);
this.stompSessionListenableFuture.addCallback(new ListenableFutureCallback<StompSession>() {
@Override
public void onFailure(Throwable e) {
if (logger.isDebugEnabled()) {
logger.debug("onFailure", e);
if (AbstractStompSessionManager.this.logger.isDebugEnabled()) {
AbstractStompSessionManager.this.logger.debug("onFailure", e);
}
latch.countDown();
if (epoch == AbstractStompSessionManager.this.epoch.get()) {
@@ -207,8 +207,8 @@ public abstract class AbstractStompSessionManager implements StompSessionManager
@Override
public void onSuccess(StompSession stompSession) {
if (logger.isDebugEnabled()) {
logger.debug("onSuccess");
if (AbstractStompSessionManager.this.logger.isDebugEnabled()) {
AbstractStompSessionManager.this.logger.debug("onSuccess");
}
AbstractStompSessionManager.this.connected = true;
AbstractStompSessionManager.this.connecting = false;
@@ -224,14 +224,14 @@ public abstract class AbstractStompSessionManager implements StompSessionManager
});
try {
if (!latch.await(10, TimeUnit.SECONDS)) {
logger.error("No response to connection attempt");
this.logger.error("No response to connection attempt");
if (epoch == this.epoch.get()) {
scheduleReconnect(null);
}
}
}
catch (InterruptedException e1) {
logger.error("Interrupted while waiting for connection attempt");
this.logger.error("Interrupted while waiting for connection attempt");
Thread.currentThread().interrupt();
}
}
@@ -239,7 +239,7 @@ public abstract class AbstractStompSessionManager implements StompSessionManager
private void scheduleReconnect(Throwable e) {
this.epoch.incrementAndGet();
this.connecting = this.connected = false;
logger.error("STOMP connect error for " + this, e);
this.logger.error("STOMP connect error for " + this, e);
if (this.applicationEventPublisher != null) {
this.applicationEventPublisher.publishEvent(
new StompConnectionFailedEvent(this, e));
@@ -290,8 +290,8 @@ public abstract class AbstractStompSessionManager implements StompSessionManager
public void start() {
synchronized (this.lifecycleMonitor) {
if (!isRunning()) {
if (logger.isInfoEnabled()) {
logger.info("Starting " + getClass().getSimpleName());
if (this.logger.isInfoEnabled()) {
this.logger.info("Starting " + getClass().getSimpleName());
}
connect();
this.running = true;
@@ -314,8 +314,8 @@ public abstract class AbstractStompSessionManager implements StompSessionManager
synchronized (this.lifecycleMonitor) {
if (isRunning()) {
this.running = false;
if (logger.isInfoEnabled()) {
logger.info("Stopping " + getClass().getSimpleName());
if (this.logger.isInfoEnabled()) {
this.logger.info("Stopping " + getClass().getSimpleName());
}
destroy();
}
@@ -340,15 +340,15 @@ public abstract class AbstractStompSessionManager implements StompSessionManager
}
protected StompHeaders getConnectHeaders() {
return connectHeaders;
return this.connectHeaders;
}
@Override
public String toString() {
return ObjectUtils.identityToString(this) +
" {connecting=" + connecting +
", connected=" + connected +
", name='" + name + '\'' +
" {connecting=" + this.connecting +
", connected=" + this.connected +
", name='" + this.name + '\'' +
'}';
}
@@ -395,7 +395,7 @@ public abstract class AbstractStompSessionManager implements StompSessionManager
@Override
public void handleTransportError(StompSession session, Throwable exception) {
logger.error("STOMP transport error for session: [" + session + "]", exception);
AbstractStompSessionManager.this.logger.error("STOMP transport error for session: [" + session + "]", exception);
this.session = null;
scheduleReconnect(exception);
synchronized (this.delegates) {

View File

@@ -51,23 +51,23 @@ public class StompReceiptEvent extends StompIntegrationEvent {
}
public String getDestination() {
return destination;
return this.destination;
}
public String getReceiptId() {
return receiptId;
return this.receiptId;
}
public StompCommand getStompCommand() {
return stompCommand;
return this.stompCommand;
}
public boolean isLost() {
return lost;
return this.lost;
}
public Message<?> getMessage() {
return message;
return this.message;
}
public void setMessage(Message<?> message) {
@@ -76,8 +76,8 @@ public class StompReceiptEvent extends StompIntegrationEvent {
@Override
public String toString() {
return "StompReceiptEvent [destination=" + destination + ", receiptId=" + receiptId + ", stompCommand="
+ stompCommand + ", lost=" + lost + ", message=" + message + "]";
return "StompReceiptEvent [destination=" + this.destination + ", receiptId=" + this.receiptId + ", stompCommand="
+ this.stompCommand + ", lost=" + this.lost + ", message=" + this.message + "]";
}
}

View File

@@ -218,7 +218,7 @@ public class StompInboundChannelAdapter extends MessageProducerSupport implement
@Override
public Type getPayloadType(StompHeaders headers) {
return payloadType;
return StompInboundChannelAdapter.this.payloadType;
}
@Override
@@ -229,7 +229,7 @@ public class StompInboundChannelAdapter extends MessageProducerSupport implement
}
else {
message = getMessageBuilderFactory().withPayload(body)
.copyHeaders(headerMapper.toHeaders(headers))
.copyHeaders(StompInboundChannelAdapter.this.headerMapper.toHeaders(headers))
.build();
}
sendMessage(message);
@@ -238,7 +238,8 @@ public class StompInboundChannelAdapter extends MessageProducerSupport implement
});
if (this.stompSessionManager.isAutoReceiptEnabled()) {
if (this.applicationEventPublisher != null) {
final ApplicationEventPublisher applicationEventPublisher = this.applicationEventPublisher;
if (applicationEventPublisher != null) {
subscription.addReceiptTask(new Runnable() {
@Override
@@ -280,7 +281,7 @@ public class StompInboundChannelAdapter extends MessageProducerSupport implement
@Override
public void afterConnected(StompSession session, StompHeaders connectedHeaders) {
StompInboundChannelAdapter.this.stompSession = session;
for (String destination : destinations) {
for (String destination : StompInboundChannelAdapter.this.destinations) {
subscribeDestination(destination);
}
}
@@ -288,12 +289,12 @@ public class StompInboundChannelAdapter extends MessageProducerSupport implement
@Override
public void handleException(StompSession session, StompCommand command, StompHeaders headers, byte[] payload,
Throwable exception) {
if (errorChannel != null) {
if (StompInboundChannelAdapter.this.errorChannel != null) {
StompHeaderAccessor headerAccessor = StompHeaderAccessor.create(command);
headerAccessor.copyHeaders(headerMapper.toHeaders(headers));
headerAccessor.copyHeaders(StompInboundChannelAdapter.this.headerMapper.toHeaders(headers));
Message<byte[]> failedMessage = MessageBuilder.createMessage(payload,
headerAccessor.getMessageHeaders());
getMessagingTemplate().send(errorChannel,
getMessagingTemplate().send(StompInboundChannelAdapter.this.errorChannel,
new ErrorMessage(new MessageHandlingException(failedMessage, exception)));
}
else {

View File

@@ -147,7 +147,8 @@ public class StompMessageHandler extends AbstractMessageHandler implements Appli
final StompSession.Receiptable receiptable = stompSession.send(stompHeaders, message.getPayload());
if (receiptable.getReceiptId() != null) {
final String destination = stompHeaders.getDestination();
if (this.applicationEventPublisher != null) {
final ApplicationEventPublisher applicationEventPublisher = this.applicationEventPublisher;
if (applicationEventPublisher != null) {
receiptable.addReceiptTask(new Runnable() {
@Override
@@ -238,13 +239,13 @@ public class StompMessageHandler extends AbstractMessageHandler implements Appli
}
if (thePayload != null) {
Message<?> failedMessage = getMessageBuilderFactory().withPayload(thePayload)
.copyHeaders(headerMapper.toHeaders(headers))
.copyHeaders(StompMessageHandler.this.headerMapper.toHeaders(headers))
.build();
MessagingException exception = new MessageDeliveryException(failedMessage,
"STOMP frame handling error.");
logger.error("STOMP frame handling error.", exception);
if (applicationEventPublisher != null) {
applicationEventPublisher.publishEvent(
if (StompMessageHandler.this.applicationEventPublisher != null) {
StompMessageHandler.this.applicationEventPublisher.publishEvent(
new StompExceptionEvent(StompMessageHandler.this, exception));
}
}