Code formatted according to checkstyle rules

pull/1923/head
Nikita Koksharov 6 years ago
parent a5bb755deb
commit bd4c70ebd6

@ -373,6 +373,12 @@
**/org/redisson/executor/**/*.java,
**/org/redisson/jcache/**/*.java,
**/org/redisson/liveobject/**/*.java,
**/org/redisson/mapreduce/**/*.java,
**/org/redisson/misc/**/*.java,
**/org/redisson/pubsub/**/*.java,
**/org/redisson/reactive/**/*.java,
**/org/redisson/remote/**/*.java,
**/org/redisson/rx/**/*.java,
</includes>
<consoleOutput>true</consoleOutput>
<enableRSS>false</enableRSS>

@ -218,7 +218,7 @@ public class RedissonFairLock extends RedissonLock implements RLock {
"end; " +
"return 1; ",
Arrays.<Object>asList(getName(), threadsQueueName, timeoutSetName, getChannelName()),
LockPubSub.unlockMessage, internalLockLeaseTime, getLockName(threadId), System.currentTimeMillis());
LockPubSub.UNLOCK_MESSAGE, internalLockLeaseTime, getLockName(threadId), System.currentTimeMillis());
}
@Override
@ -296,7 +296,7 @@ public class RedissonFairLock extends RedissonLock implements RLock {
"end; " +
"return 0;",
Arrays.<Object>asList(getName(), threadsQueueName, timeoutSetName, getChannelName()),
LockPubSub.unlockMessage, System.currentTimeMillis());
LockPubSub.UNLOCK_MESSAGE, System.currentTimeMillis());
}
}

@ -421,7 +421,7 @@ public class RedissonLock extends RedissonExpirable implements RLock {
+ "else "
+ "return 0 "
+ "end",
Arrays.<Object>asList(getName(), getChannelName()), LockPubSub.unlockMessage);
Arrays.<Object>asList(getName(), getChannelName()), LockPubSub.UNLOCK_MESSAGE);
}
@Override
@ -486,7 +486,7 @@ public class RedissonLock extends RedissonExpirable implements RLock {
"return 1; "+
"end; " +
"return nil;",
Arrays.<Object>asList(getName(), getChannelName()), LockPubSub.unlockMessage, internalLockLeaseTime, getLockName(threadId));
Arrays.<Object>asList(getName(), getChannelName()), LockPubSub.UNLOCK_MESSAGE, internalLockLeaseTime, getLockName(threadId));
}

@ -129,7 +129,7 @@ public class RedissonReadLock extends RedissonLock implements RLock {
"redis.call('publish', KEYS[2], ARGV[1]); " +
"return 1; ",
Arrays.<Object>asList(getName(), getChannelName(), timeoutPrefix, keyPrefix),
LockPubSub.unlockMessage, getLockName(threadId));
LockPubSub.UNLOCK_MESSAGE, getLockName(threadId));
}
protected String getKeyPrefix(long threadId, String timeoutPrefix) {
@ -180,7 +180,7 @@ public class RedissonReadLock extends RedissonLock implements RLock {
"return 1; " +
"end; " +
"return 0; ",
Arrays.<Object>asList(getName(), getChannelName()), LockPubSub.unlockMessage);
Arrays.<Object>asList(getName(), getChannelName()), LockPubSub.UNLOCK_MESSAGE);
}
@Override

@ -107,7 +107,7 @@ public class RedissonWriteLock extends RedissonLock implements RLock {
"end; "
+ "return nil;",
Arrays.<Object>asList(getName(), getChannelName()),
LockPubSub.readUnlockMessage, internalLockLeaseTime, getLockName(threadId));
LockPubSub.READ_UNLOCK_MESSAGE, internalLockLeaseTime, getLockName(threadId));
}
@Override
@ -125,7 +125,7 @@ public class RedissonWriteLock extends RedissonLock implements RLock {
"return 1; " +
"end; " +
"return 0; ",
Arrays.<Object>asList(getName(), getChannelName()), LockPubSub.readUnlockMessage);
Arrays.<Object>asList(getName(), getChannelName()), LockPubSub.READ_UNLOCK_MESSAGE);
}
@Override

