fix issue IDFNH0,在方法一开始进行空判断。

This commit is contained in:
shad0wm00n
2025-12-25 00:59:03 +08:00
parent de93fa7670
commit 8408660721
2 changed files with 9 additions and 0 deletions

View File

@@ -27,6 +27,9 @@ public class HexUtil {
* @return 是否为16进制
*/
public static boolean isHexNumber(String value) {
if (StrUtil.isEmpty(value)) {
return false;
}
if (StrUtil.startWith(value, '-')) {
// issue#2875
return false;

View File

@@ -59,6 +59,12 @@ public class HexUtilTest {
assertFalse(HexUtil.isHexNumber(a));
}
@Test
public void isHexNumberTest2() {
assertFalse(HexUtil.isHexNumber(""));
assertFalse(HexUtil.isHexNumber(null));
}
@Test
public void decodeTest(){
final String str = "e8c670380cb220095268f40221fc748fa6ac39d6e930e63c30da68bad97f885d";