【问题标题】:Strange behavior when adding a string with spaces to ZooKeeper向 ZooKeeper 添加带空格的字符串时的奇怪行为
【发布时间】:2018-08-02 13:29:27
【问题描述】:

使用 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,我尝试了这种方法。 由此,我认为我尝试过的应该有效。两个问题:

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

  2. 为什么后面的'set'会抛出NumberFormatException?

【问题讨论】:

  • 根据我的阅读,您不能通过 Zookeeper 的命令行工具添加带空格的字符串值。

标签: java apache-zookeeper


【解决方案1】:

它不起作用的原因是命令解析器使用空格来标记输入并且没有正确处理字符串。已解决:

ZOOKEEPER-1853 - “zkCli.sh 无法发出包含数据中空格的 CREATE 命令”。

根据 JIRA,修复程序应该在 3.4.7、3.5.2 和 3.6.0 中。

【讨论】:

  • 虽然这是 OBE,但我没有办法再验证了 - 你回答了这么老的问题是值得称赞的!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-03-20
  • 2023-03-12
  • 2015-12-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多