Skip to content

Commit

Permalink
Some changes to reset() function in builder
Browse files Browse the repository at this point in the history
  • Loading branch information
codemonstur committed Mar 12, 2024
1 parent 0b8e372 commit cdc7c79
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>com.github.codemonstur</groupId>
<artifactId>embedded-redis</artifactId>
<version>1.4.1</version>
<version>1.4.2</version>
<packaging>jar</packaging>

<name>embedded-redis</name>
Expand Down
10 changes: 3 additions & 7 deletions src/main/java/redis/embedded/core/RedisSentinelBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public final class RedisSentinelBuilder {
LINE_PORT = "port %d";

private File executable;

private ExecutableProvider executableProvider = newJarResourceProvider();
private String bind = "127.0.0.1";
private Integer port = 26379;
Expand Down Expand Up @@ -100,13 +101,8 @@ public RedisSentinelBuilder settingIf(final boolean shouldSet, final String conf
}

public RedisSentinelBuilder setting(final String configLine) {
if (sentinelConf != null) {
throw new IllegalArgumentException("Redis configuration is already set using redis conf file");
}

if (redisConfigBuilder == null) {
redisConfigBuilder = new StringBuilder();
}
if (sentinelConf != null) throw new IllegalArgumentException("Redis configuration is already set using redis conf file");
if (redisConfigBuilder == null) redisConfigBuilder = new StringBuilder();

redisConfigBuilder.append(configLine).append(LINE_SEPARATOR);
return this;
Expand Down
12 changes: 1 addition & 11 deletions src/main/java/redis/embedded/core/RedisServerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public final class RedisServerBuilder {

private static final String LINE_SEPARATOR = System.getProperty("line.separator");

private File executable;
private ExecutableProvider provider = newJarResourceProvider();
private String bindAddress = "127.0.0.1";
private int bindPort = DEFAULT_REDIS_PORT;
Expand Down Expand Up @@ -94,14 +93,7 @@ public RedisServer build() throws IOException {
}

public void reset() {
this.executable = null;
this.slaveOf = null;
this.redisConfigBuilder = new StringBuilder();
this.provider = newJarResourceProvider();
this.bindAddress = "127.0.0.1";
this.bindPort = DEFAULT_REDIS_PORT;
this.soutListener = null;
this.serrListener = null;
}

public List<String> buildCommandArgs() throws IOException {
Expand All @@ -110,10 +102,8 @@ public List<String> buildCommandArgs() throws IOException {
final Path redisConfigFile =
writeNewRedisConfigFile("embedded-redis-server_" + bindPort, redisConfigBuilder.toString());

executable = provider.get();

final List<String> args = new ArrayList<>();
args.add(executable.getAbsolutePath());
args.add(provider.get().getAbsolutePath());
args.add(redisConfigFile.toAbsolutePath().toString());
args.add("--port");
args.add(Integer.toString(bindPort));
Expand Down

0 comments on commit cdc7c79

Please sign in to comment.