0
我不确定是否面临奇怪的空指针问题,如下所示。有人可以请帮我在这下面的代码StringUtils.isNotEmpty(str)在hadoop集群数据验证上似乎无法正常工作
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;
}
空指针异常在哪一行?什么呼叫? – Chiron
我已更新代码中的评论。我也相信,即使我们把这个validateCellId方法称为null,那么stringutil应该小心,不应该允许进入内部如果条件。请让我知道如果我缺少明显的东西 –
你能提供堆栈轨道吗?您可能会忘记初始化“COUNTRY_CODE”或“Country.TEST”。 – zsxwing