[alibaba/arthas]watch命令,map.get("aa:bb")报错,ognl.ParseException: Encountered " ":"

2024-07-09 487 views
3
环境信息
  • arthas-boot.jar 或者 as.sh 的版本: xxx
  • Arthas 版本: 3.5.4
  • 操作系统版本: Debian GNU/Linux 11
  • 目标进程的JVM版本: 11
  • 执行arthas-boot的版本: xxx
重现问题的步骤
  1. curl -O https://arthas.aliyun.com/arthas-boot.jar && java -jar arthas-boot.jar
  2. watch -n 1 -x 1 类全名 方法名 {params[0].map.get("aa:bb")}
期望的结果

不报错,能正常输出 key对应的 value

实际运行的结果

实际运行结果,最好有详细的日志,异常栈。尽量贴文本。

watch failed, condition is: null, express is: {params[0].map.get(aa:bb)}, ognl.ExpressionSyntaxException: Malformed OGNL expression: {params[0].map.get("aa:bb")} [ognl.ParseException: Encountered " ":" ": "" at line 1, column 23.
Was expecting one of:
    "," ...
    "=" ...
    "?" ...
    "||" ...
    "or" ...
    "&&" ...
    "and" ...
    "|" ...
    "bor" ...
    "^" ...
    "xor" ...
    "&" ...
    "band" ...
    "==" ...
    "eq" ...
    "!=" ...
    "neq" ...
    "<" ...
    "lt" ...
    ">" ...
    "gt" ...
    "<=" ...
    "lte" ...
    ">=" ...
    "gte" ...
    "in" ...
    "not" ...
    "<<" ...
    "shl" ...
    ">>" ...
    "shr" ...
    ">>>" ...
    "ushr" ...
    "+" ...
    "-" ...
    "*" ...
    "/" ...
    "%" ...
    "instanceof" ...
    "." ...
    "(" ...
    ")" ...
    "[" ...
    <DYNAMIC_SUBSCRIPT> ...
    "(" ...
    ], visit /root/logs/arthas/arthas.log for more details.

回答

1
  • '包起来,不要用",避免需要转义
  • 增加 -v参数,会打印出具体的表达式
6

以下都试过了,报错,我猜测可能是把 冒号 当作ognl中 map的分隔符了:

  1. map.get("aa:bb")
  2. map.get('aa:bb')
  3. map.get('aa\:bb')
  4. map.get('aa\:bb')
  5. map.get('aa::bb')
  6. map['aa:bb']
  7. map["aa:bb"]
7

错误信息里面,单引号 双引号 都没了