Code formatted according to checkstyle rules

pull/1923/head
Nikita Koksharov 6 years ago
parent 7126b0bef0
commit a5862933dc

@ -366,7 +366,11 @@
**/org/redisson/client/**/*.java, **/org/redisson/client/**/*.java,
**/org/redisson/cluster/**/*.java, **/org/redisson/cluster/**/*.java,
**/org/redisson/codec/**/*.java, **/org/redisson/codec/**/*.java,
**/org/redisson/command/**/*.java **/org/redisson/command/**/*.java,
**/org/redisson/config/**/*.java,
**/org/redisson/connection/**/*.java,
**/org/redisson/eviction/**/*.java,
**/org/redisson/executor/**/*.java,
</includes> </includes>
<consoleOutput>true</consoleOutput> <consoleOutput>true</consoleOutput>
<enableRSS>false</enableRSS> <enableRSS>false</enableRSS>

@ -256,7 +256,6 @@ public class Config {
this.connectionManager = connectionManager; this.connectionManager = connectionManager;
} }
/** /**
* Init single server configuration. * Init single server configuration.
* *
@ -415,6 +414,7 @@ public class Config {
this.transportMode = transportMode; this.transportMode = transportMode;
return this; return this;
} }
public TransportMode getTransportMode() { public TransportMode getTransportMode() {
return transportMode; return transportMode;
} }
@ -500,6 +500,7 @@ public class Config {
this.lockWatchdogTimeout = lockWatchdogTimeout; this.lockWatchdogTimeout = lockWatchdogTimeout;
return this; return this;
} }
public long getLockWatchdogTimeout() { public long getLockWatchdogTimeout() {
return lockWatchdogTimeout; return lockWatchdogTimeout;
} }
@ -519,6 +520,7 @@ public class Config {
this.keepPubSubOrder = keepPubSubOrder; this.keepPubSubOrder = keepPubSubOrder;
return this; return this;
} }
public boolean isKeepPubSubOrder() { public boolean isKeepPubSubOrder() {
return keepPubSubOrder; return keepPubSubOrder;
} }
@ -534,6 +536,7 @@ public class Config {
this.addressResolverGroupFactory = addressResolverGroupFactory; this.addressResolverGroupFactory = addressResolverGroupFactory;
return this; return this;
} }
public AddressResolverGroupFactory getAddressResolverGroupFactory() { public AddressResolverGroupFactory getAddressResolverGroupFactory() {
return addressResolverGroupFactory; return addressResolverGroupFactory;
} }
@ -713,6 +716,7 @@ public class Config {
this.useScriptCache = useScriptCache; this.useScriptCache = useScriptCache;
return this; return this;
} }
public boolean isUseScriptCache() { public boolean isUseScriptCache() {
return useScriptCache; return useScriptCache;
} }
@ -720,6 +724,7 @@ public class Config {
public boolean isDecodeInExecutor() { public boolean isDecodeInExecutor() {
return decodeInExecutor; return decodeInExecutor;
} }
/** /**
* Defines whether to decode data by <code>codec</code> in executor's threads or netty's threads. * Defines whether to decode data by <code>codec</code> in executor's threads or netty's threads.
* If decoding data process takes long time and netty thread is used then `RedisTimeoutException` could arise time to time. * If decoding data process takes long time and netty thread is used then `RedisTimeoutException` could arise time to time.

@ -16,7 +16,6 @@
package org.redisson.config; package org.redisson.config;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;

@ -18,9 +18,9 @@ package org.redisson.connection;
/** /**
* @author <a href="mailto:mpaluch@paluch.biz">Mark Paluch</a> * @author <a href="mailto:mpaluch@paluch.biz">Mark Paluch</a>
**/ **/
public class CRC16 { public final class CRC16 {
private static final int LOOKUP_TABLE[] = { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, private static final int[] LOOKUP_TABLE = { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6,
0x70E7, 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, 0x1231, 0x0210, 0x3273, 0x70E7, 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, 0x1231, 0x0210, 0x3273,
0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF,
0xE3DE, 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, 0xA56A, 0xB54B, 0x8528, 0xE3DE, 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, 0xA56A, 0xB54B, 0x8528,
@ -50,7 +50,7 @@ public class CRC16 {
int crc = 0x0000; int crc = 0x0000;
for (byte b : bytes) { for (byte b : bytes) {
crc = ((crc << 8) ^ LOOKUP_TABLE[((crc >>> 8) ^ (b & 0xFF)) & 0xFF]); crc = (crc << 8) ^ LOOKUP_TABLE[((crc >>> 8) ^ (b & 0xFF)) & 0xFF];
} }
return crc & 0xFFFF; return crc & 0xFFFF;
} }

@ -347,7 +347,7 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
} }
startDNSMonitoring(f.getNow()); startDNSMonitoring(f.getNow());
} catch (RuntimeException e) { } catch (Exception e) {
stopThreads(); stopThreads();
throw e; throw e;
} }
@ -555,9 +555,9 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
return RedissonPromise.newFailedFuture(ex); return RedissonPromise.newFailedFuture(ex);
} }
// fix for https://github.com/redisson/redisson/issues/1548 // fix for https://github.com/redisson/redisson/issues/1548
if (source.getRedirect() != null && if (source.getRedirect() != null
!URIBuilder.compare(entry.getClient().getAddr(), source.getAddr()) && && !URIBuilder.compare(entry.getClient().getAddr(), source.getAddr())
entry.hasSlave(source.getAddr())) { && entry.hasSlave(source.getAddr())) {
return entry.redirectedConnectionWriteOp(command, source.getAddr()); return entry.redirectedConnectionWriteOp(command, source.getAddr());
} }
return entry.connectionWriteOp(command); return entry.connectionWriteOp(command);

