Program: 29910
Project: 29910
Buggy source:
/** 
 * Add the given object to the given table, which must be defined for a table that belongs to this session's application. This is a convenience method that bundles the DBObject in a   {@link DBObjectBatch} and calls{@link #addBatch(String,DBObjectBatch)}. The   {@link ObjectResult} from the batchresult is returned.
 * @param tableName Name of table to add object to.
 * @param dbObj     {@link DBObject} of object to add to the database.
 * @return          {@link ObjectResult} of the add request. The result can be used todetermine the ID of the object if it was added by the system.
 */
public ObjectResult addObject(String tableName,DBObject dbObj){
  Utils.require(!Utils.isEmpty(tableName),"String_Node_Str");
  Utils.require(dbObj != null,"String_Node_Str");
  TableDefinition tableDef=m_appDef.getTableDef(tableName);
  Utils.require(tableDef != null,"String_Node_Str",m_appDef.getAppName(),tableName);
  try {
    DBObjectBatch dbObjBatch=new DBObjectBatch();
    dbObjBatch.addObject(dbObj);
    byte[] body=Utils.toBytes(dbObjBatch.toDoc().toJSON());
    String uri=uriRoot() + Utils.urlEncode(m_appDef.getAppName()) + "String_Node_Str"+ Utils.urlEncode(tableName);
    RESTResponse response=m_restClient.sendRequest(HttpMethod.POST,uri,ContentType.APPLICATION_JSON,body);
    m_logger.debug("String_Node_Str",response.toString());
    BatchResult batchResult=createBatchResult(response);
    ObjectResult objResult=null;
    if (batchResult.isFailed()) {
      objResult=ObjectResult.newErrorResult(batchResult.getErrorMessage(),dbObj.getObjectID());
    }
 else {
      for (      String objID : batchResult.getResultObjectIDs()) {
        objResult=batchResult.getObjectResult(objID);
        break;
      }
    }
    return objResult;
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
/** 
 * Add the given object to the given table, which must be defined for a table that belongs to this session's application. This is a convenience method that bundles the DBObject in a   {@link DBObjectBatch} and calls{@link #addBatch(String,DBObjectBatch)}. The   {@link ObjectResult} from the batchresult is returned.
 * @param tableName Name of table to add object to.
 * @param dbObj     {@link DBObject} of object to add to the database.
 * @return          {@link ObjectResult} of the add request. The result can be used todetermine the ID of the object if it was added by the system.
 */
public ObjectResult addObject(String tableName,DBObject dbObj){
  Utils.require(!Utils.isEmpty(tableName),"String_Node_Str");
  Utils.require(dbObj != null,"String_Node_Str");
  TableDefinition tableDef=m_appDef.getTableDef(tableName);
  Utils.require(tableDef != null,"String_Node_Str",m_appDef.getAppName(),tableName);
  try {
    DBObjectBatch dbObjBatch=new DBObjectBatch();
    dbObjBatch.addObject(dbObj);
    byte[] body=Utils.toBytes(dbObjBatch.toDoc().toJSON());
    StringBuilder uri=new StringBuilder("String_Node_Str");
    uri.append(Utils.urlEncode(m_appDef.getAppName()));
    uri.append("String_Node_Str");
    uri.append(Utils.urlEncode(tableName));
    addTenantParam(uri);
    RESTResponse response=m_restClient.sendRequest(HttpMethod.POST,uri.toString(),ContentType.APPLICATION_JSON,body);
    m_logger.debug("String_Node_Str",response.toString());
    BatchResult batchResult=createBatchResult(response);
    ObjectResult objResult=null;
    if (batchResult.isFailed()) {
      objResult=ObjectResult.newErrorResult(batchResult.getErrorMessage(),dbObj.getObjectID());
    }
 else {
      for (      String objID : batchResult.getResultObjectIDs()) {
        objResult=batchResult.getObjectResult(objID);
        break;
      }
    }
    return objResult;
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}