Code formatted according to checkstyle rules

pull/1923/head
Nikita Koksharov 6 years ago
parent 062f642299
commit b47e2303b0

@ -19,7 +19,7 @@
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<!--
@ -49,6 +49,7 @@
-->
<module name="Checker">
<property name="charset" value="UTF-8"/>
<!-- Checks whether files end with a new line. -->
<!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
@ -170,7 +171,7 @@
<module name="SimplifyBooleanReturn"/>
<module name="StringLiteralEquality"/>
<module name="NestedIfDepth">
<property name="max" value="2"/>
<property name="max" value="3"/>
</module>
<module name="NestedTryDepth"/>
<module name="SuperClone"/>
@ -187,7 +188,6 @@
<!--module name="DesignForExtension"/-->
<module name="FinalClass"/>
<!--module name="HideUtilityClassConstructor"/-->
<module name="InterfaceIsType"/>
<module name="VisibilityModifier">
<property name="packageAllowed" value="true"/>
</module>
@ -216,6 +216,7 @@
<!--module name="TodoComment"/-->
<module name="UpperEll"/>
<module name="BooleanExpressionComplexity"/>
</module>
</module>

@ -360,7 +360,7 @@
</execution>
</executions>
<configuration>
<includes>**/org/redisson/api/**/*.java,**/org/redisson/cache/**/*.java</includes>
<includes>**/org/redisson/api/**/*.java,**/org/redisson/cache/**/*.java,**/org/redisson/client/**/*.java</includes>
<consoleOutput>true</consoleOutput>
<enableRSS>false</enableRSS>
<configLocation>/checkstyle.xml</configLocation>

