Skip to content

Commit

Permalink
Polishing #871
Browse files Browse the repository at this point in the history
Align static final declarations, switch final static to static final.
  • Loading branch information
mp911de committed Sep 29, 2018
1 parent 25b925a commit af1dcad
Show file tree
Hide file tree
Showing 106 changed files with 1,251 additions and 1,100 deletions.
2 changes: 1 addition & 1 deletion src/main/java/io/lettuce/core/PlainChannelInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*/
class PlainChannelInitializer extends io.netty.channel.ChannelInitializer<Channel> implements RedisChannelInitializer {

final static Supplier<AsyncCommand<?, ?, ?>> NO_PING = () -> null;
static final Supplier<AsyncCommand<?, ?, ?>> NO_PING = () -> null;

private final Supplier<List<ChannelHandler>> handlers;
private final Supplier<AsyncCommand<?, ?, ?>> pingCommandSupplier;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/lettuce/core/Range.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public String toString() {
*/
public static class Boundary<T> {

private final static Boundary<?> UNBOUNDED = new Boundary<>(null, true);
private static final Boundary<?> UNBOUNDED = new Boundary<>(null, true);

private final T value;
private final boolean including;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ static class SlotIntent {

final int slotHash;
final Intent intent;
private final static SlotIntent[] READ;
private final static SlotIntent[] WRITE;
private static final SlotIntent[] READ;
private static final SlotIntent[] WRITE;

static {
READ = new SlotIntent[SlotHash.SLOT_COUNT];
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/lettuce/core/dynamic/BatchTasks.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/
class BatchTasks implements Iterable<RedisCommand<?, ?, ?>> {

public final static BatchTasks EMPTY = new BatchTasks(Collections.emptyList());
public static final BatchTasks EMPTY = new BatchTasks(Collections.emptyList());

private final List<RedisCommand<?, ?, ?>> futures;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ public int compareTo(Voted<?> o) {
*/
protected static class ParameterWrappers {

private final static Set<Class<?>> WRAPPERS = new HashSet<>();
private final static Set<Class<?>> WITH_KEY_TYPE = new HashSet<>();
private final static Set<Class<?>> WITH_VALUE_TYPE = new HashSet<>();
private static final Set<Class<?>> WRAPPERS = new HashSet<>();
private static final Set<Class<?>> WITH_KEY_TYPE = new HashSet<>();
private static final Set<Class<?>> WITH_VALUE_TYPE = new HashSet<>();

static {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
@SuppressWarnings("rawtypes")
public class OutputRegistry {

private final static Map<OutputType, CommandOutputFactory> BUILTIN = new LinkedHashMap<>();
private static final Map<OutputType, CommandOutputFactory> BUILTIN = new LinkedHashMap<>();
private final Map<OutputType, CommandOutputFactory> registry = new LinkedHashMap<>();

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private static boolean isProxyOfSameInterfaces(Object arg, Class<?> proxyClass)

protected static class MethodTranslator {

private final static WeakHashMap<Class<?>, MethodTranslator> TRANSLATOR_MAP = new WeakHashMap<>(32);
private static final WeakHashMap<Class<?>, MethodTranslator> TRANSLATOR_MAP = new WeakHashMap<>(32);
private final Map<Method, Method> map;

private MethodTranslator(Class<?> delegate, Class<?>... methodSources) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ static class Sync<K, T extends AsyncCloseable, F extends CompletionStage<T>> {
private static final int PHASE_CANCELED = 3;

@SuppressWarnings({ "rawtypes", "unchecked" })
private final static AtomicIntegerFieldUpdater<Sync> PHASE = AtomicIntegerFieldUpdater.newUpdater(Sync.class, "phase");
private static final AtomicIntegerFieldUpdater<Sync> PHASE = AtomicIntegerFieldUpdater.newUpdater(Sync.class, "phase");

// Updated with AtomicIntegerFieldUpdater
@SuppressWarnings("unused")
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/lettuce/core/internal/DefaultMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
public class DefaultMethods {

private final static MethodHandleLookup methodHandleLookup = MethodHandleLookup.getMethodHandleLookup();
private static final MethodHandleLookup methodHandleLookup = MethodHandleLookup.getMethodHandleLookup();

/**
* Lookup a {@link MethodHandle} for a default {@link Method}.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/lettuce/core/output/ListSubscriber.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
class ListSubscriber<T> extends Subscriber<T> {

private final static ListSubscriber<Object> INSTANCE = new ListSubscriber<>();
private static final ListSubscriber<Object> INSTANCE = new ListSubscriber<>();

private ListSubscriber() {
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/lettuce/core/protocol/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
*/
public class Command<K, V, T> implements RedisCommand<K, V, T> {

protected final static byte ST_INITIAL = 0;
protected final static byte ST_COMPLETED = 1;
protected final static byte ST_CANCELLED = 2;
protected static final byte ST_INITIAL = 0;
protected static final byte ST_COMPLETED = 1;
protected static final byte ST_CANCELLED = 2;

private final ProtocolKeyword type;

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/lettuce/core/protocol/CommandWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
public class CommandWrapper<K, V, T> implements RedisCommand<K, V, T>, CompleteableCommand<T>, DecoratedCommand<K, V, T> {

@SuppressWarnings({ "rawtypes", "unchecked" })
private final static AtomicReferenceFieldUpdater<CommandWrapper, Object[]> ONCOMPLETE = AtomicReferenceFieldUpdater
private static final AtomicReferenceFieldUpdater<CommandWrapper, Object[]> ONCOMPLETE = AtomicReferenceFieldUpdater
.newUpdater(CommandWrapper.class, Object[].class, "onComplete");

@SuppressWarnings({ "rawtypes", "unchecked" })
private final static Object[] EMPTY = new Object[0];
private static final Object[] EMPTY = new Object[0];

protected final RedisCommand<K, V, T> command;

Expand Down
6 changes: 3 additions & 3 deletions src/test/java/io/lettuce/apigenerator/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
*/
class Constants {

public final static String[] TEMPLATE_NAMES = { "BaseRedisCommands", "RedisGeoCommands", "RedisHashCommands",
public static final String[] TEMPLATE_NAMES = { "BaseRedisCommands", "RedisGeoCommands", "RedisHashCommands",
"RedisHLLCommands", "RedisKeyCommands", "RedisListCommands", "RedisScriptingCommands", "RedisSentinelCommands",
"RedisServerCommands", "RedisSetCommands", "RedisSortedSetCommands", "RedisStreamCommands", "RedisStringCommands",
"RedisTransactionalCommands" };

public final static File TEMPLATES = new File("src/main/templates");
public final static File SOURCES = new File("src/main/java");
public static final File TEMPLATES = new File("src/main/templates");
public static final File SOURCES = new File("src/main/java");
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,14 @@
* @author Mark Paluch
*/
@ExtendWith(LettuceExtension.class)
class ConnectionCommandTest extends TestSupport {
class ConnectionCommandIntegrationTests extends TestSupport {

private final RedisClient client;
private final StatefulRedisConnection<String, String> connection;
private final RedisCommands<String, String> redis;

@Inject
ConnectionCommandTest(RedisClient client, StatefulRedisConnection<String, String> connection) {
ConnectionCommandIntegrationTests(RedisClient client, StatefulRedisConnection<String, String> connection) {
this.client = client;
this.connection = connection;
this.redis = connection.sync();
}

Expand Down
8 changes: 8 additions & 0 deletions src/test/java/io/lettuce/core/PipeliningIntegrationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@

import javax.inject.Inject;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith;

import io.lettuce.core.api.StatefulRedisConnection;
Expand All @@ -35,6 +37,7 @@
*/
@SuppressWarnings("rawtypes")
@ExtendWith(LettuceExtension.class)
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class PipeliningIntegrationTests extends TestSupport {

private final RedisClient client;
Expand All @@ -46,6 +49,11 @@ class PipeliningIntegrationTests extends TestSupport {
this.connection = connection;
}

@BeforeEach
void setUp() {
this.connection.async().flushall();
}

@Test
void basic() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
import javax.enterprise.inject.New;
import javax.inject.Inject;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
Expand All @@ -43,6 +45,7 @@
import io.lettuce.test.Wait;

@ExtendWith(LettuceExtension.class)
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class ReactiveConnectionIntegrationTests extends TestSupport {

private final StatefulRedisConnection<String, String> connection;
Expand All @@ -54,7 +57,11 @@ class ReactiveConnectionIntegrationTests extends TestSupport {
this.connection = connection;
this.redis = connection.sync();
this.reactive = connection.reactive();
this.redis.flushall();
}

@BeforeEach
void setUp() {
this.connection.async().flushall();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@

import javax.inject.Inject;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith;

import reactor.test.StepVerifier;
Expand All @@ -38,6 +40,7 @@
* @author Mark Paluch
*/
@ExtendWith(LettuceExtension.class)
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class ReactiveStreamingOutputIntegrationTests extends TestSupport {

private final RedisCommands<String, String> redis;
Expand All @@ -49,6 +52,11 @@ class ReactiveStreamingOutputIntegrationTests extends TestSupport {
this.reactive = connection.reactive();
}

@BeforeEach
void setUp() {
this.redis.flushall();
}

@Test
void keyListCommandShouldReturnAllElements() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
*/
class RedisClientFactoryUnitTests {

private final static String URI = "redis://" + TestSettings.host() + ":" + TestSettings.port();
private final static RedisURI REDIS_URI = RedisURI.create(URI);
private static final String URI = "redis://" + TestSettings.host() + ":" + TestSettings.port();
private static final RedisURI REDIS_URI = RedisURI.create(URI);

@Test
void plain() {
Expand Down
10 changes: 8 additions & 2 deletions src/test/java/io/lettuce/core/ScanIteratorIntegrationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@

import javax.inject.Inject;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith;

import io.lettuce.core.api.StatefulRedisConnection;
Expand All @@ -37,17 +39,21 @@
* @author Mark Paluch
*/
@ExtendWith(LettuceExtension.class)
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class ScanIteratorIntegrationTests extends TestSupport {

private final StatefulRedisConnection<String, String> connection;
private final RedisCommands<String, String> redis;

@Inject
ScanIteratorIntegrationTests(StatefulRedisConnection<String, String> connection) {
this.connection = connection;
this.redis = connection.sync();
}

@BeforeEach
void setUp() {
this.redis.flushall();
}

@Test
void scanShouldThrowNoSuchElementExceptionOnEmpty() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@

import javax.inject.Inject;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith;

import reactor.core.publisher.Flux;
Expand All @@ -34,17 +36,23 @@
* @author Mark Paluch
*/
@ExtendWith(LettuceExtension.class)
class ScanStreamTest extends TestSupport {
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class ScanStreamIntegrationTests extends TestSupport {

private final StatefulRedisConnection<String, String> connection;
private final RedisCommands<String, String> redis;

@Inject
ScanStreamTest(StatefulRedisConnection<String, String> connection) {
ScanStreamIntegrationTests(StatefulRedisConnection<String, String> connection) {
this.connection = connection;
this.redis = connection.sync();
}

@BeforeEach
void setUp() {
this.redis.flushall();
}

@Test
void shouldScanIteratively() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @author Mark Paluch
* @since 3.0
*/
class SyncAsyncApiConvergenceTest {
class SyncAsyncApiConvergenceUnitTests {

@SuppressWarnings("rawtypes")
private Class<RedisAsyncCommands> asyncClass = RedisAsyncCommands.class;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
*/
class RedisClusterClientFactoryTests {

private final static String URI = "redis://" + TestSettings.host() + ":" + TestSettings.port();
private final static RedisURI REDIS_URI = RedisURI.create(URI);
private static final String URI = "redis://" + TestSettings.host() + ":" + TestSettings.port();
private static final RedisURI REDIS_URI = RedisURI.create(URI);
private static final List<RedisURI> REDIS_URIS = LettuceLists.newList(REDIS_URI);

@Test
Expand Down
Loading

0 comments on commit af1dcad

Please sign in to comment.