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:
@@ -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.
|
||||
@@ -241,8 +241,8 @@ public abstract class AbstractMailReceiver extends IntegrationObjectSupport impl
|
||||
}
|
||||
}
|
||||
if (!this.store.isConnected()) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("connecting to store [" + MailTransportUtils.toPasswordProtectedString(this.url) + "]");
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("connecting to store [" + MailTransportUtils.toPasswordProtectedString(this.url) + "]");
|
||||
}
|
||||
this.store.connect();
|
||||
}
|
||||
@@ -263,8 +263,8 @@ public abstract class AbstractMailReceiver extends IntegrationObjectSupport impl
|
||||
if (this.folder.isOpen()) {
|
||||
return;
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("opening folder [" + MailTransportUtils.toPasswordProtectedString(this.url) + "]");
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("opening folder [" + MailTransportUtils.toPasswordProtectedString(this.url) + "]");
|
||||
}
|
||||
this.folder.open(this.folderOpenMode);
|
||||
}
|
||||
@@ -278,8 +278,8 @@ public abstract class AbstractMailReceiver extends IntegrationObjectSupport impl
|
||||
synchronized (this.folderMonitor) {
|
||||
try {
|
||||
this.openFolder();
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("attempting to receive mail from folder [" + this.getFolder().getFullName() + "]");
|
||||
if (this.logger.isInfoEnabled()) {
|
||||
this.logger.info("attempting to receive mail from folder [" + this.getFolder().getFullName() + "]");
|
||||
}
|
||||
Message[] messages = searchForNewMessages();
|
||||
if (this.maxFetchSize > 0 && messages.length > this.maxFetchSize) {
|
||||
@@ -287,15 +287,15 @@ public abstract class AbstractMailReceiver extends IntegrationObjectSupport impl
|
||||
System.arraycopy(messages, 0, reducedMessages, 0, this.maxFetchSize);
|
||||
messages = reducedMessages;
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("found " + messages.length + " new messages");
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("found " + messages.length + " new messages");
|
||||
}
|
||||
if (messages.length > 0) {
|
||||
fetchMessages(messages);
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Received " + messages.length + " messages");
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Received " + messages.length + " messages");
|
||||
}
|
||||
|
||||
Message[] filteredMessages = filterMessagesThruSelector(messages);
|
||||
@@ -334,8 +334,8 @@ public abstract class AbstractMailReceiver extends IntegrationObjectSupport impl
|
||||
for (Message message : filteredMessages) {
|
||||
if (!recentFlagSupported){
|
||||
if (flags != null && flags.contains(Flags.Flag.USER)){
|
||||
if (logger.isDebugEnabled()){
|
||||
logger.debug("USER flags are supported by this mail server. Flagging message with '"
|
||||
if (this.logger.isDebugEnabled()){
|
||||
this.logger.debug("USER flags are supported by this mail server. Flagging message with '"
|
||||
+ this.userFlag + "' user flag");
|
||||
}
|
||||
Flags siFlags = new Flags();
|
||||
@@ -343,8 +343,8 @@ public abstract class AbstractMailReceiver extends IntegrationObjectSupport impl
|
||||
message.setFlags(siFlags, true);
|
||||
}
|
||||
else {
|
||||
if (logger.isDebugEnabled()){
|
||||
logger.debug("USER flags are not supported by this mail server. "
|
||||
if (this.logger.isDebugEnabled()){
|
||||
this.logger.debug("USER flags are not supported by this mail server. "
|
||||
+ "Flagging message with system flag");
|
||||
}
|
||||
message.setFlag(Flags.Flag.FLAGGED, true);
|
||||
@@ -367,8 +367,8 @@ public abstract class AbstractMailReceiver extends IntegrationObjectSupport impl
|
||||
filteredMessages.add(message);
|
||||
}
|
||||
else {
|
||||
if (logger.isDebugEnabled()){
|
||||
logger.debug("Fetched email with subject '" + message.getSubject() + "' will be discarded by the matching filter" +
|
||||
if (this.logger.isDebugEnabled()){
|
||||
this.logger.debug("Fetched email with subject '" + message.getSubject() + "' will be discarded by the matching filter" +
|
||||
" and will not be flagged as SEEN.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -171,13 +171,13 @@ public class ImapIdleChannelAdapter extends MessageProducerSupport implements Be
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException(
|
||||
"Failure during the destruction of Mail receiver: " + mailReceiver, e);
|
||||
"Failure during the destruction of Mail receiver: " + this.mailReceiver, e);
|
||||
}
|
||||
/*
|
||||
* If we're running with the default executor, shut it down.
|
||||
*/
|
||||
if (!this.sendingTaskExecutorSet && this.sendingTaskExecutor != null) {
|
||||
((ExecutorService) sendingTaskExecutor).shutdown();
|
||||
((ExecutorService) this.sendingTaskExecutor).shutdown();
|
||||
this.sendingTaskExecutor = null;
|
||||
}
|
||||
}
|
||||
@@ -187,14 +187,14 @@ public class ImapIdleChannelAdapter extends MessageProducerSupport implements Be
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
idleTask.run();
|
||||
ImapIdleChannelAdapter.this.idleTask.run();
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Task completed successfully. Re-scheduling it again right away.");
|
||||
}
|
||||
}
|
||||
catch (Exception e) { //run again after a delay
|
||||
logger.warn("Failed to execute IDLE task. Will attempt to resubmit in " + reconnectDelay + " milliseconds.", e);
|
||||
receivingTaskTrigger.delayNextExecution();
|
||||
logger.warn("Failed to execute IDLE task. Will attempt to resubmit in " + ImapIdleChannelAdapter.this.reconnectDelay + " milliseconds.", e);
|
||||
ImapIdleChannelAdapter.this.receivingTaskTrigger.delayNextExecution();
|
||||
ImapIdleChannelAdapter.this.publishException(e);
|
||||
}
|
||||
}
|
||||
@@ -211,15 +211,15 @@ public class ImapIdleChannelAdapter extends MessageProducerSupport implements Be
|
||||
* The following shouldn't be necessary because doStart() will have ensured we have
|
||||
* one. But, just in case...
|
||||
*/
|
||||
Assert.state(sendingTaskExecutor != null, "'sendingTaskExecutor' must not be null");
|
||||
Assert.state(ImapIdleChannelAdapter.this.sendingTaskExecutor != null, "'sendingTaskExecutor' must not be null");
|
||||
|
||||
try {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("waiting for mail");
|
||||
}
|
||||
mailReceiver.waitForNewMessages();
|
||||
if (mailReceiver.getFolder().isOpen()) {
|
||||
Message[] mailMessages = mailReceiver.receive();
|
||||
ImapIdleChannelAdapter.this.mailReceiver.waitForNewMessages();
|
||||
if (ImapIdleChannelAdapter.this.mailReceiver.getFolder().isOpen()) {
|
||||
Message[] mailMessages = ImapIdleChannelAdapter.this.mailReceiver.receive();
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("received " + mailMessages.length + " mail messages");
|
||||
}
|
||||
@@ -227,7 +227,7 @@ public class ImapIdleChannelAdapter extends MessageProducerSupport implements Be
|
||||
|
||||
Runnable messageSendingTask = createMessageSendingTask(mailMessage);
|
||||
|
||||
sendingTaskExecutor.execute(messageSendingTask);
|
||||
ImapIdleChannelAdapter.this.sendingTaskExecutor.execute(messageSendingTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -235,7 +235,7 @@ public class ImapIdleChannelAdapter extends MessageProducerSupport implements Be
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("error occurred in idle task", e);
|
||||
}
|
||||
if (shouldReconnectAutomatically) {
|
||||
if (ImapIdleChannelAdapter.this.shouldReconnectAutomatically) {
|
||||
throw new IllegalStateException(
|
||||
"Failure in 'idle' task. Will resubmit.", e);
|
||||
}
|
||||
@@ -255,9 +255,10 @@ public class ImapIdleChannelAdapter extends MessageProducerSupport implements Be
|
||||
ImapIdleChannelAdapter.this.getMessageBuilderFactory().withPayload(mailMessage).build();
|
||||
|
||||
if (TransactionSynchronizationManager.isActualTransactionActive()) {
|
||||
if (transactionSynchronizationFactory != null){
|
||||
if (ImapIdleChannelAdapter.this.transactionSynchronizationFactory != null){
|
||||
TransactionSynchronization synchronization =
|
||||
transactionSynchronizationFactory.create(ImapIdleChannelAdapter.this);
|
||||
ImapIdleChannelAdapter.this.transactionSynchronizationFactory
|
||||
.create(ImapIdleChannelAdapter.this);
|
||||
TransactionSynchronizationManager.registerSynchronization(synchronization);
|
||||
if (synchronization instanceof IntegrationResourceHolderSynchronization) {
|
||||
IntegrationResourceHolder holder =
|
||||
@@ -271,14 +272,14 @@ public class ImapIdleChannelAdapter extends MessageProducerSupport implements Be
|
||||
};
|
||||
|
||||
// wrap in the TX proxy if necessary
|
||||
if (!CollectionUtils.isEmpty(adviceChain)) {
|
||||
if (!CollectionUtils.isEmpty(this.adviceChain)) {
|
||||
ProxyFactory proxyFactory = new ProxyFactory(sendingTask);
|
||||
if (!CollectionUtils.isEmpty(adviceChain)) {
|
||||
for (Advice advice : adviceChain) {
|
||||
if (!CollectionUtils.isEmpty(this.adviceChain)) {
|
||||
for (Advice advice : this.adviceChain) {
|
||||
proxyFactory.addAdvice(advice);
|
||||
}
|
||||
}
|
||||
sendingTask = (Runnable) proxyFactory.getProxy(classLoader);
|
||||
sendingTask = (Runnable) proxyFactory.getProxy(this.classLoader);
|
||||
}
|
||||
return sendingTask;
|
||||
}
|
||||
@@ -301,9 +302,9 @@ public class ImapIdleChannelAdapter extends MessageProducerSupport implements Be
|
||||
|
||||
@Override
|
||||
public Date nextExecutionTime(TriggerContext triggerContext) {
|
||||
if (delayNextExecution){
|
||||
delayNextExecution = false;
|
||||
return new Date(System.currentTimeMillis() + reconnectDelay);
|
||||
if (this.delayNextExecution){
|
||||
this.delayNextExecution = false;
|
||||
return new Date(System.currentTimeMillis() + ImapIdleChannelAdapter.this.reconnectDelay);
|
||||
}
|
||||
else {
|
||||
return new Date(System.currentTimeMillis());
|
||||
|
||||
@@ -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.
|
||||
@@ -96,7 +96,7 @@ public class ImapMailReceiver extends AbstractMailReceiver {
|
||||
* @return true if messages should be marked as read.
|
||||
*/
|
||||
public Boolean isShouldMarkMessagesAsRead() {
|
||||
return shouldMarkMessagesAsRead;
|
||||
return this.shouldMarkMessagesAsRead;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.
|
||||
@@ -43,7 +43,7 @@ public interface MailReceiver {
|
||||
}
|
||||
|
||||
Message[] getMessages() {
|
||||
return messages;
|
||||
return this.messages;
|
||||
}
|
||||
|
||||
void setMessages(Message[] messages) {
|
||||
@@ -52,7 +52,7 @@ public interface MailReceiver {
|
||||
}
|
||||
|
||||
Folder getFolder() {
|
||||
return folder;
|
||||
return this.folder;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -75,7 +75,7 @@ public class MailReceivingMessageSource implements MessageSource<javax.mail.Mess
|
||||
}
|
||||
|
||||
protected BeanFactory getBeanFactory() {
|
||||
return beanFactory;
|
||||
return this.beanFactory;
|
||||
}
|
||||
|
||||
protected MessageBuilderFactory getMessageBuilderFactory() {
|
||||
@@ -115,8 +115,8 @@ public class MailReceivingMessageSource implements MessageSource<javax.mail.Mess
|
||||
mailMessage = this.mailQueue.poll();
|
||||
}
|
||||
if (mailMessage != null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("received mail message [" + mailMessage + "]");
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("received mail message [" + mailMessage + "]");
|
||||
}
|
||||
return getMessageBuilderFactory().withPayload(mailMessage).build();
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -108,7 +108,7 @@ public class MailReceiverFactoryBean implements FactoryBean<MailReceiver>, Dispo
|
||||
}
|
||||
|
||||
public Boolean isShouldMarkMessagesAsRead() {
|
||||
return shouldMarkMessagesAsRead != null && shouldMarkMessagesAsRead;
|
||||
return this.shouldMarkMessagesAsRead != null && this.shouldMarkMessagesAsRead;
|
||||
}
|
||||
|
||||
public void setMaxFetchSize(int maxFetchSize) {
|
||||
@@ -194,14 +194,14 @@ public class MailReceiverFactoryBean implements FactoryBean<MailReceiver>, Dispo
|
||||
receiver.setShouldDeleteMessages(this.shouldDeleteMessages);
|
||||
}
|
||||
receiver.setMaxFetchSize(this.maxFetchSize);
|
||||
receiver.setSelectorExpression(selectorExpression);
|
||||
receiver.setSelectorExpression(this.selectorExpression);
|
||||
if (StringUtils.hasText(this.userFlag)) {
|
||||
receiver.setUserFlag(this.userFlag);
|
||||
}
|
||||
|
||||
if (isPop3) {
|
||||
if (this.isShouldMarkMessagesAsRead() && this.logger.isWarnEnabled()) {
|
||||
logger.warn("Setting 'should-mark-messages-as-read' to 'true' while using POP3 has no effect");
|
||||
this.logger.warn("Setting 'should-mark-messages-as-read' to 'true' while using POP3 has no effect");
|
||||
}
|
||||
}
|
||||
else if (isImap) {
|
||||
|
||||
@@ -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.
|
||||
@@ -893,7 +893,7 @@ public class ImapMailReceiverTests {
|
||||
|
||||
private boolean firstDone;
|
||||
|
||||
public TestReceiver() {
|
||||
TestReceiver() {
|
||||
setSearchTermStrategy(searchTermStrategy);
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ public class MessageWithContentTypeTests {
|
||||
}
|
||||
|
||||
private static class TestMimeMessage extends MimeMessage{
|
||||
public TestMimeMessage() {
|
||||
TestMimeMessage() {
|
||||
super(Session.getDefaultInstance(new Properties()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user