Program: 87024
Project: 87024
Buggy source:
public static Environment getFullEnvironment(Context context,String environmentName){
  String selection=EnvironmentEntry.COLUMN_NAME + "String_Node_Str";
  String[] selectionArgs=new String[]{environmentName};
  Cursor envCursor=context.getContentResolver().query(EnvironmentEntry.CONTENT_URI,null,selection,selectionArgs,null);
  Environment e;
  if (envCursor.moveToFirst()) {
    long environmentId=envCursor.getLong(envCursor.getColumnIndex(EnvironmentEntry._ID));
    Cursor bluetoothCursor=context.getContentResolver().query(EnvironmentEntry.buildEnvironmentUriWithIdAndBluetooth(environmentId),null,null,null,null), wifiCursor=context.getContentResolver().query(EnvironmentEntry.buildEnvironmentUriWithIdAndWifi(environmentId),null,null,null,null), locationCursor=context.getContentResolver().query(EnvironmentEntry.buildEnvironmentUriWithIdAndLocation(environmentId),null,null,null,null);
    List<EnvironmentVariable> environmentVariables=DatabaseToObjectMapper.getBluetoothEnvironmentVariablesFromCursor(bluetoothCursor);
    environmentVariables.addAll(DatabaseToObjectMapper.getLocationEnvironmentVariablesFromCursor(locationCursor));
    environmentVariables.addAll(DatabaseToObjectMapper.getWiFiEnvironmentVariablesFromCursor(wifiCursor));
    environmentVariables.addAll(DatabaseToObjectMapper.getNoiseLevelEnvironmentVariablesFromCursor(envCursor));
    e=new Environment(environmentName,environmentVariables);
    e.setBluetoothAllOrAny(envCursor.getInt(envCursor.getColumnIndex(EnvironmentEntry.COLUMN_BLUETOOTH_ALL_OR_ANY)) == 1);
    e.setHint(envCursor.getString(envCursor.getColumnIndex(EnvironmentEntry.COLUMN_ENVIRONMENT_HINT)));
  }
 else {
    return null;
  }
  return e;
}

Fixed version (ground truth):
public static Environment getFullEnvironment(Context context,String environmentName){
  String selection=EnvironmentEntry.COLUMN_NAME + "String_Node_Str";
  String[] selectionArgs=new String[]{environmentName};
  Cursor envCursor=context.getContentResolver().query(EnvironmentEntry.CONTENT_URI,null,selection,selectionArgs,null);
  Environment e;
  if (envCursor.moveToFirst()) {
    long environmentId=envCursor.getLong(envCursor.getColumnIndex(EnvironmentEntry._ID));
    Cursor bluetoothCursor=context.getContentResolver().query(EnvironmentEntry.buildEnvironmentUriWithIdAndBluetooth(environmentId),null,null,null,null), wifiCursor=context.getContentResolver().query(EnvironmentEntry.buildEnvironmentUriWithIdAndWifi(environmentId),null,null,null,null), locationCursor=context.getContentResolver().query(EnvironmentEntry.buildEnvironmentUriWithIdAndLocation(environmentId),null,null,null,null);
    List<EnvironmentVariable> environmentVariables=DatabaseToObjectMapper.getBluetoothEnvironmentVariablesFromCursor(bluetoothCursor);
    environmentVariables.addAll(DatabaseToObjectMapper.getLocationEnvironmentVariablesFromCursor(locationCursor));
    environmentVariables.addAll(DatabaseToObjectMapper.getWiFiEnvironmentVariablesFromCursor(wifiCursor));
    environmentVariables.addAll(DatabaseToObjectMapper.getNoiseLevelEnvironmentVariablesFromCursor(envCursor));
    e=new Environment(environmentName,environmentVariables);
    e.setBluetoothAllOrAny(envCursor.getInt(envCursor.getColumnIndex(EnvironmentEntry.COLUMN_BLUETOOTH_ALL_OR_ANY)) == 1);
    e.setHint(envCursor.getString(envCursor.getColumnIndex(EnvironmentEntry.COLUMN_ENVIRONMENT_HINT)));
    e.setEnabled(envCursor.getInt(envCursor.getColumnIndex(EnvironmentEntry.COLUMN_IS_ENABLED)) == 1);
  }
 else {
    return null;
  }
  return e;
}