zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Flavio Junqueira (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (ZOOKEEPER-2467) NullPointerException when redo Command is passed negative value
Date Mon, 01 Aug 2016 19:55:20 GMT

    [ https://issues.apache.org/jira/browse/ZOOKEEPER-2467?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15402711#comment-15402711

Flavio Junqueira commented on ZOOKEEPER-2467:

Thanks for the updated patch, [~joshi.shankar]. I have a few comments, though:

# The format seems to be broken, the try/catch block doesn't have the right indentation.
# {{testCliCommandsNotEchoingUsage}} is not the best method to include this test. We aren't
testing whether redo is echoing usage, but instead that it isn't throwing an NPE with negative
values. One suggestion is to have a test case called {{testRedoNegativeCmdNumber}} in the
same class and add the redo test there.
# The test cases in the {{ZooKeeperTest}} class throw {{Exception}} so it is actually better
that we do it to follow the pattern here. We should still fail in the case it throws an exception,
but instead of swallowing it, I suggest we rethrow. 
# We might consider adding an implementation of {{RedoCommand}} that extends {{CliCommand}}
to be able to check the output, like in {{testSortedLs()}}.

Here is roughly how it should look like:

    public void testRedoNegativeCmdNumber() throws Exception {
       try {
           String cmd = "redo -1";
           // check that the output matches
       } (Exception e) {
           fail("Failed to excute redo command with negative number");
           throw e;

> NullPointerException when redo Command is passed negative value
> ---------------------------------------------------------------
>                 Key: ZOOKEEPER-2467
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2467
>             Project: ZooKeeper
>          Issue Type: Bug
>          Components: java client
>    Affects Versions: 3.4.8, 3.5.2
>         Environment: Linux , windows
>            Reporter: Joshi Shankar
>            Assignee: Joshi Shankar
>            Priority: Minor
>             Fix For: 3.4.9, 3.5.3
>         Attachments: ZOOKEEPER-2467-1.patch, ZOOKEEPER-2467-final.patch, ZOOKEEPER-2467.patch,
> When negative value of argument is passed to redo command .
> [zk: localhost:2181(CONNECTED) 0] redo -1
> Exception in thread "main" java.lang.NullPointerException
>         at java.util.StringTokenizer.<init>(Unknown Source)
>         at java.util.StringTokenizer.<init>(Unknown Source)
>         at org.apache.zookeeper.ZooKeeperMain$MyCommandOptions.parseCommand(ZooKeeperMain.java:227)
>         at org.apache.zookeeper.ZooKeeperMain.processZKCmd(ZooKeeperMain.java:645)
>         at org.apache.zookeeper.ZooKeeperMain.processCmd(ZooKeeperMain.java:588)
>         at org.apache.zookeeper.ZooKeeperMain.executeLine(ZooKeeperMain.java:360)
>         at org.apache.zookeeper.ZooKeeperMain.run(ZooKeeperMain.java:323)
>         at org.apache.zookeeper.ZooKeeperMain.main(ZooKeeperMain.java:282)

This message was sent by Atlassian JIRA

View raw message