Program: 157567
Project: 157567
Buggy source:
public static KeyboardCreator[] createAlphaBetKeyboards(AnyKeyboardContextProvider contextProvider){
  final ArrayList<KeyboardCreator> keyboardCreators=KeyboardCreatorsFactory.getAllCreators(contextProvider);
  Log.i("String_Node_Str","String_Node_Str" + keyboardCreators.size() + "String_Node_Str");
  final SharedPreferences sharedPreferences=contextProvider.getSharedPreferences();
  ArrayList<KeyboardCreator> keyboards=new ArrayList<KeyboardCreator>();
  for (int keyboardIndex=0; keyboardIndex < keyboardCreators.size(); keyboardIndex++) {
    final KeyboardCreator creator=keyboardCreators.get(keyboardIndex);
    final boolean keyboardIsEnabled=sharedPreferences.getBoolean(creator.getKeyboardPrefId(),keyboardIndex == 0);
    if (keyboardIsEnabled) {
      keyboards.add(creator);
    }
  }
  Collections.sort(keyboards,new Comparator<KeyboardCreator>(){
    public int compare(    KeyboardCreator k1,    KeyboardCreator k2){
      return k1.getSortOrderValue() - k2.getSortOrderValue();
    }
  }
);
  if (keyboards.size() == 0) {
    final SharedPreferences.Editor editor=sharedPreferences.edit();
    final KeyboardCreator creator=keyboardCreators.get(0);
    editor.putBoolean(creator.getKeyboardPrefId(),true);
    editor.commit();
    keyboards.add(creator);
  }
  for (  final KeyboardCreator aKeyboard : keyboards) {
    Log.d("String_Node_Str","String_Node_Str" + aKeyboard.getKeyboardPrefId());
  }
  keyboards.trimToSize();
  final KeyboardCreator[] keyboardsArray=new KeyboardCreator[keyboards.size()];
  return keyboards.toArray(keyboardsArray);
}

Fixed version (ground truth):
public static KeyboardCreator[] createAlphaBetKeyboards(AnyKeyboardContextProvider contextProvider){
  final ArrayList<KeyboardCreator> keyboardCreators=KeyboardCreatorsFactory.getAllCreators(contextProvider);
  Log.i("String_Node_Str","String_Node_Str" + keyboardCreators.size() + "String_Node_Str");
  final SharedPreferences sharedPreferences=contextProvider.getSharedPreferences();
  ArrayList<KeyboardCreator> keyboards=new ArrayList<KeyboardCreator>();
  for (int keyboardIndex=0; keyboardIndex < keyboardCreators.size(); keyboardIndex++) {
    final KeyboardCreator creator=keyboardCreators.get(keyboardIndex);
    final boolean keyboardIsEnabled=sharedPreferences.getBoolean(creator.getKeyboardPrefId(),false);
    if (keyboardIsEnabled) {
      keyboards.add(creator);
    }
  }
  Collections.sort(keyboards,new Comparator<KeyboardCreator>(){
    public int compare(    KeyboardCreator k1,    KeyboardCreator k2){
      return k1.getSortOrderValue() - k2.getSortOrderValue();
    }
  }
);
  if (keyboards.size() == 0) {
    final SharedPreferences.Editor editor=sharedPreferences.edit();
    final KeyboardCreator creator=keyboardCreators.get(0);
    editor.putBoolean(creator.getKeyboardPrefId(),true);
    editor.commit();
    keyboards.add(creator);
  }
  for (  final KeyboardCreator aKeyboard : keyboards) {
    Log.d("String_Node_Str","String_Node_Str" + aKeyboard.getKeyboardPrefId());
  }
  keyboards.trimToSize();
  final KeyboardCreator[] keyboardsArray=new KeyboardCreator[keyboards.size()];
  return keyboards.toArray(keyboardsArray);
}