Skip to content

Commit

Permalink
Disallow null ports.
Browse files Browse the repository at this point in the history
Using null for the port ends up as a null pointer exception.
  • Loading branch information
Jay Anderson committed Jul 27, 2015
1 parent ada2e56 commit 7b2eb1a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/main/java/redis/embedded/RedisServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public RedisServer() throws IOException {
this(DEFAULT_REDIS_PORT);
}

public RedisServer(Integer port) throws IOException {
public RedisServer(int port) throws IOException {
super(port);
File executable = RedisExecProvider.defaultProvider().get();
this.args = Arrays.asList(
Expand All @@ -23,15 +23,15 @@ public RedisServer(Integer port) throws IOException {
);
}

public RedisServer(File executable, Integer port) {
public RedisServer(File executable, int port) {
super(port);
this.args = Arrays.asList(
executable.getAbsolutePath(),
"--port", Integer.toString(port)
);
}

public RedisServer(RedisExecProvider redisExecProvider, Integer port) throws IOException {
public RedisServer(RedisExecProvider redisExecProvider, int port) throws IOException {
super(port);
this.args = Arrays.asList(
redisExecProvider.get().getAbsolutePath(),
Expand Down
14 changes: 6 additions & 8 deletions src/main/java/redis/embedded/RedisServerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class RedisServerBuilder {

private File executable;
private RedisExecProvider redisExecProvider = RedisExecProvider.defaultProvider();
private Integer port = 6379;
private int port = 6379;
private InetSocketAddress slaveOf;
private String redisConf;

Expand All @@ -27,13 +27,13 @@ public RedisServerBuilder redisExecProvider(RedisExecProvider redisExecProvider)
this.redisExecProvider = redisExecProvider;
return this;
}
public RedisServerBuilder port(Integer port) {

public RedisServerBuilder port(int port) {
this.port = port;
return this;
}

public RedisServerBuilder slaveOf(String hostname, Integer port) {
public RedisServerBuilder slaveOf(String hostname, int port) {
this.slaveOf = new InetSocketAddress(hostname, port);
return this;
}
Expand Down Expand Up @@ -113,10 +113,8 @@ private List<String> buildCommandArgs() {
args.add(redisConf);
}

if (port != null) {
args.add("--port");
args.add(Integer.toString(port));
}
args.add("--port");
args.add(Integer.toString(port));

if (slaveOf != null) {
args.add("--slaveof");
Expand Down

0 comments on commit 7b2eb1a

Please sign in to comment.