今天发现了Bug,看下日志,应该是某个逻辑一直没进,看下代码:
String[] supportCenters = FrmConstants.SUPPORT_CENTERS.split(",");
boolean flag = false;
if (null != supportCenters && supportCenters.length > 0) {
for (String center : supportCenters) {
// upContentTypeLable.getOwnCorpOrgId()返回的为Long类型,下面这句有问题
if (null != center && null != upContentTypeLable
&& center.equals(upContentTypeLable.getOwnCorpOrgId())) {
flag = true;
break;
}
}
}
标红的这句话,判断存在问题。一个小疏忽浪费了不少时间。看下String.equals的源代码:
public boolean equals(Object anObject) { if (this == anObject) { return true; } if (anObject instanceof String) { String anotherString = (String)anObject; int n = value.length; if (n == anotherString.value.length) { char v1[] = value; char v2[] = anotherString.value; int i = 0; while (n-- != 0) { if (v1[i] != v2[i]) return false; i++; } return true; } } return false; }
很明显是绝对返回false的,以此记录,希望以后不要范这种低级错误了。