@ -58,7 +58,7 @@ import io.netty.util.concurrent.FutureListener;
* @author Nikita Koksharov
*
*/
public class RedisClient {
public final class RedisClient {
private final AtomicReference<RFuture<InetSocketAddress>> resolvedAddrFuture = new AtomicReference<RFuture<InetSocketAddress>>();
private final Bootstrap bootstrap;

@ -46,7 +46,7 @@ public class RedisConnection implements RedisCommands {
private static final AttributeKey<RedisConnection> CONNECTION = AttributeKey.valueOf("connection");
protected final RedisClient redisClient;
final RedisClient redisClient;
private volatile RPromise<Void> fastReconnect;
private volatile boolean closed;
@ -97,10 +97,10 @@ public class RedisConnection implements RedisCommands {
return (C) channel.attr(RedisConnection.CONNECTION).get();
}
public CommandData getCurrentCommand() {
public CommandData<?, ?> getCurrentCommand() {
QueueCommand command = channel.attr(CommandsQueue.CURRENT_COMMAND).get();
if (command instanceof CommandData) {
return (CommandData)command;
return (CommandData<?, ?>) command;
}
return null;
}

@ -99,7 +99,7 @@ public class RedisPubSubConnection extends RedisConnection {
async(new PubSubPatternMessageDecoder(codec.getValueDecoder()), RedisCommands.PSUBSCRIBE, channels);
}
public void unsubscribe(final ChannelName... channels) {
public void unsubscribe(ChannelName... channels) {
synchronized (this) {
for (ChannelName ch : channels) {
this.channels.remove(ch);
@ -145,7 +145,7 @@ public class RedisPubSubConnection extends RedisConnection {
}
}
public void punsubscribe(final ChannelName... channels) {
public void punsubscribe(ChannelName... channels) {
synchronized (this) {
for (ChannelName ch : channels) {
patternChannels.remove(ch);

@ -15,6 +15,9 @@
*/
package org.redisson.client.codec;
import java.util.Arrays;
import java.util.List;
import org.redisson.cache.LocalCachedMessageCodec;
import org.redisson.client.protocol.Decoder;
import org.redisson.client.protocol.Encoder;
@ -27,15 +30,19 @@ import org.redisson.jcache.JCacheEventCodec;
*/
public abstract class BaseCodec implements Codec {
private static final List<Class<?>> SKIPPED_CODECS = Arrays.asList(StringCodec.class,
ByteArrayCodec.class, LocalCachedMessageCodec.class, BitSetCodec.class, JCacheEventCodec.class);
public static Codec copy(ClassLoader classLoader, Codec codec) {
if (codec instanceof StringCodec
|| codec instanceof ByteArrayCodec
|| codec instanceof LocalCachedMessageCodec
|| codec instanceof BitSetCodec
|| codec instanceof JCacheEventCodec
|| codec == null) {
if (codec == null) {
return codec;
}
for (Class<?> clazz : SKIPPED_CODECS) {
if (clazz.isAssignableFrom(codec.getClass())) {
return codec;
}
}
try {
return codec.getClass().getConstructor(ClassLoader.class, codec.getClass()).newInstance(classLoader, codec);

@ -31,7 +31,7 @@ public class DoubleCodec extends StringCodec {
public static final DoubleCodec INSTANCE = new DoubleCodec();
public final Decoder<Object> decoder = new Decoder<Object>() {
private final Decoder<Object> decoder = new Decoder<Object>() {
@Override
public Object decode(ByteBuf buf, State state) throws IOException {
String str = (String) DoubleCodec.super.getValueDecoder().decode(buf, state);

@ -31,7 +31,7 @@ public class IntegerCodec extends StringCodec {
public static final IntegerCodec INSTANCE = new IntegerCodec();
public final Decoder<Object> decoder = new Decoder<Object>() {
private final Decoder<Object> decoder = new Decoder<Object>() {
@Override
public Object decode(ByteBuf buf, State state) throws IOException {
String str = (String) IntegerCodec.super.getValueDecoder().decode(buf, state);

@ -31,7 +31,7 @@ public class LongCodec extends StringCodec {
public static final LongCodec INSTANCE = new LongCodec();
public final Decoder<Object> decoder = new Decoder<Object>() {
private final Decoder<Object> decoder = new Decoder<Object>() {
@Override
public Object decode(ByteBuf buf, State state) throws IOException {
String str = (String) LongCodec.super.getValueDecoder().decode(buf, state);

@ -102,7 +102,7 @@ public class CommandDecoder extends ReplayingDecoder<State> {
}
protected final Logger log = LoggerFactory.getLogger(getClass());
final Logger log = LoggerFactory.getLogger(getClass());
private static final char CR = '\r';
private static final char LF = '\n';

@ -99,7 +99,7 @@ public class CommandPubSubDecoder extends CommandDecoder {
@Override
protected void decodeResult(CommandData<Object, Object> data, List<Object> parts, Channel channel,
final Object result) throws IOException {
Object result) throws IOException {
if (executor.isShutdown()) {
return;
}
@ -107,7 +107,7 @@ public class CommandPubSubDecoder extends CommandDecoder {
if (result instanceof Message) {
checkpoint();
final RedisPubSubConnection pubSubConnection = RedisPubSubConnection.getFrom(channel);
RedisPubSubConnection pubSubConnection = RedisPubSubConnection.getFrom(channel);
ChannelName channelName = ((Message) result).getChannel();
if (result instanceof PubSubStatusMessage) {
String operation = ((PubSubStatusMessage) result).getType().name().toLowerCase();
@ -160,7 +160,7 @@ public class CommandPubSubDecoder extends CommandDecoder {
}
}
private void enqueueMessage(Object res, final RedisPubSubConnection pubSubConnection, final PubSubEntry entry) {
private void enqueueMessage(Object res, RedisPubSubConnection pubSubConnection, PubSubEntry entry) {
if (res != null) {
entry.getQueue().add((Message) res);
}

@ -67,8 +67,8 @@ public class PingConnectionHandler extends ChannelInboundHandlerAdapter {
@Override
public void run(Timeout timeout) throws Exception {
CommandData<?, ?> commandData = connection.getCurrentCommand();
if ((commandData == null || !commandData.isBlockingCommand()) &&
(future.cancel(false) || !future.isSuccess())) {
if ((commandData == null || !commandData.isBlockingCommand())
&& (future.cancel(false) || !future.isSuccess())) {
ctx.channel().close();
log.debug("channel: {} closed due to PING response timeout set in {} ms", ctx.channel(), config.getPingConnectionInterval());
} else {

@ -85,7 +85,7 @@ public class CommandsData implements QueueCommand {
public List<CommandData<Object, Object>> getPubSubOperations() {
List<CommandData<Object, Object>> result = new ArrayList<CommandData<Object, Object>>();
for (CommandData<?, ?> commandData : commands) {
if (RedisCommands.PUBSUB_COMMANDS.equals(commandData.getCommand().getName())) {
if (RedisCommands.PUBSUB_COMMANDS.contains(commandData.getCommand().getName())) {
result.add((CommandData<Object, Object>) commandData);
}
}

@ -46,7 +46,7 @@ public class ClusterNodesDecoder implements Decoder<List<ClusterNodeInfo>> {
public List<ClusterNodeInfo> decode(ByteBuf buf, State state) throws IOException {
String response = buf.toString(CharsetUtil.UTF_8);
List<ClusterNodeInfo> nodes = new ArrayList<ClusterNodeInfo>();
List<ClusterNodeInfo> nodes = new ArrayList<>();
for (String nodeInfo : response.split("\n")) {
ClusterNodeInfo node = new ClusterNodeInfo(nodeInfo);
String[] params = nodeInfo.split(" ");

@ -38,7 +38,7 @@ public class GeoMapReplayDecoder implements MultiDecoder<Map<Object, Object>> {
public Map<Object, Object> decode(List<Object> parts, State state) {
Map<Object, Object> result = new LinkedHashMap<Object, Object>(parts.size());
for (Object object : parts) {
List<Object> vals = ((List<Object>) object);
List<Object> vals = (List<Object>) object;
result.put(vals.get(0), vals.get(1));
}
return result;

@ -15,7 +15,6 @@
*/
package org.redisson.client.protocol.decoder;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

@ -41,7 +41,7 @@ public class ScoredSortedSetReplayDecoder<T> implements MultiDecoder<List<Scored
@Override
public List<ScoredEntry<T>> decode(List<Object> parts, State state) {
List<ScoredEntry<T>> result = new ArrayList<ScoredEntry<T>>();
List<ScoredEntry<T>> result = new ArrayList<>();
for (int i = 0; i < parts.size(); i += 2) {
result.add(new ScoredEntry<T>(((Number) parts.get(i+1)).doubleValue(), (T) parts.get(i)));
}

@ -42,14 +42,14 @@ public class SlotsDecoder implements MultiDecoder<Object> {
@Override
public Object decode(List<Object> parts, State state) {
if (parts.size() > 2 && parts.get(0) instanceof List) {
Map<ClusterSlotRange, Set<String>> result = new HashMap<ClusterSlotRange, Set<String>>();
Map<ClusterSlotRange, Set<String>> result = new HashMap<>();
List<List<Object>> rows = (List<List<Object>>) (Object) parts;
for (List<Object> row : rows) {
Iterator<Object> iterator = row.iterator();
Long startSlot = (Long) iterator.next();
Long endSlot = (Long) iterator.next();
ClusterSlotRange range = new ClusterSlotRange(startSlot.intValue(), endSlot.intValue());
Set<String> addresses = new HashSet<String>();
Set<String> addresses = new HashSet<>();
while (iterator.hasNext()) {
List<Object> addressParts = (List<Object>) iterator.next();
addresses.add(addressParts.get(0) + ":" + addressParts.get(1));

@ -19,7 +19,6 @@ import java.util.List;
import org.redisson.client.handler.State;
import org.redisson.client.protocol.Decoder;
import org.redisson.client.protocol.decoder.MultiDecoder;
/**
*

Loading…
Cancel
Save