Program: 179530
Project: 179530
Buggy source:
private void processNetworkMessage(NetworkMessage message){
  if (message instanceof PlayerRegistrationMessage) {
    playerId=((PlayerRegistrationMessage)message).playerID;
    Log.i(NetworkVariables.TAG,"String_Node_Str" + playerId + "String_Node_Str");
    requestNetworkTimeSync();
  }
 else   if (message instanceof NetworkMessage) {
    NetworkMessage msg=(NetworkMessage)message;
switch (msg.getMessageType()) {
case UPDATE_MESSAGE:
      fireEvent(new NetworkEvent(this,msg),UpdateReceivedListener.class);
    break;
case REQUEST_MESSAGE:
  fireEvent(new NetworkEvent(this,msg),RequestReceivedListener.class);
break;
case INITIAL_GAME_STATE_MESSAGE:
processInitialGameState(msg);
break;
case PARTIAL_GAMESTATE_UPDATE_MESSAGE:
fireEvent(new NetworkEvent(this,msg),PartialGamestateReceivedListener.class);
break;
case GAMESTATE_UPDATE_MESSAGE:
fireEvent(new NetworkEvent(this,msg),GamestateReceivedListener.class);
break;
case GAMESTATE_REQUEST_MESSAGE:
break;
case TERMINATION_REQUEST_MESSAGE:
break;
case PEER_LIST_MESSAGE:
handlePeerListUpdate(msg);
break;
case PEER_LIST_REQUEST_MESSAGE:
break;
case LATENCY_REQUEST_MESSAGE:
NetworkMessage latMsg=new NetworkMessage("String_Node_Str");
latMsg.setMessageType(NetworkMessage.MessageType.LATENCY_RESPONSE_MESSAGE);
writeOut(latMsg);
break;
case LATENCY_RESPONSE_MESSAGE:
awaitingLatencyResponse=false;
latencyEndTime=System.currentTimeMillis();
if (latencyStartTime < latencyEndTime) {
fireEvent(new NetworkEvent(this,(latencyEndTime - latencyStartTime)),LatencyUpdateListener.class);
}
break;
case DIRECT_COMMUNICATION_MESSAGE:
if (msg instanceof NetworkMessageLarge) {
int listSize=((NetworkMessageLarge)msg).integers.size();
int sourcePlayerId=((NetworkMessageLarge)msg).integers.get(listSize - 1);
((NetworkMessageLarge)msg).integers.remove(listSize - 1);
((NetworkMessageLarge)msg).integers.remove(listSize - 2);
fireEvent(new DirectCommunicationEvent(this,msg,sourcePlayerId),DirectMessageListener.class);
}
 else if (msg instanceof NetworkMessageMedium) {
int listSize=((NetworkMessageMedium)msg).integers.size();
int sourcePlayerId=((NetworkMessageMedium)msg).integers.get(listSize - 1);
((NetworkMessageMedium)msg).integers.remove(listSize - 1);
((NetworkMessageMedium)msg).integers.remove(listSize - 2);
fireEvent(new DirectCommunicationEvent(this,msg,sourcePlayerId),DirectMessageListener.class);
}
 else {
Log.w(NetworkVariables.TAG,"String_Node_Str");
}
break;
case TIME_REQUEST:
break;
case TIME_RESPONSE:
if (timeSyncReceived == 0 && timeSyncInProgress) {
long sentTime=Long.parseLong(msg.getMessage());
long currentTime=gameClock.currentTimeMillis();
long latency=(currentTime - sentTime) / 2;
long serverTime=msg.getTimeStamp();
long clockDelta=(currentTime - latency) - serverTime;
Log.i(NetworkVariables.TAG,"String_Node_Str" + clockDelta);
gameClock.setTimeDelta(clockDelta);
timeSyncReceived++;
}
 else if (timeSyncReceived <= 5 && timeSyncInProgress) {
long sentTime=Long.parseLong(msg.getMessage());
long currentTime=gameClock.currentTimeMillis();
long latency=(currentTime - sentTime) / 2;
long serverTime=msg.getTimeStamp();
long clockDelta=(currentTime - latency) - serverTime;
gameClock.accumulateSyncPacket(gameClock.new TimeSyncPacket(latency,clockDelta));
timeSyncReceived++;
if (timeSyncReceived == 5) {
gameClock.convergeSyncPackets();
}
}
 else {
timeSyncReceived=0;
timeSyncInProgress=false;
syncTimer.cancel();
}
break;
default :
fireEvent(new NetworkEvent(this,msg),UnknownMessageTypeReceivedListener.class);
break;
}
}
}

