向ZooKeeper添加带有空格的字符串时出现奇怪的行为

4

使用ZK 3.4.5和zkCli.sh,我得到了以下结果:

./zkCli.sh -server localhost:2181
Connecting to localhost:2181
Welcome to ZooKeeper!
JLine support is enabled

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0] create /test 100
Created /test
[zk: localhost:2181(CONNECTED) 1] create /test/spacesString "this string has spaces in it"
Created /test/spacesString
[zk: localhost:2181(CONNECTED) 2] get /test/spacesString
"this
cZxid = 0x9c220
ctime = Wed Mar 11 06:46:10 EDT 2015
mZxid = 0x9c220
mtime = Wed Mar 11 06:46:10 EDT 2015
[deleted rest of output here]
[zk: localhost:2181(CONNECTED) 3] set /test/spacesString "new value"
Command failed: java.lang.NumberFormatException: For input string: "value""

我尝试这种方法是因为这里。 从那里,我得出了我所尝试的应该可以工作的结论。两个问题:

  1. 为什么第一个带空格的字符串无法正确创建?

  2. 为什么后续的“设置”会抛出NumberFormatException异常?


根据我所了解的,您无法通过Zookeeper命令行工具添加带有空格的字符串值。 - bkahler
1个回答

2
由于命令解析器使用空格对输入进行分词并没有正确处理字符串,所以出现了无法正常工作的情况。这个问题已经在以下 JIRA 中得到解决:ZOOKEEPER-1853 - "zkCli.sh 无法发出包含数据中空格的 CREATE 命令"。根据该 JIRA 的说明,修复版本为 3.4.7、3.5.2 和 3.6.0。

虽然这已经过时了,我无法再进行验证 - 但你因回答这么老的问题而获得了荣誉! - JoeG

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接