내가 쓴 다음 코드 흐름 : -예기치 않은 동작이
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의 값을 설정하는 것입니다 아래 코드 :이 자사의 라인에 직접 오는 ELSEIF 후
else if (customPOJO .getProtocol().equals(protocol))
{
valueString.append(customPOJO .getPort() + ":"+ protocol + ";");
}
throw new RemoteException("Invalid Argument: Unsupported protocol "+ protocol);
,
추가 작업 중에 오류가 발생하지 않고 디버그 퍼스펙티브에서 값이 valueString에 성공적으로 추가되고 있는지 확인합니다.
내가 행동의이 종류가 발생할 수내가 대신 주석의 대답으로 이것을 넣어야
jar 파일을 확인하면 코드가 일치하지 않을 수 있습니다. – Batty
코드가 (실제로 실행중인) 클래스 파일과 동기화되지 않을 때 – Krease
'clean-build'하고 코드를 디버그 할 때 이런 일이 발생했습니다. –