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

ASF GitHub Bot commented on ZOOKEEPER-2757:
-------------------------------------------

Github user afine commented on the issue:

    https://github.com/apache/zookeeper/pull/240
  
    @hanm I'm not sure that we should always assume that an 
IllegalArgumentException will only be thrown when a path is invalid. Since 
IllegalArgumentException does not need to be caught, it will be difficult for 
us to tell if we are masking IllegalArgumentExceptions thrown for other 
reasons. So we should minimize the code surrounded by `try { } 
catch(IllegalArgumentException e) {}` We cannot catch them within the methods 
of ZooKeeper.java so I think catching them at the "Command" level is the best 
we can do.
    
    IllegalArgumentException is a RuntimeException, which should represent a 
"programming problem" 
(http://docs.oracle.com/javase/tutorial/essential/exceptions/runtime.html). 
    >Runtime exceptions represent problems that are the result of a programming 
problem, and as such, the API client code cannot reasonably be expected to 
recover from them or to handle them in any way. 
    
    So if it does pop up for reasons other than a bad path, we should certainly 
bubble it up and kill the CLI.
    
    We abuse IllegalArgumentException all over ZK, I believe we should change 
this exception type in 3.6.
    
     


> Incorrect path crashes zkCli
> ----------------------------
>
>                 Key: ZOOKEEPER-2757
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2757
>             Project: ZooKeeper
>          Issue Type: Bug
>    Affects Versions: 3.5.3
>            Reporter: Flavio Junqueira
>            Assignee: Abraham Fine
>            Priority: Minor
>             Fix For: 3.5.4
>
>
> If I try {{delete test}} without the leading /, then the CLI crashes with 
> this exception:
> {noformat}
> Exception in thread "main" java.lang.IllegalArgumentException: Path must 
> start with / character
>       at org.apache.zookeeper.common.PathUtils.validatePath(PathUtils.java:51)
>       at org.apache.zookeeper.ZooKeeper.delete(ZooKeeper.java:1659)
>       at org.apache.zookeeper.cli.DeleteCommand.exec(DeleteCommand.java:83)
>       at 
> org.apache.zookeeper.ZooKeeperMain.processZKCmd(ZooKeeperMain.java:655)
>       at org.apache.zookeeper.ZooKeeperMain.processCmd(ZooKeeperMain.java:586)
>       at 
> org.apache.zookeeper.ZooKeeperMain.executeLine(ZooKeeperMain.java:370)
>       at org.apache.zookeeper.ZooKeeperMain.run(ZooKeeperMain.java:330)
>       at org.apache.zookeeper.ZooKeeperMain.main(ZooKeeperMain.java:292)
> {noformat}
> It should really fail the operation rather than crash the CLI.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to