我不确定,并面临如下奇怪的空指针问题。有人可以在下面的代码中帮助我吗
if ((COUNTRY_CODE.equalsIgnoreCase(Country.TEST.name())) && (strCellId.matches("[0-9]*")))
正在日志文件中抛出空指针(根据行号)。我能看到的唯一违规代码是
strCellId.matches("[0-9]*")
如果
strCellId
为空
然而
StringUtils.isNotEmpty(strCellId)
在我们进入if条件之前已调用。请看情况
public static boolean validateCellId(String strCellId)
{
if (StringUtils.isNotEmpty(strCellId)) {
//here the nullpointer is coming
if ((COUNTRY_CODE.equalsIgnoreCase(Country.TEST.name())) && (strCellId.matches("[0-9]*"))) {
return true;
}
}
return false;
}