@ -60,7 +60,7 @@ abstract class MapReduceExecutor<M, VIn, KOut, VOut> implements RMapReduceExecut
M mapper;
long timeout;
public MapReduceExecutor(RObject object, RedissonClient redisson, ConnectionManager connectionManager) {
MapReduceExecutor(RObject object, RedissonClient redisson, ConnectionManager connectionManager) {
this.objectName = object.getName();
this.objectCodec = object.getCodec();
this.objectClass = object.getClass();

@ -25,7 +25,7 @@ import io.netty.util.CharsetUtil;
* @author Nikita Koksharov
*
*/
public class Hash {
public final class Hash {
private static final long[] KEY = {0x9e3779b97f4a7c15L, 0xf39cc0605cedc834L, 0x1082276bf3a27251L, 0xf86c6a11d0c18e95L};

@ -19,6 +19,7 @@ package org.redisson.misc;
* HighwayHash algorithm. See <a href="https://github.com/google/highwayhash">
* HighwayHash on GitHub</a>
*/
@SuppressWarnings({"OperatorWrap", "BooleanExpressionComplexity", "UnnecessaryParentheses", "WhitespaceAfter", "ParameterName", "LocalVariableName"})
public final class HighwayHash {
private final long[] v0 = new long[4];
private final long[] v1 = new long[4];

@ -25,6 +25,7 @@ import java.util.concurrent.locks.AbstractQueuedSynchronizer;
* @author Nikita Koksharov
*/
// TODO refactor to AbstractQueuedLongSynchronizer
@SuppressWarnings({"MultipleVariableDeclarations", "AvoidInlineConditionals", "UpperEll"})
public class InfinitySemaphoreLatch extends AbstractQueuedSynchronizer {
private static final long serialVersionUID = 1744280161777661090l;

@ -22,16 +22,15 @@ import org.redisson.client.protocol.CommandData;
import org.redisson.client.protocol.RedisCommands;
import io.netty.buffer.ByteBuf;
import io.netty.util.CharsetUtil;
/**
* @author Philipp Marx
*/
public class LogHelper {
public final class LogHelper {
private static final int MAX_COLLECTION_LOG_SIZE = Integer.valueOf(System.getProperty("redisson.maxCollectionLogSize", "10"));
private static final int MAX_STRING_LOG_SIZE = Integer.valueOf(System.getProperty("redisson.maxStringLogSize", "100"));
private static final int MAX_BYTEBUF_LOG_SIZE = Integer.valueOf(System.getProperty("redisson.maxByteBufLogSize", "1000"));
// private static final int MAX_BYTEBUF_LOG_SIZE = Integer.valueOf(System.getProperty("redisson.maxByteBufLogSize", "1000"));
private LogHelper() {
}

@ -42,13 +42,14 @@ public class ProxyBuilder {
Method method;
Class<?> instanceClass;
public CacheKey(Method method, Class<?> instanceClass) {
CacheKey(Method method, Class<?> instanceClass) {
super();
this.method = method;
this.instanceClass = instanceClass;
}
@Override
@SuppressWarnings("AvoidInlineConditionals")
public int hashCode() {
final int prime = 31;
int result = 1;
@ -81,14 +82,14 @@ public class ProxyBuilder {
}
private static final ConcurrentMap<CacheKey, Method> methodsMapping = new ConcurrentHashMap<CacheKey, Method>();
private static final ConcurrentMap<CacheKey, Method> METHODS_MAPPING = new ConcurrentHashMap<CacheKey, Method>();
public static <T> T create(final Callback commandExecutor, final Object instance, final Object implementation, final Class<T> clazz) {
InvocationHandler handler = new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, final Object[] args) throws Throwable {
CacheKey key = new CacheKey(method, instance.getClass());
Method instanceMethod = methodsMapping.get(key);
Method instanceMethod = METHODS_MAPPING.get(key);
if (instanceMethod == null) {
if (implementation != null) {
try {
@ -108,7 +109,7 @@ public class ProxyBuilder {
}
}
methodsMapping.put(key, instanceMethod);
METHODS_MAPPING.put(key, instanceMethod);
}
final Method mm = instanceMethod;
if (instanceMethod.getName().endsWith("Async")) {

@ -15,8 +15,6 @@
*/
package org.redisson.misc;
import java.util.function.BiConsumer;
import org.redisson.api.RFuture;
/**

@ -27,6 +27,7 @@ import java.util.concurrent.locks.AbstractQueuedSynchronizer;
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik@jboss.org</a>)
* @since 4.0
*/
@SuppressWarnings({"MultipleVariableDeclarations", "AvoidInlineConditionals", "UpperEll"})
public class ReclosableLatch extends AbstractQueuedSynchronizer {
private static final long serialVersionUID = 1744280161777661090l;

@ -34,12 +34,12 @@ import io.netty.util.concurrent.Promise;
*/
public class RedissonPromise<T> extends CompletableFuture<T> implements RPromise<T> {
private static final Field listenersField;
private static final Field LISTENERS_FIELD;
static {
try {
listenersField = DefaultPromise.class.getDeclaredField("listeners");
listenersField.setAccessible(true);
LISTENERS_FIELD = DefaultPromise.class.getDeclaredField("listeners");
LISTENERS_FIELD.setAccessible(true);
} catch (Exception e) {
throw new IllegalStateException(e);
}
@ -165,7 +165,7 @@ public class RedissonPromise<T> extends CompletableFuture<T> implements RPromise
@Override
public boolean hasListeners() {
try {
return listenersField.get(promise) != null || getNumberOfDependents() > 0;
return LISTENERS_FIELD.get(promise) != null || getNumberOfDependents() > 0;
} catch (Exception e) {
throw new IllegalStateException(e);
}

@ -33,7 +33,7 @@ public class AsyncSemaphore {
private Runnable runnable;
private int permits;
public Entry(Runnable runnable, int permits) {
Entry(Runnable runnable, int permits) {
super();
this.runnable = runnable;
this.permits = permits;
@ -48,6 +48,7 @@ public class AsyncSemaphore {
}
@Override
@SuppressWarnings("AvoidInlineConditionals")
public int hashCode() {
final int prime = 31;
int result = 1;

@ -25,8 +25,8 @@ import org.redisson.misc.RPromise;
*/
public class LockPubSub extends PublishSubscribe<RedissonLockEntry> {
public static final Long unlockMessage = 0L;
public static final Long readUnlockMessage = 1L;
public static final Long UNLOCK_MESSAGE = 0L;
public static final Long READ_UNLOCK_MESSAGE = 1L;
@Override
protected RedissonLockEntry createEntry(RPromise<RedissonLockEntry> newPromise) {
@ -35,14 +35,14 @@ public class LockPubSub extends PublishSubscribe<RedissonLockEntry> {
@Override
protected void onMessage(RedissonLockEntry value, Long message) {
if (message.equals(unlockMessage)) {
if (message.equals(UNLOCK_MESSAGE)) {
Runnable runnableToExecute = value.getListeners().poll();
if (runnableToExecute != null) {
runnableToExecute.run();
}
value.getLatch().release();
} else if (message.equals(readUnlockMessage)) {
} else if (message.equals(READ_UNLOCK_MESSAGE)) {
while (true) {
Runnable runnableToExecute = value.getListeners().poll();
if (runnableToExecute == null) {

@ -112,13 +112,13 @@ public class PubSubConnectionEntry {
Queue<RedisPubSubListener<?>> listeners = channelListeners.get(channelName);
for (RedisPubSubListener<?> listener : listeners) {
if (listener instanceof PubSubMessageListener) {
if (((PubSubMessageListener)listener).getListener() == msgListener) {
if (((PubSubMessageListener<?>) listener).getListener() == msgListener) {
removeListener(channelName, listener);
return true;
}
}
if (listener instanceof PubSubPatternMessageListener) {
if (((PubSubPatternMessageListener)listener).getListener() == msgListener) {
if (((PubSubPatternMessageListener<?>) listener).getListener() == msgListener) {
removeListener(channelName, listener);
return true;
}

@ -115,7 +115,7 @@ public class MapReactiveIterator<K, V, M> implements Consumer<FluxSink<M>> {
return false;
}
M getValue(final Entry<Object, Object> entry) {
M getValue(Entry<Object, Object> entry) {
return (M) new AbstractMap.SimpleEntry<K, V>((K) entry.getKey(), (V) entry.getValue()) {
@Override

@ -33,10 +33,10 @@ public class ReactiveProxyBuilder {
return create(commandExecutor, instance, null, clazz);
}
public static <T> T create(final CommandReactiveExecutor commandExecutor, Object instance, Object implementation, Class<T> clazz) {
public static <T> T create(CommandReactiveExecutor commandExecutor, Object instance, Object implementation, Class<T> clazz) {
return ProxyBuilder.create(new Callback() {
@Override
public Object execute(final Method mm, final Object instance, final Object[] args) {
public Object execute(Method mm, Object instance, Object[] args) {
return commandExecutor.reactive(new Supplier<RFuture<Object>>() {
@Override
public RFuture<Object> get() {

@ -15,10 +15,6 @@
*/
package org.redisson.reactive;
import java.util.List;
import java.util.function.Supplier;
import org.reactivestreams.Publisher;
import org.redisson.RedissonListMultimap;
import org.redisson.api.RList;
import org.redisson.api.RListMultimap;
@ -34,15 +30,17 @@ import org.redisson.client.codec.Codec;
*/
public class RedissonListMultimapReactive<K, V> {
private CommandReactiveExecutor commandExecutor;
private RedissonListMultimap<K, V> instance;
private final CommandReactiveExecutor commandExecutor;
private final RedissonListMultimap<K, V> instance;
public RedissonListMultimapReactive(CommandReactiveExecutor commandExecutor, String name) {
this.instance = new RedissonListMultimap<K, V>(commandExecutor, name);
this.commandExecutor = commandExecutor;
}
public RedissonListMultimapReactive(Codec codec, CommandReactiveExecutor commandExecutor, String name) {
this.instance = new RedissonListMultimap<K, V>(codec, commandExecutor, name);
this.commandExecutor = commandExecutor;
}
public RListReactive<V> get(K key) {

@ -17,16 +17,12 @@ package org.redisson.reactive;
import java.util.Map;
import java.util.Map.Entry;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
import org.reactivestreams.Publisher;
import org.redisson.RedissonMap;
import org.redisson.api.RMapCache;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
/**
*

@ -17,9 +17,6 @@ package org.redisson.reactive;
import java.util.Map;
import java.util.Map.Entry;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
import org.reactivestreams.Publisher;
import org.redisson.RedissonMap;
@ -31,7 +28,6 @@ import org.redisson.api.RSemaphoreReactive;
import org.redisson.api.RedissonReactiveClient;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
/**
* Distributed and concurrent implementation of {@link java.util.concurrent.ConcurrentMap}

@ -70,10 +70,10 @@ public class RedissonScoredSortedSetReactive<V> {
});
}
private Flux<V> scanIteratorReactive(final String pattern, final int count) {
private Flux<V> scanIteratorReactive(String pattern, int count) {
return Flux.create(new SetReactiveIterator<V>() {
@Override
protected RFuture<ListScanResult<Object>> scanIterator(final RedisClient client, final long nextIterPos) {
protected RFuture<ListScanResult<Object>> scanIterator(RedisClient client, long nextIterPos) {
return ((RedissonScoredSortedSet<V>) instance).scanIteratorAsync(client, nextIterPos, pattern, count);
}
});

@ -15,12 +15,6 @@
*/
package org.redisson.reactive;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.function.Supplier;
import org.reactivestreams.Publisher;
import org.redisson.RedissonSetCache;
import org.redisson.ScanIterator;
@ -34,9 +28,7 @@ import org.redisson.api.RedissonReactiveClient;
import org.redisson.client.RedisClient;
import org.redisson.client.protocol.decoder.ListScanResult;
import io.netty.buffer.ByteBuf;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
/**
*

@ -15,12 +15,6 @@
*/
package org.redisson.reactive;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.function.Supplier;
import org.reactivestreams.Publisher;
import org.redisson.RedissonSet;
import org.redisson.api.RFuture;
@ -69,7 +63,7 @@ public class RedissonSetReactive<V> {
return iterator(pattern, 10);
}
public Publisher<V> iterator(final String pattern, final int count) {
public Publisher<V> iterator(String pattern, int count) {
return Flux.create(new SetReactiveIterator<V>() {
@Override
protected RFuture<ListScanResult<Object>> scanIterator(RedisClient client, long nextIterPos) {

@ -15,8 +15,6 @@
*/
package org.redisson.remote;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -51,6 +49,7 @@ public class RemoteServiceKey {
}
@Override
@SuppressWarnings("AvoidInlineConditionals")
public int hashCode() {
final int prime = 31;
int result = 1;
@ -76,7 +75,7 @@ public class RemoteServiceKey {
return false;
} else if (!signatures.equals(other.signatures)) {
return false;
} if (serviceInterface == null) {
} else if (serviceInterface == null) {
if (other.serviceInterface != null)
return false;
} else if (!serviceInterface.equals(other.serviceInterface))

@ -20,7 +20,6 @@ import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentLinkedQueue;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscription;
import org.redisson.api.BatchOptions;
import org.redisson.api.BatchResult;
import org.redisson.api.RFuture;

@ -15,10 +15,7 @@
*/
package org.redisson.rx;
import java.util.concurrent.Callable;
import org.redisson.RedissonBlockingDeque;
import org.redisson.api.RFuture;
import io.reactivex.Flowable;

@ -15,10 +15,7 @@
*/
package org.redisson.rx;
import java.util.concurrent.Callable;
import org.redisson.api.RBlockingQueueAsync;
import org.redisson.api.RFuture;
import org.redisson.api.RListAsync;
import io.reactivex.Flowable;

@ -35,7 +35,6 @@ import io.reactivex.processors.ReplayProcessor;
public class RedissonKeysRx {
private final CommandRxExecutor commandExecutor;
private final RedissonKeys instance;
public RedissonKeysRx(CommandRxExecutor commandExecutor) {

@ -46,10 +46,10 @@ public class RedissonLexSortedSetRx {
}.addAll(c);
}
private Flowable<String> scanIteratorReactive(final String pattern, final int count) {
private Flowable<String> scanIteratorReactive(String pattern, int count) {
return new SetRxIterator<String>() {
@Override
protected RFuture<ListScanResult<Object>> scanIterator(final RedisClient client, final long nextIterPos) {
protected RFuture<ListScanResult<Object>> scanIterator(RedisClient client, long nextIterPos) {
return ((RedissonScoredSortedSet<String>)instance).scanIteratorAsync(client, nextIterPos, pattern, count);
}
}.create();

@ -30,15 +30,17 @@ import org.redisson.client.codec.Codec;
*/
public class RedissonListMultimapRx<K, V> {
private CommandRxExecutor commandExecutor;
private RedissonListMultimap<K, V> instance;
private final CommandRxExecutor commandExecutor;
private final RedissonListMultimap<K, V> instance;
public RedissonListMultimapRx(CommandRxExecutor commandExecutor, String name) {
this.instance = new RedissonListMultimap<K, V>(commandExecutor, name);
this.commandExecutor = commandExecutor;
}
public RedissonListMultimapRx(Codec codec, CommandRxExecutor commandExecutor, String name) {
this.instance = new RedissonListMultimap<K, V>(codec, commandExecutor, name);
this.commandExecutor = commandExecutor;
}
public RListRx<V> get(K key) {

@ -40,7 +40,7 @@ import org.redisson.api.RedissonRxClient;
public class RedissonMapRx<K, V> {
private final RedissonMap<K, V> instance;
private RedissonRxClient redisson;
private final RedissonRxClient redisson;
public RedissonMapRx(RMap<K, V> instance, RedissonRx redisson) {
this.instance = (RedissonMap<K, V>) instance;

@ -17,6 +17,7 @@ package org.redisson.rx;
import org.redisson.RedissonScoredSortedSet;
import org.redisson.api.RFuture;
import org.redisson.api.RObject;
import org.redisson.api.RScoredSortedSetAsync;
import org.redisson.client.RedisClient;
import org.redisson.client.protocol.decoder.ListScanResult;
@ -37,10 +38,10 @@ public class RedissonScoredSortedSetRx<V> {
this.instance = instance;
}
private Flowable<V> scanIteratorReactive(final String pattern, final int count) {
private Flowable<V> scanIteratorReactive(String pattern, int count) {
return new SetRxIterator<V>() {
@Override
protected RFuture<ListScanResult<Object>> scanIterator(final RedisClient client, final long nextIterPos) {
protected RFuture<ListScanResult<Object>> scanIterator(RedisClient client, long nextIterPos) {
return ((RedissonScoredSortedSet<V>) instance).scanIteratorAsync(client, nextIterPos, pattern, count);
}
}.create();
@ -59,7 +60,7 @@ public class RedissonScoredSortedSetRx<V> {
}
public String getName() {
return ((RedissonScoredSortedSet<V>)instance).getName();
return ((RObject) instance).getName();
}
public Flowable<V> iterator() {

@ -63,7 +63,7 @@ public class RedissonSetRx<V> {
return iterator(pattern, 10);
}
public Flowable<V> iterator(final String pattern, final int count) {
public Flowable<V> iterator(String pattern, int count) {
return new SetRxIterator<V>() {
@Override
protected RFuture<ListScanResult<Object>> scanIterator(RedisClient client, long nextIterPos) {

Loading…
Cancel
Save