Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applying code formatter each time we run a Maven build #2841

Merged
merged 4 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
21 changes: 21 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,27 @@
</configuration>
</plugin>

<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>2.16.0</version>
<configuration>
<directories>
<directory>${project.build.sourceDirectory}</directory>
<directory>${project.build.testSourceDirectory}</directory>
<directory>${project.basedir}/src/main/templates</directory>
</directories>
<configFile>formatting.xml</configFile>
</configuration>
<executions>
<execution>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/io/lettuce/core/AbstractRedisClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,8 @@ protected void channelType(ConnectionBuilder connectionBuilder, ConnectionPoint
LettuceAssert.notNull(connectionPoint, "ConnectionPoint must not be null");

boolean domainSocket = LettuceStrings.isNotEmpty(connectionPoint.getSocket());
connectionBuilder.bootstrap().group(
getEventLoopGroup(
domainSocket ? NativeTransports.eventLoopGroupClass(true) : Transports.eventLoopGroupClass()));
connectionBuilder.bootstrap().group(getEventLoopGroup(
domainSocket ? NativeTransports.eventLoopGroupClass(true) : Transports.eventLoopGroupClass()));

if (connectionPoint.getSocket() != null) {
NativeTransports.assertDomainSocketAvailable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,7 @@ public Mono<StreamScanCursor> hscan(KeyValueStreamingChannel<K, V> channel, K ke

@Override
public Mono<StreamScanCursor> hscanNovalues(KeyStreamingChannel<K> channel, K key, ScanCursor scanCursor,
ScanArgs scanArgs) {
ScanArgs scanArgs) {
return createMono(() -> commandBuilder.hscanNoValuesStreaming(channel, key, scanCursor, scanArgs));
}

Expand Down Expand Up @@ -2151,7 +2151,7 @@ public Flux<V> spop(K key, long count) {
public Mono<Long> spublish(K shardChannel, V message) {
return createMono(() -> commandBuilder.spublish(shardChannel, message));
}

@Override
public Mono<V> srandmember(K key) {
return createMono(() -> commandBuilder.srandmember(key));
Expand Down
1 change: 1 addition & 0 deletions src/main/java/io/lettuce/core/ChannelGroupListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@ private static String getRedisUri(Channel channel) {
private static CommandHandler getCommandHandler(ChannelHandlerContext ctx) {
return ctx.pipeline().get(CommandHandler.class);
}

}
11 changes: 5 additions & 6 deletions src/main/java/io/lettuce/core/ClientOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public class ClientOptions implements Serializable {

private final TimeoutOptions timeoutOptions;


protected ClientOptions(Builder builder) {
this.autoReconnect = builder.autoReconnect;
this.cancelCommandsOnReconnectFailure = builder.cancelCommandsOnReconnectFailure;
Expand Down Expand Up @@ -448,11 +447,11 @@ public ClientOptions.Builder mutate() {

builder.autoReconnect(isAutoReconnect()).cancelCommandsOnReconnectFailure(isCancelCommandsOnReconnectFailure())
.decodeBufferPolicy(getDecodeBufferPolicy()).disconnectedBehavior(getDisconnectedBehavior())
.readOnlyCommands(getReadOnlyCommands())
.publishOnScheduler(isPublishOnScheduler()).pingBeforeActivateConnection(isPingBeforeActivateConnection())
.protocolVersion(getConfiguredProtocolVersion()).requestQueueSize(getRequestQueueSize())
.scriptCharset(getScriptCharset()).socketOptions(getSocketOptions()).sslOptions(getSslOptions())
.suspendReconnectOnProtocolFailure(isSuspendReconnectOnProtocolFailure()).timeoutOptions(getTimeoutOptions());
.readOnlyCommands(getReadOnlyCommands()).publishOnScheduler(isPublishOnScheduler())
.pingBeforeActivateConnection(isPingBeforeActivateConnection()).protocolVersion(getConfiguredProtocolVersion())
.requestQueueSize(getRequestQueueSize()).scriptCharset(getScriptCharset()).socketOptions(getSocketOptions())
.sslOptions(getSslOptions()).suspendReconnectOnProtocolFailure(isSuspendReconnectOnProtocolFailure())
.timeoutOptions(getTimeoutOptions());

return builder;
}
Expand Down
124 changes: 62 additions & 62 deletions src/main/java/io/lettuce/core/CopyArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,75 +33,75 @@
*/
public class CopyArgs implements CompositeArgument {

private Long destinationDb;
private Long destinationDb;

private boolean replace;

/**
* Builder entry points for {@link CopyArgs}.
*/
public static class Builder {

/**
* Utility constructor.
*/
private Builder() {
}

/**
* Creates new {@link CopyArgs} and sets {@literal DB}.
*
* @return new {@link CopyArgs} with {@literal DB} set.
*/
public static CopyArgs destinationDb(long destinationDb) {
return new CopyArgs().destinationDb(destinationDb);
}

/**
* Creates new {@link CopyArgs} and sets {@literal REPLACE}.
*
* @return new {@link CopyArgs} with {@literal REPLACE} set.
*/
public static CopyArgs replace(boolean replace) {
return new CopyArgs().replace(replace);
}

}

/**
* Specify an alternative logical database index for the destination key.
*
* @param destinationDb logical database index to apply for {@literal DB}.
* @return {@code this}.
*/
public CopyArgs destinationDb(long destinationDb) {

this.destinationDb = destinationDb;
return this;
}

/**
* Hint redis to remove the destination key before copying the value to it.
*
* @param replace remove destination key before copying the value {@literal REPLACE}.
* @return {@code this}.
*/
public CopyArgs replace(boolean replace) {

this.replace = replace;
return this;
}
/**
* Builder entry points for {@link CopyArgs}.
*/
public static class Builder {

/**
* Utility constructor.
*/
private Builder() {
}

/**
* Creates new {@link CopyArgs} and sets {@literal DB}.
*
* @return new {@link CopyArgs} with {@literal DB} set.
*/
public static CopyArgs destinationDb(long destinationDb) {
return new CopyArgs().destinationDb(destinationDb);
}

/**
* Creates new {@link CopyArgs} and sets {@literal REPLACE}.
*
* @return new {@link CopyArgs} with {@literal REPLACE} set.
*/
public static CopyArgs replace(boolean replace) {
return new CopyArgs().replace(replace);
}

}

/**
* Specify an alternative logical database index for the destination key.
*
* @param destinationDb logical database index to apply for {@literal DB}.
* @return {@code this}.
*/
public CopyArgs destinationDb(long destinationDb) {

this.destinationDb = destinationDb;
return this;
}

/**
* Hint redis to remove the destination key before copying the value to it.
*
* @param replace remove destination key before copying the value {@literal REPLACE}.
* @return {@code this}.
*/
public CopyArgs replace(boolean replace) {

this.replace = replace;
return this;
}

@Override
public <K, V> void build(CommandArgs<K, V> args) {
public <K, V> void build(CommandArgs<K, V> args) {

if (destinationDb != null) {
args.add(CommandKeyword.DB).add(destinationDb);
}
if (destinationDb != null) {
args.add(CommandKeyword.DB).add(destinationDb);
}

if (replace) {
args.add(CommandKeyword.REPLACE);
}
}
args.add(CommandKeyword.REPLACE);
}
}

}
1 change: 1 addition & 0 deletions src/main/java/io/lettuce/core/FlushMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ public enum FlushMode implements ProtocolKeyword {
public byte[] getBytes() {
return bytes;
}

}
1 change: 1 addition & 0 deletions src/main/java/io/lettuce/core/GeoArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ public enum Unit implements ProtocolKeyword {
public byte[] getBytes() {
return asBytes;
}

}

public <K, V> void build(CommandArgs<K, V> args) {
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/io/lettuce/core/KillArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

/**
*
* Argument list builder for the Redis <a href="https://redis.io/commands/client-kill">CLIENT KILL</a> command. Static import the
* methods from {@link Builder} and chain the method calls: {@code id(1).skipme()}.
* Argument list builder for the Redis <a href="https://redis.io/commands/client-kill">CLIENT KILL</a> command. Static import
* the methods from {@link Builder} and chain the method calls: {@code id(1).skipme()}.
* <p>
* {@link KillArgs} is a mutable object and instances should be used only once to avoid shared mutable state.
*
Expand Down Expand Up @@ -159,6 +159,7 @@ public static KillArgs typeSlave() {
public static KillArgs user(String username) {
return new KillArgs().user(username);
}

}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/io/lettuce/core/LMoveArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,12 @@ public static LMoveArgs rightLeft() {
public static LMoveArgs rightRight() {
return new LMoveArgs(CommandKeyword.RIGHT, CommandKeyword.RIGHT);
}

}

@Override
public <K, V> void build(CommandArgs<K, V> args) {
args.add(source).add(destination);
}

}
4 changes: 2 additions & 2 deletions src/main/java/io/lettuce/core/MigrateArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import io.lettuce.core.protocol.CommandType;

/**
* Argument list builder for the Redis <a href="https://redis.io/commands/migrate">MIGRATE</a> command. Static import the methods
* from {@link Builder} and chain the method calls: {@code copy().auth("foobar")}.
* Argument list builder for the Redis <a href="https://redis.io/commands/migrate">MIGRATE</a> command. Static import the
* methods from {@link Builder} and chain the method calls: {@code copy().auth("foobar")}.
* <p>
* {@link MigrateArgs} is a mutable object and instances should be used only once to avoid shared mutable state.
*
Expand Down
1 change: 0 additions & 1 deletion src/main/java/io/lettuce/core/Range.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ public int hashCode() {
return Objects.hash(value, including);
}


@Override
public String toString() {

Expand Down
1 change: 1 addition & 0 deletions src/main/java/io/lettuce/core/ReadFromImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public List<RedisNodeDescription> select(Nodes nodes) {

return Collections.emptyList();
}

}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/lettuce/core/RedisChannelWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public interface RedisChannelWriter extends Closeable, AsyncCloseable {
void setConnectionFacade(ConnectionFacade connection);

/**
* Disable or enable auto-flush behavior. Default is {@code true}. If autoFlushCommands is disabled, multiple commands
* can be issued without writing them actually to the transport. Commands are buffered until a {@link #flushCommands()} is
* Disable or enable auto-flush behavior. Default is {@code true}. If autoFlushCommands is disabled, multiple commands can
* be issued without writing them actually to the transport. Commands are buffered until a {@link #flushCommands()} is
* issued. After calling {@link #flushCommands()} commands are sent to the transport and executed by Redis.
*
* @param autoFlush state of autoFlush.
Expand Down
30 changes: 15 additions & 15 deletions src/main/java/io/lettuce/core/RedisClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -744,28 +744,28 @@ private Mono<SocketAddress> lookupRedis(RedisURI sentinelUri) {
return Mono.usingWhen(
Mono.fromCompletionStage(() -> connectSentinelAsync(newStringStringCodec(), sentinelUri, timeout)), c -> {

String sentinelMasterId = sentinelUri.getSentinelMasterId();
return c.reactive().getMasterAddrByName(sentinelMasterId).map(it -> {
String sentinelMasterId = sentinelUri.getSentinelMasterId();
tishun marked this conversation as resolved.
Show resolved Hide resolved
return c.reactive().getMasterAddrByName(sentinelMasterId).map(it -> {

if (it instanceof InetSocketAddress) {
if (it instanceof InetSocketAddress) {

InetSocketAddress isa = (InetSocketAddress) it;
SocketAddress resolved = getResources().socketAddressResolver()
.resolve(RedisURI.create(isa.getHostString(), isa.getPort()));
InetSocketAddress isa = (InetSocketAddress) it;
SocketAddress resolved = getResources().socketAddressResolver()
.resolve(RedisURI.create(isa.getHostString(), isa.getPort()));

logger.debug("Resolved Master {} SocketAddress {}:{} to {}", sentinelMasterId, isa.getHostString(),
isa.getPort(), resolved);
logger.debug("Resolved Master {} SocketAddress {}:{} to {}", sentinelMasterId, isa.getHostString(),
isa.getPort(), resolved);

return resolved;
}
return resolved;
}

return it;
}).timeout(timeout) //
return it;
}).timeout(timeout) //
.onErrorMap(e -> {

RedisCommandTimeoutException ex = ExceptionFactory
.createTimeoutException("Cannot obtain master using SENTINEL MASTER", timeout);
ex.addSuppressed(e);
RedisCommandTimeoutException ex = ExceptionFactory
.createTimeoutException("Cannot obtain master using SENTINEL MASTER", timeout);
ex.addSuppressed(e);

return ex;
});
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/lettuce/core/RedisCommandBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -1689,7 +1689,7 @@ Command<K, V, StreamScanCursor> hscanStreaming(KeyValueStreamingChannel<K, V> ch
}

Command<K, V, StreamScanCursor> hscanNoValuesStreaming(KeyStreamingChannel<K> channel, K key, ScanCursor scanCursor,
ScanArgs scanArgs) {
ScanArgs scanArgs) {
notNullKey(key);
notNull(channel);

Expand Down
6 changes: 2 additions & 4 deletions src/main/java/io/lettuce/core/RedisHandshake.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,11 @@ private CompletableFuture<Void> applyConnectionMetadata(Channel channel) {
}

if (LettuceStrings.isNotEmpty(metadata.getLibraryName())) {
postHandshake.add(
new AsyncCommand<>(this.commandBuilder.clientSetinfo("lib-name", metadata.getLibraryName())));
postHandshake.add(new AsyncCommand<>(this.commandBuilder.clientSetinfo("lib-name", metadata.getLibraryName())));
}

if (LettuceStrings.isNotEmpty(metadata.getLibraryVersion())) {
postHandshake.add(
new AsyncCommand<>(this.commandBuilder.clientSetinfo("lib-ver", metadata.getLibraryVersion())));
postHandshake.add(new AsyncCommand<>(this.commandBuilder.clientSetinfo("lib-ver", metadata.getLibraryVersion())));
}

if (postHandshake.isEmpty()) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/lettuce/core/RedisPublisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,8 @@ void potentiallyReadMore() {

/*
* getDemand() maybe is Long.MAX_VALUE,because MonoNext.NextSubscriber#request(long n) inner use the Long.MAX_VALUE,
* so maybe "getDemand() + 1" will be overflow,we use "getDemand() > data.size() - 1" replace the "(getDemand() + 1) > data.size()"
* so maybe "getDemand() + 1" will be overflow,we use "getDemand() > data.size() - 1" replace the
* "(getDemand() + 1) > data.size()"
*/
if (getDemand() > data.size() - 1) {
state().readData(this);
Expand Down
Loading
Loading