Program: 99025
Project: 99025
Buggy source:
/** 
 * Client-side handler for RPC Result packets. Logs a message to the console (unless this is a reply to a session id request) and calls the relevant callback (if it exists) dependent on whether status of the result is SUCCESS.
 * @param from
 * @param pkt
 */
private void handleRPCresult(Integer from,RPCResultPacket pkt){
  RPCRequest request=requestQueue.peek();
  if (request == null || pkt.getRequestID() != request.pckt.getRequestID()) {
    return;
  }
  Status status=pkt.getStatus();
  Command requestType=request.pckt.getRequest();
  if (requestType == Command.SESSION) {
    if (status == Status.SUCCESS) {
      serverSessionIDs.put(from,Integer.parseInt(Utility.byteArrayToString(pkt.getPayload())));
      requestQueue.poll();
    }
  }
 else {
    requestQueue.poll();
    Callback callback;
    if (status == Status.SUCCESS) {
      callback=request.success;
      logOutput("String_Node_Str" + requestType + "String_Node_Str"+ request.serverAddr);
      String payload=Utility.byteArrayToString(pkt.getPayload());
      logOutput(payload);
      if (callback != null) {
        Object[] params=callback.getParams();
        params[0]=from;
        if (pkt != null && params.length >= 2) {
          params[1]=pkt.getPayload();
        }
      }
    }
 else {
      if (status == Status.CRASH) {
        serverSessionIDs.put(from,Integer.parseInt(Utility.byteArrayToString(pkt.getPayload())));
      }
      callback=request.failure;
      logError("String_Node_Str" + requestType + "String_Node_Str"+ request.serverAddr+ "String_Node_Str"+ request.filename+ "String_Node_Str"+ status.getMsg());
      if (callback != null) {
        Object[] params=callback.getParams();
        params[0]=status.getCode();
      }
    }
    if (callback != null) {
      try {
        logOutput("String_Node_Str" + callback);
        callback.invoke();
      }
 catch (      Exception e) {
        System.out.println(e.getLocalizedMessage());
        e.printStackTrace();
      }
    }
  }
  sendNextRequest();
}

Fixed version (ground truth):
/** 
 * Client-side handler for RPC Result packets. Logs a message to the console (unless this is a reply to a session id request) and calls the relevant callback (if it exists) dependent on whether status of the result is SUCCESS.
 * @param from
 * @param pkt
 */
private void handleRPCresult(Integer from,RPCResultPacket pkt){
  RPCRequest request=requestQueue.peek();
  if (request == null || pkt.getRequestID() != request.pckt.getRequestID()) {
    return;
  }
  Status status=pkt.getStatus();
  Command requestType=request.pckt.getRequest();
  if (requestType == Command.SESSION) {
    if (status == Status.SUCCESS) {
      serverSessionIDs.put(from,Integer.parseInt(Utility.byteArrayToString(pkt.getPayload())));
      requestQueue.poll();
    }
  }
 else {
    requestQueue.poll();
    Callback callback;
    if (status == Status.SUCCESS) {
      callback=request.success;
      logOutput("String_Node_Str" + requestType + "String_Node_Str"+ request.serverAddr);
      String payload=Utility.byteArrayToString(pkt.getPayload());
      logOutput(payload);
      if (callback != null) {
        Object[] params=callback.getParams();
        params[0]=from;
        if (pkt != null && params.length >= 2) {
          params[1]=pkt.getPayload();
        }
      }
    }
 else {
      if (status == Status.CRASH) {
        serverSessionIDs.put(from,Integer.parseInt(Utility.byteArrayToString(pkt.getPayload())));
      }
      callback=request.failure;
      logError("String_Node_Str" + requestType + "String_Node_Str"+ request.serverAddr+ "String_Node_Str"+ request.filename+ "String_Node_Str"+ status.getMsg());
      if (callback != null) {
        Object[] params=callback.getParams();
        params[0]=status.getCode();
      }
    }
    if (callback != null) {
      try {
        logOutput("String_Node_Str" + callback.toString());
        Object[] params=callback.getParams();
        for (        Object param : params) {
          logOutput("String_Node_Str" + param.getClass().getName());
        }
        callback.invoke();
      }
 catch (      Exception e) {
        System.out.println(e.getLocalizedMessage());
        e.printStackTrace();
      }
    }
  }
  sendNextRequest();
}