You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by ra...@apache.org on 2016/10/16 12:23:44 UTC
zookeeper git commit: ZOOKEEPER-2467: NullPointerException when redo
Command is passed negative value (Rakesh Kumar Singh via rakeshr)
Repository: zookeeper
Updated Branches:
refs/heads/master f78061aaf -> 422058c22
ZOOKEEPER-2467: NullPointerException when redo Command is passed negative value (Rakesh Kumar Singh via rakeshr)
Project: http://git-wip-us.apache.org/repos/asf/zookeeper/repo
Commit: http://git-wip-us.apache.org/repos/asf/zookeeper/commit/422058c2
Tree: http://git-wip-us.apache.org/repos/asf/zookeeper/tree/422058c2
Diff: http://git-wip-us.apache.org/repos/asf/zookeeper/diff/422058c2
Branch: refs/heads/master
Commit: 422058c222a8a31ec7cfd4113fbdc036181f751d
Parents: f78061a
Author: Rakesh Radhakrishnan <ra...@apache.org>
Authored: Sun Oct 16 17:51:43 2016 +0530
Committer: Rakesh Radhakrishnan <ra...@apache.org>
Committed: Sun Oct 16 17:51:43 2016 +0530
----------------------------------------------------------------------
CHANGES.txt | 3 +++
.../org/apache/zookeeper/ZooKeeperMain.java | 2 +-
.../org/apache/zookeeper/ZooKeeperTest.java | 22 ++++++++++++++++++++
3 files changed, 26 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/422058c2/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 01f8d59..4dc5fd8 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -397,6 +397,9 @@ BUGFIXES:
ZOOKEEPER-2611: zoo_remove_watchers - can remove the wrong watch
(Eyal Leshmem via rgs)
+ ZOOKEEPER-2467: NullPointerException when redo Command is passed negative value
+ (Rakesh Kumar Singh via rakeshr)
+
IMPROVEMENTS:
ZOOKEEPER-2024 Major throughput improvement with mixed workloads (Kfir Lev-Ari via shralex)
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/422058c2/src/java/main/org/apache/zookeeper/ZooKeeperMain.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/ZooKeeperMain.java b/src/java/main/org/apache/zookeeper/ZooKeeperMain.java
index 25d61a4..c39395a 100644
--- a/src/java/main/org/apache/zookeeper/ZooKeeperMain.java
+++ b/src/java/main/org/apache/zookeeper/ZooKeeperMain.java
@@ -616,7 +616,7 @@ public class ZooKeeperMain {
System.exit(exitCode);
} else if (cmd.equals("redo") && args.length >= 2) {
Integer i = Integer.decode(args[1]);
- if (commandCount <= i) { // don't allow redoing this redo
+ if (commandCount <= i || i < 0) { // don't allow redoing this redo
throw new MalformedCommandException("Command index out of range");
}
cl.parseCommand(history.get(i));
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/422058c2/src/java/test/org/apache/zookeeper/ZooKeeperTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/ZooKeeperTest.java b/src/java/test/org/apache/zookeeper/ZooKeeperTest.java
index 8ff98bd..dd610dd 100644
--- a/src/java/test/org/apache/zookeeper/ZooKeeperTest.java
+++ b/src/java/test/org/apache/zookeeper/ZooKeeperTest.java
@@ -433,6 +433,28 @@ public class ZooKeeperTest extends ClientBase {
}
}
+ // ZOOKEEPER-2467 : Testing negative number for redo command
+ @Test
+ public void testRedoWithNegativeCmdNumber() throws Exception {
+ final ZooKeeper zk = createClient();
+ ZooKeeperMain zkMain = new ZooKeeperMain(zk);
+ String cmd1 = "redo -1";
+
+ // setup redirect out/err streams to get System.in/err, use this
+ // judiciously!
+ final PrintStream systemErr = System.err; // get current err
+ final ByteArrayOutputStream errContent = new ByteArrayOutputStream();
+ System.setErr(new PrintStream(errContent));
+ try {
+ zkMain.executeLine(cmd1);
+ Assert.assertEquals("Command index out of range", errContent
+ .toString().trim());
+ } finally {
+ // revert redirect of out/err streams - important step!
+ System.setErr(systemErr);
+ }
+ }
+
private static void runCommandExpect(CliCommand command, List<String> expectedResults)
throws Exception {
// call command and put result in byteStream