Program: 120792
Project: 120792
Buggy source:
/** 
 * logout
 */
public void logout() throws Exception {
  Object returnObject=null;
  try {
    if (insertItems.size() > 0) {
      SObject[] accs=insertItems.toArray(new SObject[insertItems.size()]);
      Create create=new Create();
      create.setSObjects(accs);
      SaveResult[] sr=stub.create(create,sh,co,null,null,null,null,null,null,null,null,null).getResult();
      insertItems.clear();
      accs=null;
      if (exceptionForErrors && sr != null && sr.length != 0) {
        for (        SaveResult result : sr) {
          StringBuilder errors=new StringBuilder("String_Node_Str");
          if (result.getSuccess()) {
          }
 else {
            errors=addLog(result.getErrors());
          }
          if (exceptionForErrors && errors.toString().length() > 0) {
            if (logWriter != null) {
              logWriter.close();
            }
            throw new Exception(errors.toString());
          }
        }
      }
      returnObject=sr;
    }
    if (deleteItems.size() > 0) {
      ID[] delIDs=deleteItems.toArray(new ID[deleteItems.size()]);
      Delete dels=new Delete();
      dels.setIds(delIDs);
      DeleteResponse dresp=stub.delete(dels,sh,co,null,null,null,null,null,null,null,null);
      DeleteResult[] dr=dresp.getResult();
      deleteItems.clear();
      delIDs=null;
      if (exceptionForErrors && dr != null && dr.length != 0) {
        for (        DeleteResult result : dr) {
          StringBuilder errors=new StringBuilder("String_Node_Str");
          if (result.getSuccess()) {
          }
 else {
            errors=addLog(result.getErrors());
          }
          if (exceptionForErrors && errors.toString().length() > 0) {
            if (logWriter != null) {
              logWriter.close();
            }
            throw new Exception(errors.toString());
          }
        }
      }
      returnObject=dr;
    }
    if (updateItems.size() > 0) {
      SObject[] upds=updateItems.toArray(new SObject[updateItems.size()]);
      Update update=new Update();
      update.setSObjects(upds);
      SaveResult[] saveResults=stub.update(update,sh,co,null,null,null,null,null,null,null,null,null).getResult();
      updateItems.clear();
      upds=null;
      if (exceptionForErrors && saveResults != null && saveResults.length != 0) {
        for (        SaveResult result : saveResults) {
          StringBuilder errors=new StringBuilder("String_Node_Str");
          if (result.getSuccess()) {
          }
 else {
            errors=addLog(result.getErrors());
          }
          if (exceptionForErrors && errors.toString().length() > 0) {
            if (logWriter != null) {
              logWriter.close();
            }
            throw new Exception(errors.toString());
          }
        }
      }
      returnObject=saveResults;
    }
    if (upsertItems.size() > 0) {
      SObject[] upds=upsertItems.toArray(new SObject[upsertItems.size()]);
      Upsert upsert=new Upsert();
      upsert.setSObjects(upds);
      upsert.setExternalIDFieldName(upsertKeyColumn);
      UpsertResult[] upsertResults=stub.upsert(upsert,sh,co,null,null,null,null,null,null,null,null,null).getResult();
      upsertItems.clear();
      upds=null;
      if (exceptionForErrors && upsertResults != null && upsertResults.length != 0) {
        for (        UpsertResult result : upsertResults) {
          StringBuilder errors=new StringBuilder("String_Node_Str");
          if (result.getSuccess()) {
          }
 else {
            errors=addLog(result.getErrors());
          }
          if (exceptionForErrors && errors.toString().length() > 0) {
            if (logWriter != null) {
              logWriter.close();
            }
            throw new Exception(errors.toString());
          }
        }
      }
      returnObject=upsertResults;
    }
  }
 catch (  Exception e) {
    throw new Exception(e.toString());
  }
  if (logWriter != null) {
    logWriter.close();
  }
}

Fixed version (ground truth):
/** 
 * logout
 */
