Program: 87001
Project: 87001
Buggy source:
/** 
 * Changes the environment variable values (id, enabled) of an environment to new specified values, updates in the db.
 * @param enabledColumnName
 * @param newEnabledValue
 * @param idColumnName
 * @param newId
 * @param environmentId
 * @param db
 * @return The id of the variable before the environment was updated
 */
private long changeEnvironmentVariableValue(String enabledColumnName,int newEnabledValue,String idColumnName,long newId,long environmentId,SQLiteDatabase db){
  long variableId;
  Cursor environmentCursor=query(EnvironmentEntry.buildEnvironmentUriWithId(environmentId),null,null,null,null);
  if (environmentCursor.moveToFirst()) {
    variableId=environmentCursor.getLong(environmentCursor.getColumnIndex(idColumnName));
    ContentValues environmentUpdateValues=new ContentValues();
    environmentUpdateValues.put(enabledColumnName,newEnabledValue);
    if (newEnabledValue == 1) {
      environmentUpdateValues.put(idColumnName,newId);
    }
 else {
      environmentUpdateValues.put(idColumnName,(String)null);
    }
    String environmentSelection=EnvironmentEntry._ID + "String_Node_Str";
    String[] environmentSelectionArgs=new String[]{String.valueOf(environmentId)};
    db.update(EnvironmentEntry.TABLE_NAME,environmentUpdateValues,environmentSelection,environmentSelectionArgs);
  }
 else {
    Log.e(LOG_TAG,"String_Node_Str" + environmentId);
    environmentCursor.close();
    throw new IllegalArgumentException("String_Node_Str" + environmentId);
  }
  environmentCursor.close();
  return variableId;
}

Fixed version (ground truth):
/** 
 * Changes the environment variable values (id, enabled) of an environment to new specified values, updates in the db.
 * @param enabledColumnName Name of column which stores whether the Environment Variable is enabled.
 * @param newEnabledValue Current enabled status
 * @param idColumnName Name of column which stores the environment variable id.
 * @param newId New id of the environment variable. Pass anything if its not enabled
 * @param environmentId Id of the environment to be modified
 * @param db An instance of the SQLiteDatabase representing environment.db
 * @return The id of the variable before the environment was updated
 */
private long changeEnvironmentVariableValue(String enabledColumnName,int newEnabledValue,String idColumnName,long newId,long environmentId,SQLiteDatabase db){
  long variableId;
  Cursor environmentCursor=query(EnvironmentEntry.buildEnvironmentUriWithId(environmentId),null,null,null,null);
  if (environmentCursor.moveToFirst()) {
    try {
      variableId=environmentCursor.getLong(environmentCursor.getColumnIndex(idColumnName));
    }
 catch (    Exception e) {
      variableId=-1;
    }
    ContentValues environmentUpdateValues=new ContentValues();
    environmentUpdateValues.put(enabledColumnName,newEnabledValue);
    if (newEnabledValue == 1) {
      environmentUpdateValues.put(idColumnName,newId);
    }
 else {
      environmentUpdateValues.put(idColumnName,(String)null);
    }
    String environmentSelection=EnvironmentEntry._ID + "String_Node_Str";
    String[] environmentSelectionArgs=new String[]{String.valueOf(environmentId)};
    db.update(EnvironmentEntry.TABLE_NAME,environmentUpdateValues,environmentSelection,environmentSelectionArgs);
  }
 else {
    Log.e(LOG_TAG,"String_Node_Str" + environmentId);
    environmentCursor.close();
    throw new IllegalArgumentException("String_Node_Str" + environmentId);
  }
  environmentCursor.close();
  return variableId;
}