Program: 184869
Project: 184869
Buggy source:
/** 
 * place a temporary callerinfo object in the hands of the caller and notify caller when the actual query is done.
 */
static CallerInfoToken startGetCallerInfo(Context context,Connection c,CallerInfoAsyncQuery.OnQueryCompleteListener listener,Object cookie){
  CallerInfoToken cit;
  if (c == null) {
    cit=new CallerInfoToken();
    cit.asyncQuery=null;
    return cit;
  }
  Object userDataObject=c.getUserData();
  if (userDataObject instanceof Uri) {
    cit=new CallerInfoToken();
    cit.currentInfo=new CallerInfo();
    cit.asyncQuery=CallerInfoAsyncQuery.startQuery(QUERY_TOKEN,context,(Uri)userDataObject,sCallerInfoQueryListener,c);
    cit.asyncQuery.addQueryListener(QUERY_TOKEN,listener,cookie);
    cit.isFinal=false;
    c.setUserData(cit);
    if (DBG)     log("String_Node_Str" + userDataObject);
  }
 else   if (userDataObject == null) {
    String number=c.getAddress();
    cit=new CallerInfoToken();
    cit.currentInfo=new CallerInfo();
    if (DBG)     log("String_Node_Str" + number);
    if (!TextUtils.isEmpty(number)) {
      cit.currentInfo.phoneNumber=number;
      cit.currentInfo.cnapName=c.getCnapName();
      cit.currentInfo.name=cit.currentInfo.cnapName;
      cit.currentInfo.numberPresentation=c.getNumberPresentation();
      cit.currentInfo.namePresentation=c.getCnapNamePresentation();
      if (DBG)       log("String_Node_Str" + cit.currentInfo.cnapName + "String_Node_Str"+ cit.currentInfo.numberPresentation);
      cit.asyncQuery=CallerInfoAsyncQuery.startQuery(QUERY_TOKEN,context,number,sCallerInfoQueryListener,c);
      cit.asyncQuery.addQueryListener(QUERY_TOKEN,listener,cookie);
      cit.isFinal=false;
    }
 else {
      if (DBG)       log("String_Node_Str");
      cit.isFinal=true;
    }
    c.setUserData(cit);
    if (DBG)     log("String_Node_Str" + number);
  }
 else   if (userDataObject instanceof CallerInfoToken) {
    cit=(CallerInfoToken)userDataObject;
    if (cit.asyncQuery != null) {
      cit.asyncQuery.addQueryListener(QUERY_TOKEN,listener,cookie);
      if (DBG)       log("String_Node_Str" + listener.getClass().toString());
    }
 else {
      if (DBG)       log("String_Node_Str");
      if (cit.currentInfo == null) {
        cit.currentInfo=new CallerInfo();
      }
      cit.isFinal=true;
    }
  }
 else {
    cit=new CallerInfoToken();
    cit.currentInfo=(CallerInfo)userDataObject;
    cit.asyncQuery=null;
    cit.isFinal=true;
    if (DBG)     log("String_Node_Str");
  }
  return cit;
}

Fixed version (ground truth):
/** 
 * place a temporary callerinfo object in the hands of the caller and notify caller when the actual query is done.
 */
static CallerInfoToken startGetCallerInfo(Context context,Connection c,CallerInfoAsyncQuery.OnQueryCompleteListener listener,Object cookie){
  CallerInfoToken cit;
  if (c == null) {
    cit=new CallerInfoToken();
    cit.asyncQuery=null;
    return cit;
  }
  Object userDataObject=c.getUserData();
  if (userDataObject instanceof Uri) {
    cit=new CallerInfoToken();
    cit.currentInfo=new CallerInfo();
    cit.asyncQuery=CallerInfoAsyncQuery.startQuery(QUERY_TOKEN,context,(Uri)userDataObject,sCallerInfoQueryListener,c);
    cit.asyncQuery.addQueryListener(QUERY_TOKEN,listener,cookie);
    cit.isFinal=false;
    c.setUserData(cit);
    if (DBG)     log("String_Node_Str" + userDataObject);
  }
 else   if (userDataObject == null) {
    String number=c.getAddress();
    cit=new CallerInfoToken();
    cit.currentInfo=new CallerInfo();
    if (DBG)     log("String_Node_Str" + number);
    if (!TextUtils.isEmpty(number)) {
      cit.currentInfo.phoneNumber=number;
      cit.currentInfo.cnapName=c.getCnapName();
      cit.currentInfo.name=cit.currentInfo.cnapName;
      cit.currentInfo.numberPresentation=c.getNumberPresentation();
      cit.currentInfo.namePresentation=c.getCnapNamePresentation();
      if (DBG)       log("String_Node_Str" + cit.currentInfo.cnapName + "String_Node_Str"+ cit.currentInfo.numberPresentation);
      cit.asyncQuery=CallerInfoAsyncQuery.startQuery(QUERY_TOKEN,context,number,sCallerInfoQueryListener,c);
      cit.asyncQuery.addQueryListener(QUERY_TOKEN,listener,cookie);
      cit.isFinal=false;
    }
 else {
      if (DBG)       log("String_Node_Str");
      cit.isFinal=true;
    }
    c.setUserData(cit);
    if (DBG)     log("String_Node_Str" + number);
  }
 else   if (userDataObject instanceof CallerInfoToken) {
    cit=(CallerInfoToken)userDataObject;
    if (cit.asyncQuery != null) {
      cit.asyncQuery.addQueryListener(QUERY_TOKEN,listener,cookie);
      if (DBG)       log("String_Node_Str" + listener.getClass().toString());
    }
 else {
      String updatedNumber=c.getAddress();
      if (DBG)       log("String_Node_Str" + updatedNumber);
      if (!TextUtils.isEmpty(updatedNumber)) {
        cit.currentInfo.phoneNumber=updatedNumber;
        cit.currentInfo.cnapName=c.getCnapName();
        cit.currentInfo.name=cit.currentInfo.cnapName;
        cit.currentInfo.numberPresentation=c.getNumberPresentation();
        cit.currentInfo.namePresentation=c.getCnapNamePresentation();
        if (DBG)         log("String_Node_Str" + cit.currentInfo.cnapName + "String_Node_Str"+ cit.currentInfo.numberPresentation);
        cit.asyncQuery=CallerInfoAsyncQuery.startQuery(QUERY_TOKEN,context,updatedNumber,sCallerInfoQueryListener,c);
        cit.asyncQuery.addQueryListener(QUERY_TOKEN,listener,cookie);
        cit.isFinal=false;
      }
 else {
        if (DBG)         log("String_Node_Str");
        if (cit.currentInfo == null) {
          cit.currentInfo=new CallerInfo();
        }
        cit.isFinal=true;
      }
    }
  }
 else {
    cit=new CallerInfoToken();
    cit.currentInfo=(CallerInfo)userDataObject;
    cit.asyncQuery=null;
    cit.isFinal=true;
    if (DBG)     log("String_Node_Str");
  }
  return cit;
}