public void logout() throws Exception {
  Object returnObject=null;
  try {
    if (insertItems.size() > 0) {
      SObject[] accs=insertItems.toArray(new SObject[insertItems.size()]);
      changedItemKeys=new String[accs.length];
      Create create=new Create();
      create.setSObjects(accs);
      SaveResult[] sr=stub.create(create,sh,co,null,null,null,null,null,null,null,null,null).getResult();
      insertItems.clear();
      accs=null;
      if (sr != null && sr.length != 0) {
        int batch_idx=-1;
        for (        SaveResult result : sr) {
          ++batch_idx;
          StringBuilder errors=new StringBuilder("String_Node_Str");
          if (result.getSuccess()) {
          }
 else {
            errors=addLog(result.getErrors(),batch_idx < changedItemKeys.length ? "String_Node_Str" + (batch_idx + 1) : "String_Node_Str");
          }
          if (exceptionForErrors && errors.toString().length() > 0) {
            if (logWriter != null) {
              logWriter.close();
            }
            throw new Exception(errors.toString());
          }
        }
      }
      returnObject=sr;
    }
    if (deleteItems.size() > 0) {
      ID[] delIDs=deleteItems.toArray(new ID[deleteItems.size()]);
      changedItemKeys=new String[delIDs.length];
      for (int ix=0; ix < delIDs.length; ++ix) {
        changedItemKeys[ix]=delIDs[ix].getID();
      }
      Delete dels=new Delete();
      dels.setIds(delIDs);
      DeleteResponse dresp=stub.delete(dels,sh,co,null,null,null,null,null,null,null,null);
      DeleteResult[] dr=dresp.getResult();
      deleteItems.clear();
      delIDs=null;
      if (dr != null && dr.length != 0) {
        int batch_idx=-1;
        for (        DeleteResult result : dr) {
          ++batch_idx;
          StringBuilder errors=new StringBuilder("String_Node_Str");
          if (result.getSuccess()) {
          }
 else {
            errors=addLog(result.getErrors(),batch_idx < changedItemKeys.length ? changedItemKeys[batch_idx] : "String_Node_Str");
          }
          if (exceptionForErrors && errors.toString().length() > 0) {
            if (logWriter != null) {
              logWriter.close();
            }
            throw new Exception(errors.toString());
          }
        }
      }
      returnObject=dr;
    }
    if (updateItems.size() > 0) {
      SObject[] upds=updateItems.toArray(new SObject[updateItems.size()]);
      changedItemKeys=new String[upds.length];
      for (int ix=0; ix < upds.length; ++ix) {
        changedItemKeys[ix]=upds[ix].getId().getID();
      }
      Update update=new Update();
      update.setSObjects(upds);
      SaveResult[] saveResults=stub.update(update,sh,co,null,null,null,null,null,null,null,null,null).getResult();
      updateItems.clear();
      upds=null;
      if (saveResults != null && saveResults.length != 0) {
        int batch_idx=-1;
        for (        SaveResult result : saveResults) {
          ++batch_idx;
          StringBuilder errors=new StringBuilder("String_Node_Str");
          if (result.getSuccess()) {
          }
 else {
            errors=addLog(result.getErrors(),batch_idx < changedItemKeys.length ? changedItemKeys[batch_idx] : "String_Node_Str");
          }
          if (exceptionForErrors && errors.toString().length() > 0) {
            if (logWriter != null) {
              logWriter.close();
            }
            throw new Exception(errors.toString());
          }
        }
      }
      returnObject=saveResults;
    }
    if (upsertItems.size() > 0) {
      SObject[] upds=upsertItems.toArray(new SObject[upsertItems.size()]);
      changedItemKeys=new String[upds.length];
      for (int ix=0; ix < upds.length; ++ix) {
        changedItemKeys[ix]="String_Node_Str" + upsertKeyColumn + "String_Node_Str";
        OMElement[] oms=upds[ix].getExtraElement();
        for (int iy=0; iy < oms.length; ++iy) {
          if (upsertKeyColumn != null && oms[iy] != null && upsertKeyColumn.equals(oms[iy].getLocalName())) {
            changedItemKeys[ix]=oms[iy].getText();
            break;
          }
        }
      }
      Upsert upsert=new Upsert();
      upsert.setSObjects(upds);
      upsert.setExternalIDFieldName(upsertKeyColumn);
      UpsertResult[] upsertResults=stub.upsert(upsert,sh,co,null,null,null,null,null,null,null,null,null).getResult();
      upsertItems.clear();
      upds=null;
      if (upsertResults != null && upsertResults.length != 0) {
        int batch_idx=-1;
        for (        UpsertResult result : upsertResults) {
          ++batch_idx;
          StringBuilder errors=new StringBuilder("String_Node_Str");
          if (result.getSuccess()) {
          }
 else {
            errors=addLog(result.getErrors(),batch_idx < changedItemKeys.length ? changedItemKeys[batch_idx] : "String_Node_Str");
          }
          if (exceptionForErrors && errors.toString().length() > 0) {
            if (logWriter != null) {
              logWriter.close();
            }
            throw new Exception(errors.toString());
          }
        }
      }
      returnObject=upsertResults;
    }
  }
 catch (  Exception e) {
    throw new Exception(e.toString());
  }
  if (logWriter != null) {
    logWriter.close();
  }
}