[alibaba/arthas]修复Configure的telnetPort 和httpPort 在BinderUtils.inject 反射设置异常的问题

2023-12-15 268 views
0

arthas-spring-boot-starter 在设置httpPort或者telnetPort是会报异常:

Caused by: java.lang.IllegalArgumentException: Cannot convert value [8564] from source type [Integer] to target type [int] at com.taobao.arthas.core.env.PropertySourcesPropertyResolver.getProperty(PropertySourcesPropertyResolver.java:97) at com.taobao.arthas.core.env.PropertySourcesPropertyResolver.getProperty(PropertySourcesPropertyResolver.java:62) at com.taobao.arthas.core.env.ArthasEnvironment.getProperty(ArthasEnvironment.java:101) at com.taobao.arthas.core.config.BinderUtils.inject(BinderUtils.java:53) ... 34 common frames omitted

在BinderUtils.inject 设置值的时候调用PropertySourcesPropertyResolver.getProperty 比较int和integer的时候验证不过抛出异常,Configure 的set方法入参需要修改成Integer

回答

5

更好的办法是让注入的代码本身支持类型转换,应该是少了一些 convertor 类。

暂时可以在配置里用 字符串的方式注入。

0

被设置的值类型是integer,set方法的入参是int,在getProperty 时判断类型的时候抛出了异常,starter里设置arthas.httpPort设置成什么都会报错,这个是稳定复现的异常,会导致服务无法启动。增加Convertor转换类我觉得没必要搞那么复杂,其实只要改成相同类型就可以,或者优化getProperty的逻辑对基础类型Int long double等这种进行一下特殊处理。 望尽快修复~

6

被设置的值类型是integer,set方法的入参是int,在getProperty 时判断类型的时候抛出了异常,starter里设置arthas.httpPort设置成什么都会报错,这个是稳定复现的异常,会导致服务无法启动。增加Convertor转换类我觉得没必要搞那么复杂,其实只要改成相同类型就可以,或者优化getProperty的逻辑对基础类型Int long double等这种进行一下特殊处理。 望尽快修复~