我已經寫了下面的代碼片段: -意外行爲流
public Collection<?> constructResponse (...........) throws RemoteException {
while (keyIterator.hasNext())
{
String keyValue = (String) keyIterator.next();
keyString = new StringBuilder(); // since multiple keys will be there in map need to ensure every time keyString and valueString is created
valueString = new StringBuilder();
keyString.append(keyValue + ";" + "name");
List<CustomValuePOJO> customPOJOlist = employeeValuesMap.get(keyValue);
for (CustomValuePOJO customPOJO : customPOJOlist)
{
if (protocol == null || protocol.equals(""))
{
valueString.append(rpNatPOJO.getDcnPort() + ":"+ rpNatPOJO.getProtocol() + ";");
}
else if (customPOJO .getProtocol().equals(protocol))
{
valueString.append(customPOJO .getPort() + ":"+ protocol + ";");
}
else
{ throw new RemoteException("Invalid Argument: Unsupported protocol "+ protocol);
}
}
if (valueString.length() == 0)
{
return generateErrorResponse("No info found");
}
responseMap.put(keyString.toString(), valueString.toString());
}
}
這是發生怪異的行爲是在通過customPOJO遍歷其內部ELSEIF到來,也通過執行設定的valueString值下面的代碼:
else if (customPOJO .getProtocol().equals(protocol))
{
valueString.append(customPOJO .getPort() + ":"+ protocol + ";");
}
這個ELSEIF其直接陸續上馬後
throw new RemoteException("Invalid Argument: Unsupported protocol "+ protocol);
沒有錯誤發生在追加操作中,並且在調試透視圖中檢查了該值正在成功追加到valueString中。
請告訴我所缺少的
檢查你的jar文件,有代碼不匹配的可能性。 – Batty
當你的代碼(你正在步入的)與類文件(實際上正在運行)不同步時,我已經看到了這種事情發生了 – Krease
'clean-build'並調試你的代碼 –