将带空格的字符串添加到 ZooKeeper 时的奇怪行为
Strange behavior when adding a string with spaces to ZooKeeper
使用 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""
因为 here,我尝试了这种方法。
由此,我了解到我尝试过的应该有效。两个问题:
为什么第一个带空格的字符串没有正确创建?
为什么后面的'set'会抛出NumberFormatException?
它不起作用的原因是命令解析器使用空格来标记输入并且没有正确处理字符串。这已在:
中解决
ZOOKEEPER-1853 - "zkCli.sh can't issue a CREATE command containing spaces in the data".
根据 JIRA,修复应该在 3.4.7、3.5.2 和 3.6.0 中。
使用 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""
因为 here,我尝试了这种方法。 由此,我了解到我尝试过的应该有效。两个问题:
为什么第一个带空格的字符串没有正确创建?
为什么后面的'set'会抛出NumberFormatException?
它不起作用的原因是命令解析器使用空格来标记输入并且没有正确处理字符串。这已在:
中解决ZOOKEEPER-1853 - "zkCli.sh can't issue a CREATE command containing spaces in the data".
根据 JIRA,修复应该在 3.4.7、3.5.2 和 3.6.0 中。