@ -156,6 +156,7 @@ public class LoadBalancerManager {
return freeze(connectionEntry, freezeReason); return freeze(connectionEntry, freezeReason);
} }
@SuppressWarnings("BooleanExpressionComplexity")
public ClientConnectionsEntry freeze(ClientConnectionsEntry connectionEntry, FreezeReason freezeReason) { public ClientConnectionsEntry freeze(ClientConnectionsEntry connectionEntry, FreezeReason freezeReason) {
if (connectionEntry == null || (connectionEntry.isFailed() if (connectionEntry == null || (connectionEntry.isFailed()
&& connectionEntry.getFreezeReason() == FreezeReason.RECONNECT && connectionEntry.getFreezeReason() == FreezeReason.RECONNECT
@ -169,8 +170,7 @@ public class LoadBalancerManager {
|| connectionEntry.getFreezeReason() == FreezeReason.RECONNECT || connectionEntry.getFreezeReason() == FreezeReason.RECONNECT
|| (freezeReason == FreezeReason.MANAGER || (freezeReason == FreezeReason.MANAGER
&& connectionEntry.getFreezeReason() != FreezeReason.MANAGER && connectionEntry.getFreezeReason() != FreezeReason.MANAGER
&& connectionEntry.getNodeType() == NodeType.SLAVE && connectionEntry.getNodeType() == NodeType.SLAVE)) {
)) {
connectionEntry.setFreezed(true); connectionEntry.setFreezed(true);
connectionEntry.setFreezeReason(freezeReason); connectionEntry.setFreezeReason(freezeReason);
return connectionEntry; return connectionEntry;

@ -15,18 +15,14 @@
*/ */
package org.redisson.connection.decoder; package org.redisson.connection.decoder;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.redisson.client.codec.LongCodec;
import org.redisson.client.handler.State; import org.redisson.client.handler.State;
import org.redisson.client.protocol.Decoder; import org.redisson.client.protocol.Decoder;
import org.redisson.client.protocol.decoder.MultiDecoder; import org.redisson.client.protocol.decoder.MultiDecoder;
import io.netty.buffer.ByteBuf;
/** /**
* *
* @author Nikita Koksharov * @author Nikita Koksharov

@ -19,7 +19,6 @@ import java.net.InetSocketAddress;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@ -63,7 +62,7 @@ abstract class ConnectionPool<T extends RedisConnection> {
final MasterSlaveEntry masterSlaveEntry; final MasterSlaveEntry masterSlaveEntry;
public ConnectionPool(MasterSlaveServersConfig config, ConnectionManager connectionManager, MasterSlaveEntry masterSlaveEntry) { ConnectionPool(MasterSlaveServersConfig config, ConnectionManager connectionManager, MasterSlaveEntry masterSlaveEntry) {
this.config = config; this.config = config;
this.masterSlaveEntry = masterSlaveEntry; this.masterSlaveEntry = masterSlaveEntry;
this.connectionManager = connectionManager; this.connectionManager = connectionManager;
@ -189,8 +188,8 @@ abstract class ConnectionPool<T extends RedisConnection> {
List<ClientConnectionsEntry> entriesCopy = new LinkedList<ClientConnectionsEntry>(entries); List<ClientConnectionsEntry> entriesCopy = new LinkedList<ClientConnectionsEntry>(entries);
for (Iterator<ClientConnectionsEntry> iterator = entriesCopy.iterator(); iterator.hasNext();) { for (Iterator<ClientConnectionsEntry> iterator = entriesCopy.iterator(); iterator.hasNext();) {
ClientConnectionsEntry entry = iterator.next(); ClientConnectionsEntry entry = iterator.next();
if (!((!entry.isFreezed() || entry.isMasterForRead()) && if (!((!entry.isFreezed() || entry.isMasterForRead())
tryAcquireConnection(entry))) { && tryAcquireConnection(entry))) {
iterator.remove(); iterator.remove();
} }
} }
@ -225,7 +224,7 @@ abstract class ConnectionPool<T extends RedisConnection> {
return acquireConnection(command, entry); return acquireConnection(command, entry);
} }
public static abstract class AcquireCallback<T> implements Runnable, BiConsumer<T, Throwable> { public abstract static class AcquireCallback<T> implements Runnable, BiConsumer<T, Throwable> {
} }

@ -50,6 +50,9 @@ import java.util.TreeSet;
* @author Contributions from Mads Henderson * @author Contributions from Mads Henderson
* @author Refactoring from CronTrigger to CronExpression by Aaron Craven * @author Refactoring from CronTrigger to CronExpression by Aaron Craven
*/ */
@SuppressWarnings({"EmptyStatement", "InnerAssignment", "ConstantName",
"BooleanExpressionComplexity", "NestedIfDepth", "ParenPad",
"MethodLength", "WhitespaceAfter", "SuperClone", "UnnecessaryParentheses"})
public final class CronExpression implements Serializable, Cloneable { public final class CronExpression implements Serializable, Cloneable {
private static final long serialVersionUID = 12423409423L; private static final long serialVersionUID = 12423409423L;
@ -1499,6 +1502,7 @@ public final class CronExpression implements Serializable, Cloneable {
} }
} }
@SuppressWarnings("VisibilityModifier")
class ValueSet { class ValueSet {
public int value; public int value;

@ -64,7 +64,7 @@ import io.netty.util.TimerTask;
*/ */
public class TasksRunnerService implements RemoteExecutorService { public class TasksRunnerService implements RemoteExecutorService {
private static final Map<HashValue, Codec> codecs = new LRUCacheMap<HashValue, Codec>(500, 0, 0); private static final Map<HashValue, Codec> CODECS = new LRUCacheMap<HashValue, Codec>(500, 0, 0);
private final Codec codec; private final Codec codec;
private final String name; private final String name;
@ -125,7 +125,7 @@ public class TasksRunnerService implements RemoteExecutorService {
RFuture<Void> future = asyncScheduledServiceAtFixed(params.getExecutorId(), params.getRequestId()).scheduleAtFixedRate(params); RFuture<Void> future = asyncScheduledServiceAtFixed(params.getExecutorId(), params.getRequestId()).scheduleAtFixedRate(params);
try { try {
executeRunnable(params); executeRunnable(params);
} catch (RuntimeException e) { } catch (Exception e) {
// cancel task if it throws an exception // cancel task if it throws an exception
future.cancel(true); future.cancel(true);
throw e; throw e;
@ -145,7 +145,7 @@ public class TasksRunnerService implements RemoteExecutorService {
} }
try { try {
executeRunnable(params, nextStartDate == null); executeRunnable(params, nextStartDate == null);
} catch (RuntimeException e) { } catch (Exception e) {
// cancel task if it throws an exception // cancel task if it throws an exception
if (future != null) { if (future != null) {
future.cancel(true); future.cancel(true);
@ -263,13 +263,13 @@ public class TasksRunnerService implements RemoteExecutorService {
ByteBuf stateBuf = Unpooled.wrappedBuffer(params.getState()); ByteBuf stateBuf = Unpooled.wrappedBuffer(params.getState());
try { try {
HashValue hash = new HashValue(Hash.hash128(classBodyBuf)); HashValue hash = new HashValue(Hash.hash128(classBodyBuf));
Codec classLoaderCodec = codecs.get(hash); Codec classLoaderCodec = CODECS.get(hash);
if (classLoaderCodec == null) { if (classLoaderCodec == null) {
RedissonClassLoader cl = new RedissonClassLoader(codec.getClassLoader()); RedissonClassLoader cl = new RedissonClassLoader(codec.getClassLoader());
cl.loadClass(params.getClassName(), params.getClassBody()); cl.loadClass(params.getClassName(), params.getClassBody());
classLoaderCodec = this.codec.getClass().getConstructor(ClassLoader.class).newInstance(cl); classLoaderCodec = this.codec.getClass().getConstructor(ClassLoader.class).newInstance(cl);
codecs.put(hash, classLoaderCodec); CODECS.put(hash, classLoaderCodec);
} }
T task; T task;

Loading…
Cancel
Save