Fixed version (ground truth):
private void processNetworkMessage(NetworkMessage message){
  if (message instanceof PlayerRegistrationMessage) {
    playerId=((PlayerRegistrationMessage)message).playerID;
    Log.i(NetworkVariables.TAG,"String_Node_Str" + playerId + "String_Node_Str");
    requestNetworkTimeSync();
  }
 else   if (message instanceof NetworkMessage) {
    NetworkMessage msg=(NetworkMessage)message;
switch (msg.getMessageType()) {
case UPDATE_MESSAGE:
      fireEvent(new NetworkEvent(this,msg),UpdateReceivedListener.class);
    break;
case REQUEST_MESSAGE:
  fireEvent(new NetworkEvent(this,msg),RequestReceivedListener.class);
break;
case INITIAL_GAME_STATE_MESSAGE:
processInitialGameState(msg);
break;
case PARTIAL_GAMESTATE_UPDATE_MESSAGE:
fireEvent(new NetworkEvent(this,msg),PartialGamestateReceivedListener.class);
break;
case GAMESTATE_UPDATE_MESSAGE:
fireEvent(new NetworkEvent(this,msg),GamestateReceivedListener.class);
break;
case GAMESTATE_REQUEST_MESSAGE:
break;
case TERMINATION_REQUEST_MESSAGE:
break;
case PEER_LIST_MESSAGE:
handlePeerListUpdate(msg);
break;
case PEER_LIST_REQUEST_MESSAGE:
break;
case LATENCY_REQUEST_MESSAGE:
NetworkMessage latMsg=new NetworkMessage("String_Node_Str");
latMsg.setMessageType(NetworkMessage.MessageType.LATENCY_RESPONSE_MESSAGE);
writeOut(latMsg);
break;
case LATENCY_RESPONSE_MESSAGE:
awaitingLatencyResponse=false;
latencyEndTime=System.currentTimeMillis();
if (latencyStartTime < latencyEndTime) {
fireEvent(new NetworkEvent(this,(latencyEndTime - latencyStartTime)),LatencyUpdateListener.class);
}
break;
case DIRECT_COMMUNICATION_MESSAGE:
if (msg instanceof NetworkMessageLarge) {
int listSize=((NetworkMessageLarge)msg).integers.size();
int sourcePlayerId=((NetworkMessageLarge)msg).integers.get(listSize - 1);
((NetworkMessageLarge)msg).integers.remove(listSize - 1);
((NetworkMessageLarge)msg).integers.remove(listSize - 2);
fireEvent(new DirectCommunicationEvent(this,msg,sourcePlayerId),DirectMessageListener.class);
}
 else if (msg instanceof NetworkMessageMedium) {
int listSize=((NetworkMessageMedium)msg).integers.size();
int sourcePlayerId=((NetworkMessageMedium)msg).integers.get(listSize - 1);
((NetworkMessageMedium)msg).integers.remove(listSize - 1);
((NetworkMessageMedium)msg).integers.remove(listSize - 2);
fireEvent(new DirectCommunicationEvent(this,msg,sourcePlayerId),DirectMessageListener.class);
}
 else {
Log.w(NetworkVariables.TAG,"String_Node_Str");
}
break;
case TIME_REQUEST:
break;
case TIME_RESPONSE:
if (timeSyncReceived == 0 && timeSyncInProgress) {
long sentTime=Long.parseLong(msg.getMessage());
long currentTime=gameClock.currentTimeMillis();
long latency=(currentTime - sentTime) / 2;
long serverTime=msg.getTimeStamp();
long clockDelta=(currentTime - latency) - serverTime;
Log.i(NetworkVariables.TAG,"String_Node_Str" + clockDelta);
gameClock.setTimeDelta(clockDelta);
timeSyncReceived++;
}
 else if (timeSyncReceived <= 5 && timeSyncInProgress) {
long sentTime=Long.parseLong(msg.getMessage());
long currentTime=gameClock.currentTimeMillis();
long latency=(currentTime - sentTime) / 2;
long serverTime=msg.getTimeStamp();
long clockDelta=(currentTime - latency) - serverTime;
gameClock.accumulateSyncPacket(gameClock.new TimeSyncPacket(latency,clockDelta));
if (timeSyncReceived == 5) {
gameClock.convergeSyncPackets();
}
timeSyncReceived++;
}
 else {
timeSyncReceived=0;
timeSyncInProgress=false;
syncTimer.cancel();
}
break;
default :
fireEvent(new NetworkEvent(this,msg),UnknownMessageTypeReceivedListener.class);
break;
}
}
}