hutool icon indicating copy to clipboard operation
hutool copied to clipboard

HexUtil.isHexNumber()判断逻辑有问题

Open dujunchen opened this issue 2 years ago • 1 comments

版本情况

JDK版本: openjdk_11 hutool版本: 5.8.5

问题描述(包括截图)

"0x0000000000000001158e460913d00000"是一个合法的16进制数字字符串,可以使用BigInteger转换为对应的十进制,但是该方法却返回false

  1. 复现代码 // 原本应该返回true,但是却返回false System.out.println(HexUtil.isHexNumber("0x0000000000000001158e460913d00000")); //使用BigInteger转换为对应的十进制,正常 System.out.println(new BigInteger("0000000000000001158e460913d00000",16));

dujunchen avatar Nov 22 '22 07:11 dujunchen

确实是有这个问题, HexUtil中默认使用Long类型来校验, 没想到你有这么大的十六进制数字

ZZemptypoint avatar Nov 22 '22 08:11 ZZemptypoint

见:https://gitee.com/dromara/hutool/issues/I62H7K

looly avatar Nov 26 '22 17:11 looly