Skip to content

Commit

Permalink
1.0.16-release
Browse files Browse the repository at this point in the history
fix inputstream close bug
  • Loading branch information
leonchen83 committed Nov 23, 2016
1 parent 3f24013 commit 3275846
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jdk:
- openjdk7
branches:
only:
- 1.0.15
- 1.0.16
services:
- redis-server
before_install:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ rdb version 7
<dependency>
<groupId>com.moilioncircle</groupId>
<artifactId>redis-replicator</artifactId>
<version>1.0.15</version>
<version>1.0.16</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<groupId>com.moilioncircle</groupId>
<artifactId>redis-replicator</artifactId>
<version>1.0.15</version>
<version>1.0.16</version>

<name>redis-replicator</name>
<description>Redis Replicator is a redis RDB and Command parser written in java.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ public RedisAofReplicator(InputStream in, Configuration configuration) {

@Override
public void open() throws IOException {
try {
doOpen();
} finally {
close();
}
}

private void doOpen() {
worker.start();
while (true) {
try {
Expand Down Expand Up @@ -81,7 +89,6 @@ public void open() throws IOException {
logger.info("Redis reply:" + obj);
}
} catch (IOException | InterruptedException e) {
doClose();
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,18 @@ public RedisRdbReplicator(InputStream in, Configuration configuration) {

@Override
public void open() throws IOException {
try {
doOpen();
} catch (IOException e) {
} finally {
close();
}
}

private void doOpen() throws IOException {
worker.start();
RdbParser parser = new RdbParser(inputStream, this);
parser.parse();
doClose();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ public void handle(long len) {
Object[] params = new Object[command.length - 1];
System.arraycopy(command, 1, params, 0, params.length);

final CommandParser<? extends Command> operations;
//if command do not register. ignore
if (commands.get(cmdName) == null) continue;
if ((operations = commands.get(cmdName)) == null) continue;

//do command replyParser
CommandParser<? extends Command> operations = commands.get(cmdName);
Command parsedCommand = operations.parse(cmdName, params);

//submit event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ public String readString(int len, Charset charset) throws IOException {
return new String(original, charset);
}

@Override
public int read(byte[] bytes, int offset, int len) throws IOException {
int total = len;
int index = offset;
Expand All @@ -185,6 +186,7 @@ public int read(byte[] bytes, int offset, int len) throws IOException {
return len;
}

@Override
public int available() throws IOException {
return tail - head + in.available();
}
Expand All @@ -196,6 +198,7 @@ public void fill() throws IOException {
head = 0;
}

@Override
public long skip(long len) throws IOException {
long total = len;
while (total > 0) {
Expand All @@ -210,4 +213,9 @@ public long skip(long len) throws IOException {
}
return len;
}

@Override
public void close() throws IOException {
in.close();
}
}

0 comments on commit 3275846

Please sign in to comment.