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-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.
|
||||
@@ -139,7 +139,7 @@ public class SubscribableRedisChannel extends AbstractMessageChannel implements
|
||||
if (this.messageConverter instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) this.messageConverter).setBeanFactory(this.getBeanFactory());
|
||||
}
|
||||
this.container.setConnectionFactory(connectionFactory);
|
||||
this.container.setConnectionFactory(this.connectionFactory);
|
||||
if (!(this.taskExecutor instanceof ErrorHandlingTaskExecutor)) {
|
||||
ErrorHandler errorHandler = new MessagePublishingErrorHandler(
|
||||
new BeanFactoryChannelResolver(this.getBeanFactory()));
|
||||
@@ -147,9 +147,9 @@ public class SubscribableRedisChannel extends AbstractMessageChannel implements
|
||||
}
|
||||
this.container.setTaskExecutor(this.taskExecutor);
|
||||
MessageListenerAdapter adapter = new MessageListenerAdapter(new MessageListenerDelegate());
|
||||
adapter.setSerializer(serializer);
|
||||
adapter.setSerializer(this.serializer);
|
||||
adapter.afterPropertiesSet();
|
||||
this.container.addMessageListener(adapter, new ChannelTopic(topicName));
|
||||
this.container.addMessageListener(adapter, new ChannelTopic(this.topicName));
|
||||
this.container.afterPropertiesSet();
|
||||
this.dispatcher.setBeanFactory(this.getBeanFactory());
|
||||
this.initialized = true;
|
||||
@@ -206,9 +206,9 @@ public class SubscribableRedisChannel extends AbstractMessageChannel implements
|
||||
|
||||
@SuppressWarnings({ "unused", "unchecked" })
|
||||
public void handleMessage(String s) {
|
||||
Message<?> siMessage = messageConverter.toMessage(s, null);
|
||||
Message<?> siMessage = SubscribableRedisChannel.this.messageConverter.toMessage(s, null);
|
||||
try {
|
||||
dispatcher.dispatch(siMessage);
|
||||
SubscribableRedisChannel.this.dispatcher.dispatch(siMessage);
|
||||
}
|
||||
catch (MessageDispatchingException e) {
|
||||
String topicName = SubscribableRedisChannel.this.topicName;
|
||||
|
||||
@@ -197,7 +197,7 @@ public class RedisQueueInboundGateway extends MessagingGatewaySupport implements
|
||||
}
|
||||
String uuid = null;
|
||||
if (value != null) {
|
||||
if (!active) {
|
||||
if (!this.active) {
|
||||
this.boundListOperations.rightPush(value);
|
||||
return;
|
||||
}
|
||||
@@ -211,7 +211,7 @@ public class RedisQueueInboundGateway extends MessagingGatewaySupport implements
|
||||
}
|
||||
Message<Object> requestMessage = null;
|
||||
if (value != null) {
|
||||
if (!active) {
|
||||
if (!this.active) {
|
||||
this.template.boundListOps(uuid).rightPush(value);
|
||||
this.boundListOperations.rightPush(stringSerializer.serialize(uuid));
|
||||
return;
|
||||
@@ -235,11 +235,11 @@ public class RedisQueueInboundGateway extends MessagingGatewaySupport implements
|
||||
if (replyMessage != null) {
|
||||
if (this.extractPayload) {
|
||||
if (!(replyMessage.getPayload() instanceof byte[])) {
|
||||
if (replyMessage.getPayload() instanceof String && !serializerExplicitlySet) {
|
||||
if (replyMessage.getPayload() instanceof String && !this.serializerExplicitlySet) {
|
||||
value = stringSerializer.serialize((String) replyMessage.getPayload());
|
||||
}
|
||||
else {
|
||||
value = ((RedisSerializer<Object>) serializer).serialize(replyMessage.getPayload());
|
||||
value = ((RedisSerializer<Object>) this.serializer).serialize(replyMessage.getPayload());
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -248,7 +248,7 @@ public class RedisQueueInboundGateway extends MessagingGatewaySupport implements
|
||||
}
|
||||
else {
|
||||
if (this.serializer != null) {
|
||||
value = ((RedisSerializer<Object>) serializer).serialize(replyMessage);
|
||||
value = ((RedisSerializer<Object>) this.serializer).serialize(replyMessage);
|
||||
}
|
||||
}
|
||||
this.template.boundListOps(uuid + QUEUE_NAME_SUFFIX).leftPush(value);
|
||||
|
||||
@@ -306,7 +306,7 @@ public class RedisQueueMessageDrivenEndpoint extends MessageProducerSupport impl
|
||||
}
|
||||
|
||||
public boolean isListening() {
|
||||
return listening;
|
||||
return this.listening;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.
|
||||
@@ -152,7 +152,7 @@ public class RedisStoreMessageSource extends IntegrationObjectSupport
|
||||
}
|
||||
|
||||
public RedisStore getResource() {
|
||||
return resourceHolder.get();
|
||||
return this.resourceHolder.get();
|
||||
}
|
||||
|
||||
public void afterCommit(Object object) {
|
||||
|
||||
@@ -87,7 +87,7 @@ public class RedisPublishingMessageHandler extends AbstractMessageHandler {
|
||||
|
||||
@Override
|
||||
protected void onInit() throws Exception {
|
||||
Assert.notNull(topicExpression, "'topicExpression' must not be null.");
|
||||
Assert.notNull(this.topicExpression, "'topicExpression' must not be null.");
|
||||
if (this.messageConverter instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) this.messageConverter).setBeanFactory(getBeanFactory());
|
||||
}
|
||||
|
||||
@@ -96,11 +96,11 @@ public class RedisQueueOutboundGateway extends AbstractReplyProducingMessageHand
|
||||
value = message.getPayload();
|
||||
}
|
||||
if (!(value instanceof byte[])) {
|
||||
if (value instanceof String && !serializerExplicitlySet) {
|
||||
if (value instanceof String && !this.serializerExplicitlySet) {
|
||||
value = stringSerializer.serialize((String) value);
|
||||
}
|
||||
else {
|
||||
value = ((RedisSerializer<Object>) serializer).serialize(value);
|
||||
value = ((RedisSerializer<Object>) this.serializer).serialize(value);
|
||||
}
|
||||
}
|
||||
String uuid = defaultIdGenerator.generateId().toString();
|
||||
@@ -109,7 +109,7 @@ public class RedisQueueOutboundGateway extends AbstractReplyProducingMessageHand
|
||||
this.boundListOps.leftPush(uuidByte);
|
||||
this.template.boundListOps(uuid).leftPush(value);
|
||||
|
||||
BoundListOperations<String, Object> boundListOperations = template.boundListOps(uuid + QUEUE_NAME_SUFFIX);
|
||||
BoundListOperations<String, Object> boundListOperations = this.template.boundListOps(uuid + QUEUE_NAME_SUFFIX);
|
||||
byte[] reply = (byte[]) boundListOperations.rightPop(this.receiveTimeout, TimeUnit.MILLISECONDS);
|
||||
if (reply != null && reply.length > 0) {
|
||||
Object replyMessage = this.serializer.deserialize(reply);
|
||||
|
||||
@@ -258,19 +258,19 @@ public class RedisStoreWritingMessageHandler extends AbstractMessageHandler {
|
||||
|
||||
Assert.state(this.initialized, "handler not initialized - afterPropertiesSet() must be called before the first use");
|
||||
try {
|
||||
if (collectionType == CollectionType.ZSET) {
|
||||
if (this.collectionType == CollectionType.ZSET) {
|
||||
this.writeToZset((RedisZSet<Object>) store, message);
|
||||
}
|
||||
else if (collectionType == CollectionType.SET) {
|
||||
else if (this.collectionType == CollectionType.SET) {
|
||||
this.writeToSet((RedisSet<Object>) store, message);
|
||||
}
|
||||
else if (collectionType == CollectionType.LIST) {
|
||||
else if (this.collectionType == CollectionType.LIST) {
|
||||
this.writeToList((RedisList<Object>) store, message);
|
||||
}
|
||||
else if (collectionType == CollectionType.MAP) {
|
||||
else if (this.collectionType == CollectionType.MAP) {
|
||||
this.writeToMap((RedisMap<Object, Object>) store, message);
|
||||
}
|
||||
else if (collectionType == CollectionType.PROPERTIES) {
|
||||
else if (this.collectionType == CollectionType.PROPERTIES) {
|
||||
this.writeToProperties((RedisProperties) store, message);
|
||||
}
|
||||
}
|
||||
@@ -400,14 +400,14 @@ public class RedisStoreWritingMessageHandler extends AbstractMessageHandler {
|
||||
|
||||
private void processInPipeline(PipelineCallback callback) {
|
||||
RedisConnection connection =
|
||||
RedisConnectionUtils.bindConnection(redisTemplate.getConnectionFactory());
|
||||
RedisConnectionUtils.bindConnection(this.redisTemplate.getConnectionFactory());
|
||||
try {
|
||||
connection.openPipeline();
|
||||
callback.process();
|
||||
}
|
||||
finally {
|
||||
connection.closePipeline();
|
||||
RedisConnectionUtils.unbindConnection(redisTemplate.getConnectionFactory());
|
||||
RedisConnectionUtils.unbindConnection(this.redisTemplate.getConnectionFactory());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ public class RedisStoreWritingMessageHandler extends AbstractMessageHandler {
|
||||
this.doIncrementOrOverwrite(ops, object, score, zsetIncrementScore);
|
||||
}
|
||||
else {
|
||||
logger.debug("Zset Score could not be determined. Using default score of 1");
|
||||
this.logger.debug("Zset Score could not be determined. Using default score of 1");
|
||||
this.doIncrementOrOverwrite(ops, object, Double.valueOf(1), zsetIncrementScore);
|
||||
}
|
||||
}
|
||||
@@ -448,8 +448,8 @@ public class RedisStoreWritingMessageHandler extends AbstractMessageHandler {
|
||||
private boolean verifyAllMapValuesOfTypeNumber(Map<?,?> map) {
|
||||
for (Object value : map.values()) {
|
||||
if (!(value instanceof Number)) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("failed to extract payload elements because '" +
|
||||
if (this.logger.isWarnEnabled()) {
|
||||
this.logger.warn("failed to extract payload elements because '" +
|
||||
value + "' is not of type Number");
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -58,7 +58,7 @@ public class RedisMessageStore extends AbstractKeyValueMessageStore {
|
||||
@Override
|
||||
protected Object doRetrieve(Object id){
|
||||
Assert.notNull(id, "'id' must not be null");
|
||||
BoundValueOperations<Object, Object> ops = redisTemplate.boundValueOps(id);
|
||||
BoundValueOperations<Object, Object> ops = this.redisTemplate.boundValueOps(id);
|
||||
return ops.get();
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class RedisMessageStore extends AbstractKeyValueMessageStore {
|
||||
protected void doStore(Object id, Object objectToStore) {
|
||||
Assert.notNull(id, "'id' must not be null");
|
||||
Assert.notNull(objectToStore, "'objectToStore' must not be null");
|
||||
BoundValueOperations<Object, Object> ops = redisTemplate.boundValueOps(id);
|
||||
BoundValueOperations<Object, Object> ops = this.redisTemplate.boundValueOps(id);
|
||||
try {
|
||||
ops.set(objectToStore);
|
||||
}
|
||||
@@ -84,7 +84,7 @@ public class RedisMessageStore extends AbstractKeyValueMessageStore {
|
||||
Assert.notNull(id, "'id' must not be null");
|
||||
Object removedObject = this.doRetrieve(id);
|
||||
if (removedObject != null){
|
||||
redisTemplate.delete(id);
|
||||
this.redisTemplate.delete(id);
|
||||
}
|
||||
return removedObject;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class RedisMessageStore extends AbstractKeyValueMessageStore {
|
||||
@Override
|
||||
protected Collection<?> doListKeys(String keyPattern) {
|
||||
Assert.hasText(keyPattern, "'keyPattern' must not be empty");
|
||||
Set<Object> keys = redisTemplate.keys(keyPattern);
|
||||
Set<Object> keys = this.redisTemplate.keys(keyPattern);
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
* Copyright 2014-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.
|
||||
@@ -283,12 +283,12 @@ public final class RedisLockRegistry implements LockRegistry {
|
||||
|
||||
@Override
|
||||
public Collection<Lock> doInRedis(RedisConnection connection) throws DataAccessException {
|
||||
Set<byte[]> keys = connection.keys((registryKey + ":*").getBytes());
|
||||
Set<byte[]> keys = connection.keys((RedisLockRegistry.this.registryKey + ":*").getBytes());
|
||||
ArrayList<Lock> list = new ArrayList<Lock>(keys.size());
|
||||
if (keys.size() > 0) {
|
||||
List<byte[]> locks = connection.mGet(keys.toArray(new byte[keys.size()][]));
|
||||
for (byte[] lock : locks) {
|
||||
list.add(lockSerializer.deserialize(lock));
|
||||
list.add(RedisLockRegistry.this.lockSerializer.deserialize(lock));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
@@ -316,12 +316,12 @@ public final class RedisLockRegistry implements LockRegistry {
|
||||
}
|
||||
|
||||
private String getLockKey() {
|
||||
return lockKey;
|
||||
return this.lockKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lock() {
|
||||
Lock localLock = RedisLockRegistry.this.localRegistry.obtain(lockKey);
|
||||
Lock localLock = RedisLockRegistry.this.localRegistry.obtain(this.lockKey);
|
||||
localLock.lock();
|
||||
try {
|
||||
while (true) {
|
||||
@@ -348,7 +348,7 @@ public final class RedisLockRegistry implements LockRegistry {
|
||||
|
||||
@Override
|
||||
public void lockInterruptibly() throws InterruptedException {
|
||||
Lock localLock = RedisLockRegistry.this.localRegistry.obtain(lockKey);
|
||||
Lock localLock = RedisLockRegistry.this.localRegistry.obtain(this.lockKey);
|
||||
localLock.lockInterruptibly();
|
||||
try {
|
||||
while (!this.obtainLock()) {
|
||||
@@ -367,7 +367,7 @@ public final class RedisLockRegistry implements LockRegistry {
|
||||
|
||||
@Override
|
||||
public boolean tryLock() {
|
||||
Lock localLock = RedisLockRegistry.this.localRegistry.obtain(lockKey);
|
||||
Lock localLock = RedisLockRegistry.this.localRegistry.obtain(this.lockKey);
|
||||
try {
|
||||
if (!localLock.tryLock()) {
|
||||
return false;
|
||||
@@ -448,7 +448,7 @@ public final class RedisLockRegistry implements LockRegistry {
|
||||
|
||||
@Override
|
||||
public boolean tryLock(long time, TimeUnit unit) throws InterruptedException {
|
||||
Lock localLock = RedisLockRegistry.this.localRegistry.obtain(lockKey);
|
||||
Lock localLock = RedisLockRegistry.this.localRegistry.obtain(this.lockKey);
|
||||
if (!localLock.tryLock(time, unit)) {
|
||||
return false;
|
||||
}
|
||||
@@ -494,7 +494,7 @@ public final class RedisLockRegistry implements LockRegistry {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
Lock localLock = RedisLockRegistry.this.localRegistry.obtain(lockKey);
|
||||
Lock localLock = RedisLockRegistry.this.localRegistry.obtain(this.lockKey);
|
||||
localLock.unlock();
|
||||
}
|
||||
}
|
||||
@@ -532,10 +532,10 @@ public final class RedisLockRegistry implements LockRegistry {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + getOuterType().hashCode();
|
||||
result = prime * result + Arrays.hashCode(lockHost);
|
||||
result = prime * result + ((lockKey == null) ? 0 : lockKey.hashCode());
|
||||
result = prime * result + (int) (lockedAt ^ (lockedAt >>> 32));
|
||||
result = prime * result + ((threadName == null) ? 0 : threadName.hashCode());
|
||||
result = prime * result + Arrays.hashCode(this.lockHost);
|
||||
result = prime * result + ((this.lockKey == null) ? 0 : this.lockKey.hashCode());
|
||||
result = prime * result + (int) (this.lockedAt ^ (this.lockedAt >>> 32));
|
||||
result = prime * result + ((this.threadName == null) ? 0 : this.threadName.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -554,21 +554,21 @@ public final class RedisLockRegistry implements LockRegistry {
|
||||
if (!getOuterType().equals(other.getOuterType())) {
|
||||
return false;
|
||||
}
|
||||
if (!Arrays.equals(lockHost, other.lockHost)) {
|
||||
if (!Arrays.equals(this.lockHost, other.lockHost)) {
|
||||
return false;
|
||||
}
|
||||
if (!lockKey.equals(other.lockKey)) {
|
||||
if (!this.lockKey.equals(other.lockKey)) {
|
||||
return false;
|
||||
}
|
||||
if (lockedAt != other.lockedAt) {
|
||||
if (this.lockedAt != other.lockedAt) {
|
||||
return false;
|
||||
}
|
||||
if (threadName == null) {
|
||||
if (this.threadName == null) {
|
||||
if (other.threadName != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!threadName.equals(other.threadName)) {
|
||||
else if (!this.threadName.equals(other.threadName)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -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.
|
||||
@@ -562,7 +562,7 @@ public class RedisStoreWritingMessageHandlerTests extends RedisAvailableTests{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String name;
|
||||
|
||||
public President(String name) {
|
||||
President(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user