nus-yam/ex-repair huggingface dataset:
Program: 162435
Project: 162435
Buggy source:
/** 
 * Starts a media scanner to let file system know changes done to files
 */
public static void scanFile(final Context context,final MediaScannerConnection mediaScannerConnection,final String[] paths){
  Log.d("String_Node_Str",paths[0]);
  AppConfig.runInBackground(() -> {
    mediaScannerConnection.connect();
    MediaScannerConnection.scanFile(context,paths,null,null);
  }
);
}

Fixed version (ground truth):
/** 
 * Triggers   {@link Intent#ACTION_MEDIA_SCANNER_SCAN_FILE} intent to refresh the media store.
 * @param uri File's {@link Uri}
 * @param c {@link Context}
 */
public static void scanFile(@NonNull Uri uri,@NonNull Context c){
  Intent mediaScanIntent=new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,uri);
  c.sendBroadcast(mediaScanIntent);
}
Program: 162437
Project: 162437
Buggy source:
public static MaterialDialog showNameDialog(final MainActivity m,String hint,String prefill,String title,String positiveButtonText,String neutralButtonText,String negativeButtonText,MaterialDialog.SingleButtonCallback positiveButtonAction,WarnableTextInputValidator.OnTextValidate validator){
  int accentColor=m.getAccent();
  MaterialDialog.Builder builder=new MaterialDialog.Builder(m);
  View dialogView=m.getLayoutInflater().inflate(R.layout.dialog_singleedittext,null);
  EditText textfield=dialogView.findViewById(R.id.singleedittext_input);
  textfield.setHint(hint);
  textfield.setText(prefill);
  WarnableTextInputLayout tilTextfield=dialogView.findViewById(R.id.singleedittext_warnabletextinputlayout);
  builder.customView(dialogView,false).widgetColor(accentColor).theme(m.getAppTheme().getMaterialDialogTheme()).title(title).positiveText(positiveButtonText).onPositive(positiveButtonAction);
  if (neutralButtonText != null) {
    builder.neutralText(neutralButtonText);
  }
  if (negativeButtonText != null) {
    builder.negativeText(negativeButtonText);
    builder.negativeColor(accentColor);
  }
  MaterialDialog dialog=builder.show();
  new WarnableTextInputValidator(builder.getContext(),textfield,tilTextfield,dialog.getActionButton(DialogAction.POSITIVE),validator);
  return dialog;
}

Fixed version (ground truth):
public static MaterialDialog showNameDialog(final MainActivity m,String hint,String prefill,String title,String positiveButtonText,String neutralButtonText,String negativeButtonText,MaterialDialog.SingleButtonCallback positiveButtonAction,WarnableTextInputValidator.OnTextValidate validator){
  int accentColor=m.getAccent();
  MaterialDialog.Builder builder=new MaterialDialog.Builder(m);
  View dialogView=m.getLayoutInflater().inflate(R.layout.dialog_singleedittext,null);
  EditText textfield=dialogView.findViewById(R.id.singleedittext_input);
  textfield.setHint(hint);
  textfield.setText(prefill);
  WarnableTextInputLayout tilTextfield=dialogView.findViewById(R.id.singleedittext_warnabletextinputlayout);
  builder.customView(dialogView,false).widgetColor(accentColor).theme(m.getAppTheme().getMaterialDialogTheme()).title(title).positiveText(positiveButtonText).onPositive(positiveButtonAction);
  if (neutralButtonText != null) {
    builder.neutralText(neutralButtonText);
  }
  if (negativeButtonText != null) {
    builder.negativeText(negativeButtonText);
    builder.negativeColor(accentColor);
  }
  MaterialDialog dialog=builder.show();
  WarnableTextInputValidator textInputValidator=new WarnableTextInputValidator(builder.getContext(),textfield,tilTextfield,dialog.getActionButton(DialogAction.POSITIVE),validator);
  if (!TextUtils.isEmpty(prefill))   textInputValidator.afterTextChanged(textfield.getText());
  return dialog;
}
Program: 162438
Project: 162438
Buggy source:
/** 
 * Prompt a dialog to user to input file name
 * @param path     current path at which file to create
 * @param ma       {@link MainFragment} current fragment
 */
void mkfile(final OpenMode openMode,final String path,final MainFragment ma){
  mk(R.string.newfile,"String_Node_Str",(dialog,which) -> {
    EditText textfield=dialog.getCustomView().findViewById(R.id.singleedittext_input);
    mkFile(new HybridFile(openMode,path + "String_Node_Str" + textfield.getText().toString()),ma);
    dialog.dismiss();
  }
,(text) -> {
    boolean isValidFilename=FileUtil.isValidFilename(text);
    if (isValidFilename && text.length() > 0 && !text.toLowerCase().endsWith("String_Node_Str")) {
      return new WarnableTextInputValidator.ReturnState(WarnableTextInputValidator.ReturnState.STATE_WARNING,R.string.create_file_suggest_txt_extension);
    }
 else {
      if (!isValidFilename) {
        return new WarnableTextInputValidator.ReturnState(WarnableTextInputValidator.ReturnState.STATE_ERROR,R.string.invalid_name);
      }
 else       if (text.length() < 1) {
        return new WarnableTextInputValidator.ReturnState(WarnableTextInputValidator.ReturnState.STATE_ERROR,R.string.field_empty);
      }
    }
    return new WarnableTextInputValidator.ReturnState();
  }
);
}

Fixed version (ground truth):
/** 
 * Prompt a dialog to user to input file name
 * @param path     current path at which file to create
 * @param ma       {@link MainFragment} current fragment
 */
void mkfile(final OpenMode openMode,final String path,final MainFragment ma){
  mk(R.string.newfile,NEW_FILE_TXT_EXTENSION,(dialog,which) -> {
    EditText textfield=dialog.getCustomView().findViewById(R.id.singleedittext_input);
    mkFile(new HybridFile(openMode,path + "String_Node_Str" + textfield.getText().toString()),ma);
    dialog.dismiss();
  }
,(text) -> {
    boolean isValidFilename=FileUtil.isValidFilename(text);
    if (isValidFilename && text.length() > 0) {
      SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(mainActivity);
      if (text.startsWith("String_Node_Str") && !prefs.getBoolean(PreferencesConstants.PREFERENCE_SHOW_HIDDENFILES,false)) {
        return new WarnableTextInputValidator.ReturnState(WarnableTextInputValidator.ReturnState.STATE_WARNING,R.string.create_hidden_file_warn);
      }
 else       if (!text.toLowerCase().endsWith(NEW_FILE_TXT_EXTENSION)) {
        return new WarnableTextInputValidator.ReturnState(WarnableTextInputValidator.ReturnState.STATE_WARNING,R.string.create_file_suggest_txt_extension);
      }
    }
 else {
      if (!isValidFilename) {
        return new WarnableTextInputValidator.ReturnState(WarnableTextInputValidator.ReturnState.STATE_ERROR,R.string.invalid_name);
      }
 else       if (text.length() < 1) {
        return new WarnableTextInputValidator.ReturnState(WarnableTextInputValidator.ReturnState.STATE_ERROR,R.string.field_empty);
      }
    }
    return new WarnableTextInputValidator.ReturnState();
  }
);
}
Program: 162440
Project: 162440
Buggy source:
@Override public void onCreate(){
  super.onCreate();
  AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
  mInstance=this;
  utilsProvider=new UtilitiesProvider(this);
  mUtilsHandler=new UtilsHandler(this);
  sBackgroundHandlerThread.start();
  sBackgroundHandler=new Handler(sBackgroundHandlerThread.getLooper());
  StrictMode.VmPolicy.Builder builder=new StrictMode.VmPolicy.Builder();
  StrictMode.setVmPolicy(builder.build());
}

Fixed version (ground truth):
@Override public void onCreate(){
  super.onCreate();
  AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
  sBackgroundHandlerThread=new HandlerThread("String_Node_Str");
  mInstance=this;
  utilsProvider=new UtilitiesProvider(this);
  mUtilsHandler=new UtilsHandler(this);
  sBackgroundHandlerThread.start();
  sBackgroundHandler=new Handler(sBackgroundHandlerThread.getLooper());
  StrictMode.VmPolicy.Builder builder=new StrictMode.VmPolicy.Builder();
  StrictMode.setVmPolicy(builder.build());
}
Program: 162441
Project: 162441
Buggy source:
/** 
 * Initializes the floating action button to act as to save data from an external intent
 */
private void initFabToSave(final ArrayList<Uri> uris){
  floatingActionButton.removeButton(findViewById(R.id.menu_new_folder));
  floatingActionButton.removeButton(findViewById(R.id.menu_new_file));
  floatingActionButton.removeButton(findViewById(R.id.menu_new_cloud));
  floatingActionButton.setMenuButtonIcon(R.drawable.ic_file_download_white_24dp);
  floatingActionButton.getMenuButton().setOnClickListener(v -> {
    FileUtil.writeUriToStorage(MainActivity.this,uris,getContentResolver(),getCurrentMainFragment().getCurrentPath());
    Toast.makeText(MainActivity.this,getResources().getString(R.string.saving),Toast.LENGTH_LONG).show();
    finish();
  }
);
}

Fixed version (ground truth):
/** 
 * Initializes the floating action button to act as to save data from an external intent
 */
private void initFabToSave(final ArrayList<Uri> uris){
  floatingActionButton.removeButton(findViewById(R.id.menu_new_folder));
  floatingActionButton.removeButton(findViewById(R.id.menu_new_file));
  floatingActionButton.removeButton(findViewById(R.id.menu_new_cloud));
  floatingActionButton.setMenuButtonIcon(R.drawable.ic_file_download_white_24dp);
  floatingActionButton.getMenuButton().setOnClickListener(v -> {
    FileUtil.writeUriToStorage(MainActivity.this,uris,getContentResolver(),getCurrentMainFragment().getCurrentPath());
    Toast.makeText(MainActivity.this,getResources().getString(R.string.saving),Toast.LENGTH_LONG).show();
    finish();
  }
);
  floatingActionButton.setVisibility(View.VISIBLE);
  floatingActionButton.getMenuButton().show();
}
Program: 162444
Project: 162444
Buggy source:
private ArrayList<LayoutElementParcelable> listVideos(){
  ArrayList<LayoutElementParcelable> songs=new ArrayList<>();
  final String[] projection={MediaStore.Images.Media.DATA};
  final Cursor cursor=c.getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,projection,null,null,null);
  if (cursor.getCount() > 0 && cursor.moveToFirst()) {
    do {
      String path=cursor.getString(cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA));
      HybridFileParcelable strings=RootHelper.generateBaseFile(new File(path),showHiddenFiles);
      if (strings != null) {
        LayoutElementParcelable parcelable=createListParcelables(strings);
        if (parcelable != null)         songs.add(parcelable);
      }
    }
 while (cursor.moveToNext());
  }
  cursor.close();
  return songs;
}

Fixed version (ground truth):
private ArrayList<LayoutElementParcelable> listVideos(){
  ArrayList<LayoutElementParcelable> videos=new ArrayList<>();
  final String[] projection={MediaStore.Images.Media.DATA};
  final Cursor cursor=c.getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,projection,null,null,null);
  if (cursor == null)   return videos;
 else   if (cursor.getCount() > 0 && cursor.moveToFirst()) {
    do {
      String path=cursor.getString(cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA));
      HybridFileParcelable strings=RootHelper.generateBaseFile(new File(path),showHiddenFiles);
      if (strings != null) {
        LayoutElementParcelable parcelable=createListParcelables(strings);
        if (parcelable != null)         videos.add(parcelable);
      }
    }
 while (cursor.moveToNext());
  }
  cursor.close();
  return videos;
}
Program: 162445
Project: 162445
Buggy source:
private ArrayList<LayoutElementParcelable> listRecentFiles(){
  ArrayList<LayoutElementParcelable> songs=new ArrayList<>();
  final String[] projection={MediaStore.Files.FileColumns.DATA,MediaStore.Files.FileColumns.DATE_MODIFIED};
  Calendar c=Calendar.getInstance();
  c.set(Calendar.DAY_OF_YEAR,c.get(Calendar.DAY_OF_YEAR) - 2);
  Date d=c.getTime();
  Cursor cursor=this.c.getContentResolver().query(MediaStore.Files.getContentUri("String_Node_Str"),projection,null,null,null);
  if (cursor == null)   return songs;
  if (cursor.getCount() > 0 && cursor.moveToFirst()) {
    do {
      String path=cursor.getString(cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA));
      File f=new File(path);
      if (d.compareTo(new Date(f.lastModified())) != 1 && !f.isDirectory()) {
        HybridFileParcelable strings=RootHelper.generateBaseFile(new File(path),showHiddenFiles);
        if (strings != null) {
          LayoutElementParcelable parcelable=createListParcelables(strings);
          if (parcelable != null)           songs.add(parcelable);
        }
      }
    }
 while (cursor.moveToNext());
  }
  cursor.close();
  Collections.sort(songs,(lhs,rhs) -> -1 * Long.valueOf(lhs.date).compareTo(rhs.date));
  if (songs.size() > 20)   for (int i=songs.size() - 1; i > 20; i--) {
    songs.remove(i);
  }
  return songs;
}

Fixed version (ground truth):
private ArrayList<LayoutElementParcelable> listRecentFiles(){
  ArrayList<LayoutElementParcelable> recentFiles=new ArrayList<>();
  final String[] projection={MediaStore.Files.FileColumns.DATA,MediaStore.Files.FileColumns.DATE_MODIFIED};
  Calendar c=Calendar.getInstance();
  c.set(Calendar.DAY_OF_YEAR,c.get(Calendar.DAY_OF_YEAR) - 2);
  Date d=c.getTime();
  Cursor cursor=this.c.getContentResolver().query(MediaStore.Files.getContentUri("String_Node_Str"),projection,null,null,null);
  if (cursor == null)   return recentFiles;
  if (cursor.getCount() > 0 && cursor.moveToFirst()) {
    do {
      String path=cursor.getString(cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA));
      File f=new File(path);
      if (d.compareTo(new Date(f.lastModified())) != 1 && !f.isDirectory()) {
        HybridFileParcelable strings=RootHelper.generateBaseFile(new File(path),showHiddenFiles);
        if (strings != null) {
          LayoutElementParcelable parcelable=createListParcelables(strings);
          if (parcelable != null)           recentFiles.add(parcelable);
        }
      }
    }
 while (cursor.moveToNext());
  }
  cursor.close();
  Collections.sort(recentFiles,(lhs,rhs) -> -1 * Long.valueOf(lhs.date).compareTo(rhs.date));
  if (recentFiles.size() > 20)   for (int i=recentFiles.size() - 1; i > 20; i--) {
    recentFiles.remove(i);
  }
  return recentFiles;
}
Program: 162446
Project: 162446
Buggy source:
private ArrayList<LayoutElementParcelable> listImages(){
  ArrayList<LayoutElementParcelable> songs=new ArrayList<>();
  final String[] projection={MediaStore.Images.Media.DATA};
  final Cursor cursor=c.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,projection,null,null,null);
  if (cursor.getCount() > 0 && cursor.moveToFirst()) {
    do {
      String path=cursor.getString(cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA));
      HybridFileParcelable strings=RootHelper.generateBaseFile(new File(path),showHiddenFiles);
      if (strings != null) {
        LayoutElementParcelable parcelable=createListParcelables(strings);
        if (parcelable != null)         songs.add(parcelable);
      }
    }
 while (cursor.moveToNext());
  }
  cursor.close();
  return songs;
}

Fixed version (ground truth):
private ArrayList<LayoutElementParcelable> listImages(){
  ArrayList<LayoutElementParcelable> images=new ArrayList<>();
  final String[] projection={MediaStore.Images.Media.DATA};
  final Cursor cursor=c.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,projection,null,null,null);
  if (cursor == null)   return images;
 else   if (cursor.getCount() > 0 && cursor.moveToFirst()) {
    do {
      String path=cursor.getString(cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA));
      HybridFileParcelable strings=RootHelper.generateBaseFile(new File(path),showHiddenFiles);
      if (strings != null) {
        LayoutElementParcelable parcelable=createListParcelables(strings);
        if (parcelable != null)         images.add(parcelable);
      }
    }
 while (cursor.moveToNext());
  }
  cursor.close();
  return images;
}
Program: 162447
Project: 162447
Buggy source:
private ArrayList<LayoutElementParcelable> listDocs(){
  ArrayList<LayoutElementParcelable> songs=new ArrayList<>();
  final String[] projection={MediaStore.Files.FileColumns.DATA};
  Cursor cursor=c.getContentResolver().query(MediaStore.Files.getContentUri("String_Node_Str"),projection,null,null,null);
  String[] types=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  if (cursor.getCount() > 0 && cursor.moveToFirst()) {
    do {
      String path=cursor.getString(cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA));
      if (path != null && Arrays.asList(types).contains(path)) {
        HybridFileParcelable strings=RootHelper.generateBaseFile(new File(path),showHiddenFiles);
        if (strings != null) {
          LayoutElementParcelable parcelable=createListParcelables(strings);
          if (parcelable != null)           songs.add(parcelable);
        }
      }
    }
 while (cursor.moveToNext());
  }
  cursor.close();
  Collections.sort(songs,(lhs,rhs) -> -1 * Long.valueOf(lhs.date).compareTo(rhs.date));
  if (songs.size() > 20)   for (int i=songs.size() - 1; i > 20; i--) {
    songs.remove(i);
  }
  return songs;
}

Fixed version (ground truth):
private ArrayList<LayoutElementParcelable> listDocs(){
  ArrayList<LayoutElementParcelable> docs=new ArrayList<>();
  final String[] projection={MediaStore.Files.FileColumns.DATA};
  Cursor cursor=c.getContentResolver().query(MediaStore.Files.getContentUri("String_Node_Str"),projection,null,null,null);
  String[] types=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  if (cursor == null)   return docs;
 else   if (cursor.getCount() > 0 && cursor.moveToFirst()) {
    do {
      String path=cursor.getString(cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA));
      if (path != null && Arrays.asList(types).contains(path)) {
        HybridFileParcelable strings=RootHelper.generateBaseFile(new File(path),showHiddenFiles);
        if (strings != null) {
          LayoutElementParcelable parcelable=createListParcelables(strings);
          if (parcelable != null)           docs.add(parcelable);
        }
      }
    }
 while (cursor.moveToNext());
  }
  cursor.close();
  Collections.sort(docs,(lhs,rhs) -> -1 * Long.valueOf(lhs.date).compareTo(rhs.date));
  if (docs.size() > 20)   for (int i=docs.size() - 1; i > 20; i--) {
    docs.remove(i);
  }
  return docs;
}
Program: 162448
Project: 162448
Buggy source:
private ArrayList<LayoutElementParcelable> listApks(){
  ArrayList<LayoutElementParcelable> songs=new ArrayList<>();
  final String[] projection={MediaStore.Files.FileColumns.DATA};
  Cursor cursor=c.getContentResolver().query(MediaStore.Files.getContentUri("String_Node_Str"),projection,null,null,null);
  if (cursor.getCount() > 0 && cursor.moveToFirst()) {
    do {
      String path=cursor.getString(cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA));
      if (path != null && path.endsWith("String_Node_Str")) {
        HybridFileParcelable strings=RootHelper.generateBaseFile(new File(path),showHiddenFiles);
        if (strings != null) {
          LayoutElementParcelable parcelable=createListParcelables(strings);
          if (parcelable != null)           songs.add(parcelable);
        }
      }
    }
 while (cursor.moveToNext());
  }
  cursor.close();
  return songs;
}

Fixed version (ground truth):
private ArrayList<LayoutElementParcelable> listApks(){
  ArrayList<LayoutElementParcelable> apks=new ArrayList<>();
  final String[] projection={MediaStore.Files.FileColumns.DATA};
  Cursor cursor=c.getContentResolver().query(MediaStore.Files.getContentUri("String_Node_Str"),projection,null,null,null);
  if (cursor == null)   return apks;
 else   if (cursor.getCount() > 0 && cursor.moveToFirst()) {
    do {
      String path=cursor.getString(cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA));
      if (path != null && path.endsWith("String_Node_Str")) {
        HybridFileParcelable strings=RootHelper.generateBaseFile(new File(path),showHiddenFiles);
        if (strings != null) {
          LayoutElementParcelable parcelable=createListParcelables(strings);
          if (parcelable != null)           apks.add(parcelable);
        }
      }
    }
 while (cursor.moveToNext());
  }
  cursor.close();
  return apks;
}
Program: 162449
Project: 162449
Buggy source:
private ArrayList<LayoutElementParcelable> listaudio(){
  String selection=MediaStore.Audio.Media.IS_MUSIC + "String_Node_Str";
  String[] projection={MediaStore.Audio.Media.DATA};
  Cursor cursor=c.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,projection,selection,null,null);
  ArrayList<LayoutElementParcelable> songs=new ArrayList<>();
  if (cursor.getCount() > 0 && cursor.moveToFirst()) {
    do {
      String path=cursor.getString(cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA));
      HybridFileParcelable strings=RootHelper.generateBaseFile(new File(path),showHiddenFiles);
      if (strings != null) {
        LayoutElementParcelable parcelable=createListParcelables(strings);
        if (parcelable != null)         songs.add(parcelable);
      }
    }
 while (cursor.moveToNext());
  }
  cursor.close();
  return songs;
}

Fixed version (ground truth):
private ArrayList<LayoutElementParcelable> listaudio(){
  String selection=MediaStore.Audio.Media.IS_MUSIC + "String_Node_Str";
  String[] projection={MediaStore.Audio.Media.DATA};
  Cursor cursor=c.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,projection,selection,null,null);
  ArrayList<LayoutElementParcelable> songs=new ArrayList<>();
  if (cursor == null)   return songs;
 else   if (cursor.getCount() > 0 && cursor.moveToFirst()) {
    do {
      String path=cursor.getString(cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA));
      HybridFileParcelable strings=RootHelper.generateBaseFile(new File(path),showHiddenFiles);
      if (strings != null) {
        LayoutElementParcelable parcelable=createListParcelables(strings);
        if (parcelable != null)         songs.add(parcelable);
      }
    }
 while (cursor.moveToNext());
  }
  cursor.close();
  return songs;
}
Program: 162450
Project: 162450
Buggy source:
public String getOriginalPath(boolean savePaths,SharedPreferences sharedPreferences){
  if (savePaths && FileUtils.isPathAccesible(path,sharedPreferences)) {
    return path;
  }
 else {
    return home;
  }
}

Fixed version (ground truth):
public String getOriginalPath(boolean savePaths,SharedPreferences sharedPreferences){
  if (savePaths && FileUtils.isPathAccessible(path,sharedPreferences)) {
    return path;
  }
 else {
    return home;
  }
}
Program: 162452
Project: 162452
Buggy source:
private void disableButtonIfNotPath(EditText path,final MaterialDialog dialog){
  path.addTextChangedListener(new SimpleTextWatcher(){
    @Override public void afterTextChanged(    Editable s){
      dialog.getActionButton(DialogAction.POSITIVE).setEnabled(FileUtils.isPathAccesible(s.toString(),sharedPrefs));
    }
  }
);
}

Fixed version (ground truth):
private void disableButtonIfNotPath(EditText path,final MaterialDialog dialog){
  path.addTextChangedListener(new SimpleTextWatcher(){
    @Override public void afterTextChanged(    Editable s){
      dialog.getActionButton(DialogAction.POSITIVE).setEnabled(FileUtils.isPathAccessible(s.toString(),sharedPrefs));
    }
  }
);
}
Program: 162453
Project: 162453
Buggy source:
public static void showChangePathsDialog(final MainActivity mainActivity,final SharedPreferences prefs){
  final MaterialDialog.Builder a=new MaterialDialog.Builder(mainActivity);
  a.input(null,mainActivity.getCurrentMainFragment().getCurrentPath(),false,(dialog,charSequence) -> {
    boolean isAccessible=FileUtils.isPathAccesible(charSequence.toString(),prefs);
    dialog.getActionButton(DialogAction.POSITIVE).setEnabled(isAccessible);
  }
);
  a.alwaysCallInputCallback();
  int accentColor=mainActivity.getColorPreference().getColor(ColorUsage.ACCENT);
  a.widgetColor(accentColor);
  a.theme(mainActivity.getAppTheme().getMaterialDialogTheme());
  a.title(R.string.enterpath);
  a.positiveText(R.string.go);
  a.positiveColor(accentColor);
  a.negativeText(R.string.cancel);
  a.negativeColor(accentColor);
  a.onPositive((dialog,which) -> {
    mainActivity.getCurrentMainFragment().loadlist(dialog.getInputEditText().getText().toString(),false,OpenMode.UNKNOWN);
  }
);
  a.show();
}

Fixed version (ground truth):
public static void showChangePathsDialog(final MainActivity mainActivity,final SharedPreferences prefs){
  final MaterialDialog.Builder a=new MaterialDialog.Builder(mainActivity);
  a.input(null,mainActivity.getCurrentMainFragment().getCurrentPath(),false,(dialog,charSequence) -> {
    boolean isAccessible=FileUtils.isPathAccessible(charSequence.toString(),prefs);
    dialog.getActionButton(DialogAction.POSITIVE).setEnabled(isAccessible);
  }
);
  a.alwaysCallInputCallback();
  int accentColor=mainActivity.getColorPreference().getColor(ColorUsage.ACCENT);
  a.widgetColor(accentColor);
  a.theme(mainActivity.getAppTheme().getMaterialDialogTheme());
  a.title(R.string.enterpath);
  a.positiveText(R.string.go);
  a.positiveColor(accentColor);
  a.negativeText(R.string.cancel);
  a.negativeColor(accentColor);
  a.onPositive((dialog,which) -> {
    mainActivity.getCurrentMainFragment().loadlist(dialog.getInputEditText().getText().toString(),false,OpenMode.UNKNOWN);
  }
);
  a.show();
}
Program: 162455
Project: 162455
Buggy source:
public void run(){
  try {
    s.setStreamSrc(smbFile,si);
    activity.runOnUiThread(() -> {
      try {
        Uri uri=Uri.parse(Streamer.URL + Uri.fromFile(new File(Uri.parse(smbFile.getPath()).getPath())).getEncodedPath());
        Intent i=new Intent(Intent.ACTION_VIEW);
        i.setDataAndType(uri,MimeTypes.getMimeType(smbFile.getPath(),smbFile.isDirectory()));
        PackageManager packageManager=activity.getPackageManager();
        List<ResolveInfo> resInfos=packageManager.queryIntentActivities(i,0);
        if (resInfos != null && resInfos.size() > 0)         activity.startActivity(i);
 else         Toast.makeText(activity,activity.getResources().getString(R.string.smb_launch_error),Toast.LENGTH_SHORT).show();
      }
 catch (      ActivityNotFoundException|SmbException e) {
        e.printStackTrace();
      }
    }
);
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public void run(){
  try {
    s.setStreamSrc(new SmbFile(baseFile.getPath()),baseFile.getSize());
    activity.runOnUiThread(() -> {
      try {
        Uri uri=Uri.parse(Streamer.URL + Uri.fromFile(new File(Uri.parse(baseFile.getPath()).getPath())).getEncodedPath());
        Intent i=new Intent(Intent.ACTION_VIEW);
        i.setDataAndType(uri,MimeTypes.getMimeType(baseFile.getPath(),baseFile.isDirectory()));
        PackageManager packageManager=activity.getPackageManager();
        List<ResolveInfo> resInfos=packageManager.queryIntentActivities(i,0);
        if (resInfos != null && resInfos.size() > 0)         activity.startActivity(i);
 else         Toast.makeText(activity,activity.getResources().getString(R.string.smb_launch_error),Toast.LENGTH_SHORT).show();
      }
 catch (      ActivityNotFoundException e) {
        e.printStackTrace();
      }
    }
);
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
Program: 162457
Project: 162457
Buggy source:
public static void launchSMB(final SmbFile smbFile,final long si,final Activity activity){
  final Streamer s=Streamer.getInstance();
  new Thread(){
    public void run(){
      try {
        s.setStreamSrc(smbFile,si);
        activity.runOnUiThread(() -> {
          try {
            Uri uri=Uri.parse(Streamer.URL + Uri.fromFile(new File(Uri.parse(smbFile.getPath()).getPath())).getEncodedPath());
            Intent i=new Intent(Intent.ACTION_VIEW);
            i.setDataAndType(uri,MimeTypes.getMimeType(smbFile.getPath(),smbFile.isDirectory()));
            PackageManager packageManager=activity.getPackageManager();
            List<ResolveInfo> resInfos=packageManager.queryIntentActivities(i,0);
            if (resInfos != null && resInfos.size() > 0)             activity.startActivity(i);
 else             Toast.makeText(activity,activity.getResources().getString(R.string.smb_launch_error),Toast.LENGTH_SHORT).show();
          }
 catch (          ActivityNotFoundException|SmbException e) {
            e.printStackTrace();
          }
        }
);
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
    }
  }
.start();
}

Fixed version (ground truth):
public static void launchSMB(final HybridFileParcelable baseFile,final Activity activity){
  final Streamer s=Streamer.getInstance();
  new Thread(){
    public void run(){
      try {
        s.setStreamSrc(new SmbFile(baseFile.getPath()),baseFile.getSize());
        activity.runOnUiThread(() -> {
          try {
            Uri uri=Uri.parse(Streamer.URL + Uri.fromFile(new File(Uri.parse(baseFile.getPath()).getPath())).getEncodedPath());
            Intent i=new Intent(Intent.ACTION_VIEW);
            i.setDataAndType(uri,MimeTypes.getMimeType(baseFile.getPath(),baseFile.isDirectory()));
            PackageManager packageManager=activity.getPackageManager();
            List<ResolveInfo> resInfos=packageManager.queryIntentActivities(i,0);
            if (resInfos != null && resInfos.size() > 0)             activity.startActivity(i);
 else             Toast.makeText(activity,activity.getResources().getString(R.string.smb_launch_error),Toast.LENGTH_SHORT).show();
          }
 catch (          ActivityNotFoundException e) {
            e.printStackTrace();
          }
        }
);
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
    }
  }
.start();
}
Program: 162458
Project: 162458
Buggy source:
/** 
 * Starts a HTTP server to given port.<p> Throws an IOException if the socket is already in use
 */
public StreamServer(int port,File wwwroot) throws IOException {
  myTcpPort=port;
  this.myRootDir=wwwroot;
  myServerSocket=new ServerSocket(myTcpPort);
  myThread=new Thread(() -> {
    try {
      while (true) {
        Socket accept=myServerSocket.accept();
        new HTTPSession(accept);
      }
    }
 catch (    IOException ioe) {
    }
  }
);
  myThread.setDaemon(true);
  myThread.start();
}

Fixed version (ground truth):
/** 
 * Starts a HTTP server to given port.<p> Throws an IOException if the socket is already in use
 */
public StreamServer(int port,File wwwroot) throws IOException {
  myTcpPort=port;
  this.myRootDir=wwwroot;
  myServerSocket=tryBind(myTcpPort);
  myThread=new Thread(() -> {
    try {
      while (true) {
        Socket accept=myServerSocket.accept();
        new HTTPSession(accept);
      }
    }
 catch (    IOException ioe) {
    }
  }
);
  myThread.setDaemon(true);
  myThread.start();
}
Program: 162459
Project: 162459
Buggy source:
public CloudStreamServer(File wwwroot) throws IOException {
  this.myRootDir=wwwroot;
  myServerSocket=new ServerSocket(myTcpPort);
  myThread=new Thread(() -> {
    try {
      while (true) {
        Socket accept=myServerSocket.accept();
        new HTTPSession(accept);
      }
    }
 catch (    IOException ioe) {
    }
  }
);
  myThread.setDaemon(true);
  myThread.start();
}

Fixed version (ground truth):
public CloudStreamServer(File wwwroot) throws IOException {
  this.myRootDir=wwwroot;
  myServerSocket=tryBind(myTcpPort);
  myThread=new Thread(() -> {
    try {
      while (true) {
        Socket accept=myServerSocket.accept();
        new HTTPSession(accept);
      }
    }
 catch (    IOException ioe) {
    }
  }
);
  myThread.setDaemon(true);
  myThread.start();
}
Program: 162461
Project: 162461
Buggy source:
/** 
 * Initiates loading of file/uri by getting an input stream associated with it on a worker thread
 */
private void load(){
  mInput.setHint(R.string.loading);
  new ReadFileTask(getContentResolver(),mFile,getExternalCacheDir(),isRootExplorer(),(data) -> {
switch (data.error) {
case ReadFileTask.NORMAL:
      cacheFile=data.cachedFile;
    mOriginal=data.fileContents;
  try {
    mInput.setText(data.fileContents);
    if (data.fileContents.isEmpty()) {
      mInput.setHint(R.string.file_empty);
    }
 else {
      mInput.setHint(null);
    }
  }
 catch (  OutOfMemoryError e) {
    mInput.setHint(R.string.error);
  }
break;
case ReadFileTask.EXCEPTION_STREAM_NOT_FOUND:
mInput.setHint(R.string.error_file_not_found);
break;
case ReadFileTask.EXCEPTION_IO:
mInput.setHint(R.string.error_io);
break;
}
}
).execute();
}

Fixed version (ground truth):
/** 
 * Initiates loading of file/uri by getting an input stream associated with it on a worker thread
 */
private void load(){
  Snackbar.make(scrollView,R.string.loading,Snackbar.LENGTH_SHORT).show();
  new ReadFileTask(getContentResolver(),mFile,getExternalCacheDir(),isRootExplorer(),(data) -> {
switch (data.error) {
case ReadFileTask.NORMAL:
      cacheFile=data.cachedFile;
    mOriginal=data.fileContents;
  try {
    mInput.setText(data.fileContents);
    if (data.fileContents.isEmpty()) {
      mInput.setHint(R.string.file_empty);
    }
 else {
      mInput.setHint(null);
    }
  }
 catch (  OutOfMemoryError e) {
    Toast.makeText(getApplicationContext(),R.string.error,Toast.LENGTH_SHORT).show();
    finish();
  }
break;
case ReadFileTask.EXCEPTION_STREAM_NOT_FOUND:
Toast.makeText(getApplicationContext(),R.string.error_file_not_found,Toast.LENGTH_SHORT).show();
finish();
break;
case ReadFileTask.EXCEPTION_IO:
Toast.makeText(getApplicationContext(),R.string.error_io,Toast.LENGTH_SHORT).show();
finish();
break;
}
}
).execute();
}
Program: 162462
Project: 162462
Buggy source:
public ArrayList<String[]> getSmbList(){
  SQLiteDatabase sqLiteDatabase=getReadableDatabase();
  Cursor cursor=sqLiteDatabase.query(getTableForOperation(Operation.SMB),null,null,null,null,null,null);
  cursor.moveToFirst();
  ArrayList<String[]> row=new ArrayList<>();
  try {
    while (cursor.moveToNext()) {
      try {
        row.add(new String[]{cursor.getString(cursor.getColumnIndex(COLUMN_NAME)),SmbUtil.getSmbDecryptedPath(context,cursor.getString(cursor.getColumnIndex(COLUMN_PATH)))});
      }
 catch (      GeneralSecurityException|IOException e) {
        e.printStackTrace();
        Toast.makeText(context,context.getResources().getString(R.string.failed_smb_decrypt_path),Toast.LENGTH_LONG).show();
        removeSmbPath(cursor.getString(cursor.getColumnIndex(COLUMN_NAME)),"String_Node_Str");
        continue;
      }
    }
  }
  finally {
    cursor.close();
  }
  return row;
}

Fixed version (ground truth):
public ArrayList<String[]> getSmbList(){
  SQLiteDatabase sqLiteDatabase=getReadableDatabase();
  Cursor cursor=sqLiteDatabase.query(getTableForOperation(Operation.SMB),null,null,null,null,null,null);
  boolean hasNext=cursor.moveToFirst();
  ArrayList<String[]> row=new ArrayList<>();
  while (hasNext) {
    try {
      row.add(new String[]{cursor.getString(cursor.getColumnIndex(COLUMN_NAME)),SmbUtil.getSmbDecryptedPath(context,cursor.getString(cursor.getColumnIndex(COLUMN_PATH)))});
    }
 catch (    GeneralSecurityException|IOException e) {
      e.printStackTrace();
      Toast.makeText(context,context.getResources().getString(R.string.failed_smb_decrypt_path),Toast.LENGTH_LONG).show();
      removeSmbPath(cursor.getString(cursor.getColumnIndex(COLUMN_NAME)),"String_Node_Str");
      continue;
    }
    hasNext=cursor.moveToNext();
  }
  cursor.close();
  return row;
}
Program: 162463
Project: 162463
Buggy source:
public DbViewerTask(Cursor schemaCursor,Cursor contentCursor,WebView webView,DbViewerFragment dbViewerFragment){
  this.schemaCursor=schemaCursor;
  this.contentCursor=contentCursor;
  this.webView=webView;
  this.dbViewerFragment=dbViewerFragment;
  stringBuilder=new StringBuilder();
}

Fixed version (ground truth):
public DbViewerTask(Cursor schemaCursor,Cursor contentCursor,WebView webView,DbViewerFragment dbViewerFragment){
  this.schemaCursor=schemaCursor;
  this.contentCursor=contentCursor;
  this.webView=webView;
  this.dbViewerFragment=dbViewerFragment;
  stringBuilder=new StringBuilder();
  webView.getSettings().setDefaultTextEncodingName("String_Node_Str");
}
Program: 162464
Project: 162464
Buggy source:
@Override protected void onPostExecute(Void aVoid){
  super.onPostExecute(aVoid);
  dbViewerFragment.loadingText.setVisibility(View.GONE);
  stringBuilder.append("String_Node_Str");
  for (  String s : schemaList) {
    stringBuilder.append("String_Node_Str").append(s).append("String_Node_Str");
  }
  stringBuilder.append("String_Node_Str");
  for (  String[] strings : contentList) {
    stringBuilder.append("String_Node_Str");
    for (int i=0; i < strings.length; i++) {
      stringBuilder.append("String_Node_Str").append(strings[i]).append("String_Node_Str");
    }
    stringBuilder.append("String_Node_Str");
  }
  stringBuilder.append("String_Node_Str");
  webView.loadData(stringBuilder.toString(),"String_Node_Str",null);
  webView.setVisibility(View.VISIBLE);
}

Fixed version (ground truth):
@Override protected void onPostExecute(Void aVoid){
  super.onPostExecute(aVoid);
  dbViewerFragment.loadingText.setVisibility(View.GONE);
  stringBuilder.append("String_Node_Str");
  for (  String s : schemaList) {
    stringBuilder.append("String_Node_Str").append(s).append("String_Node_Str");
  }
  stringBuilder.append("String_Node_Str");
  for (  String[] strings : contentList) {
    stringBuilder.append("String_Node_Str");
    for (int i=0; i < strings.length; i++) {
      stringBuilder.append("String_Node_Str").append(strings[i]).append("String_Node_Str");
    }
    stringBuilder.append("String_Node_Str");
  }
  stringBuilder.append("String_Node_Str");
  webView.loadData(stringBuilder.toString(),"String_Node_Str","String_Node_Str");
  webView.setVisibility(View.VISIBLE);
}
Program: 162465
Project: 162465
Buggy source:
public EncryptedEntry findEntry(String path) throws GeneralSecurityException, IOException {
  String query="String_Node_Str" + TABLE_ENCRYPTED + "String_Node_Str"+ COLUMN_ENCRYPTED_PATH+ "String_Node_Str"+ path+ "String_Node_Str";
  SQLiteDatabase sqLiteDatabase=getReadableDatabase();
  Cursor cursor=sqLiteDatabase.rawQuery(query,null);
  EncryptedEntry encryptedEntry=new EncryptedEntry();
  if (cursor.moveToFirst()) {
    cursor.moveToFirst();
    encryptedEntry.setId((cursor.getInt(0)));
    encryptedEntry.setPath(cursor.getString(1));
    encryptedEntry.setPassword(CryptUtil.decryptPassword(context,cursor.getString(2)));
    cursor.close();
  }
 else {
    encryptedEntry=null;
  }
  return encryptedEntry;
}

Fixed version (ground truth):
public EncryptedEntry findEntry(String path) throws GeneralSecurityException, IOException {
  String query="String_Node_Str" + TABLE_ENCRYPTED + "String_Node_Str"+ COLUMN_ENCRYPTED_PATH+ "String_Node_Str"+ path+ "String_Node_Str";
  SQLiteDatabase sqLiteDatabase=getReadableDatabase();
  Cursor cursor=sqLiteDatabase.rawQuery(query,null);
  EncryptedEntry encryptedEntry=new EncryptedEntry();
  if (cursor.moveToFirst()) {
    encryptedEntry.setId((cursor.getInt(0)));
    encryptedEntry.setPath(cursor.getString(1));
    encryptedEntry.setPassword(CryptUtil.decryptPassword(context,cursor.getString(2)));
    cursor.close();
  }
 else {
    encryptedEntry=null;
  }
  return encryptedEntry;
}
Program: 162466
Project: 162466
Buggy source:
public List<EncryptedEntry> getAllEntries() throws GeneralSecurityException, IOException {
  List<EncryptedEntry> entryList=new ArrayList<EncryptedEntry>();
  String query="String_Node_Str" + TABLE_ENCRYPTED;
  SQLiteDatabase sqLiteDatabase=getReadableDatabase();
  Cursor cursor=null;
  try {
    cursor=sqLiteDatabase.rawQuery(query,null);
    if (cursor.getCount() > 0 && cursor.moveToFirst()) {
      do {
        EncryptedEntry encryptedEntry=new EncryptedEntry();
        encryptedEntry.setId((cursor.getInt(0)));
        encryptedEntry.setPath(cursor.getString(1));
        encryptedEntry.setPassword(CryptUtil.decryptPassword(context,cursor.getString(2)));
        entryList.add(encryptedEntry);
      }
 while (cursor.moveToNext());
    }
  }
  finally {
    if (cursor != null) {
      cursor.close();
    }
  }
  return entryList;
}

Fixed version (ground truth):
public List<EncryptedEntry> getAllEntries() throws GeneralSecurityException, IOException {
  List<EncryptedEntry> entryList=new ArrayList<EncryptedEntry>();
  String query="String_Node_Str" + TABLE_ENCRYPTED;
  SQLiteDatabase sqLiteDatabase=getReadableDatabase();
  Cursor cursor=null;
  try {
    cursor=sqLiteDatabase.rawQuery(query,null);
    boolean hasNext=cursor.moveToFirst();
    while (hasNext) {
      EncryptedEntry encryptedEntry=new EncryptedEntry();
      encryptedEntry.setId((cursor.getInt(0)));
      encryptedEntry.setPath(cursor.getString(1));
      encryptedEntry.setPassword(CryptUtil.decryptPassword(context,cursor.getString(2)));
      entryList.add(encryptedEntry);
      hasNext=cursor.moveToNext();
    }
  }
  finally {
    if (cursor != null) {
      cursor.close();
    }
  }
  return entryList;
}
Program: 162467
Project: 162467
Buggy source:
public List<Tab> getAllTabs(){
  List<Tab> tabList=new ArrayList<>();
  SQLiteDatabase sqLiteDatabase=getReadableDatabase();
  Cursor cursor=sqLiteDatabase.query(TABLE_TAB,null,null,null,null,null,null);
  try {
    if (cursor.moveToFirst() && cursor.getCount() > 0) {
      while (cursor.moveToNext()) {
        Tab tab=new Tab(cursor.getInt(0),cursor.getString(1),cursor.getString(2));
        tabList.add(tab);
      }
    }
  }
  finally {
    cursor.close();
  }
  return tabList;
}

Fixed version (ground truth):
public List<Tab> getAllTabs(){
  List<Tab> tabList=new ArrayList<>();
  SQLiteDatabase sqLiteDatabase=getReadableDatabase();
  Cursor cursor=sqLiteDatabase.query(TABLE_TAB,null,null,null,null,null,null);
  boolean hasNext=cursor.moveToFirst();
  while (hasNext) {
    Tab tab=new Tab(cursor.getInt(0),cursor.getString(1),cursor.getString(2));
    tabList.add(tab);
    hasNext=cursor.moveToNext();
  }
  cursor.close();
  return tabList;
}
Program: 162468
Project: 162468
Buggy source:
public ConcurrentRadixTree<VoidValue> getHiddenFilesConcurrentRadixTree(){
  ConcurrentRadixTree<VoidValue> paths=new ConcurrentRadixTree<>(new DefaultCharArrayNodeFactory());
  Cursor cursor=getReadableDatabase().query(getTableForOperation(Operation.HIDDEN),null,null,null,null,null,null);
  cursor.moveToFirst();
  while (cursor.moveToNext()) {
    paths.put(cursor.getString(cursor.getColumnIndex(COLUMN_PATH)),VoidValue.SINGLETON);
  }
  cursor.close();
  return paths;
}

Fixed version (ground truth):
public ConcurrentRadixTree<VoidValue> getHiddenFilesConcurrentRadixTree(){
  ConcurrentRadixTree<VoidValue> paths=new ConcurrentRadixTree<>(new DefaultCharArrayNodeFactory());
  Cursor cursor=getReadableDatabase().query(getTableForOperation(Operation.HIDDEN),null,null,null,null,null,null);
  boolean hasNext=cursor.moveToFirst();
  while (hasNext) {
    paths.put(cursor.getString(cursor.getColumnIndex(COLUMN_PATH)),VoidValue.SINGLETON);
    hasNext=cursor.moveToNext();
  }
  cursor.close();
  return paths;
}
Program: 162469
Project: 162469
Buggy source:
private ArrayList<String> getPath(Operation operation){
  SQLiteDatabase sqLiteDatabase=getReadableDatabase();
  Cursor cursor=sqLiteDatabase.query(getTableForOperation(operation),null,null,null,null,null,null);
  ArrayList<String> paths=new ArrayList<>();
switch (operation) {
case LIST:
case GRID:
    cursor.moveToFirst();
  try {
    while (cursor.moveToNext()) {
      paths.add(cursor.getString(cursor.getColumnIndex(COLUMN_PATH)));
    }
  }
  finally {
    cursor.close();
  }
return paths;
default :
return null;
}
}

Fixed version (ground truth):
private ArrayList<String> getPath(Operation operation){
  SQLiteDatabase sqLiteDatabase=getReadableDatabase();
  Cursor cursor=sqLiteDatabase.query(getTableForOperation(operation),null,null,null,null,null,null);
  ArrayList<String> paths=new ArrayList<>();
switch (operation) {
case LIST:
case GRID:
    boolean hasNext=cursor.moveToFirst();
  while (hasNext) {
    paths.add(cursor.getString(cursor.getColumnIndex(COLUMN_PATH)));
    hasNext=cursor.moveToNext();
  }
cursor.close();
return paths;
default :
return null;
}
}
Program: 162470
Project: 162470
Buggy source:
public LinkedList<String> getHistoryLinkedList(){
  SQLiteDatabase sqLiteDatabase=getReadableDatabase();
  Cursor cursor=sqLiteDatabase.query(getTableForOperation(Operation.HISTORY),null,null,null,null,null,null);
  LinkedList<String> paths=new LinkedList<>();
  cursor.moveToFirst();
  try {
    while (cursor.moveToNext()) {
      paths.push(cursor.getString(cursor.getColumnIndex(COLUMN_PATH)));
    }
  }
  finally {
    cursor.close();
  }
  return paths;
}

Fixed version (ground truth):
public LinkedList<String> getHistoryLinkedList(){
  SQLiteDatabase sqLiteDatabase=getReadableDatabase();
  Cursor cursor=sqLiteDatabase.query(getTableForOperation(Operation.HISTORY),null,null,null,null,null,null);
  LinkedList<String> paths=new LinkedList<>();
  boolean hasNext=cursor.moveToFirst();
  while (hasNext) {
    paths.push(cursor.getString(cursor.getColumnIndex(COLUMN_PATH)));
    hasNext=cursor.moveToNext();
  }
  cursor.close();
  return paths;
}
Program: 162471
Project: 162471
Buggy source:
public ArrayList<String[]> getBookmarksList(){
  SQLiteDatabase sqLiteDatabase=getReadableDatabase();
  Cursor cursor=sqLiteDatabase.query(getTableForOperation(Operation.BOOKMARKS),null,null,null,null,null,null);
  cursor.moveToFirst();
  ArrayList<String[]> row=new ArrayList<>();
  try {
    while (cursor.moveToNext()) {
      row.add(new String[]{cursor.getString(cursor.getColumnIndex(COLUMN_NAME)),cursor.getString(cursor.getColumnIndex(COLUMN_PATH))});
    }
  }
  finally {
    cursor.close();
  }
  return row;
}

Fixed version (ground truth):
public ArrayList<String[]> getBookmarksList(){
  SQLiteDatabase sqLiteDatabase=getReadableDatabase();
  Cursor cursor=sqLiteDatabase.query(getTableForOperation(Operation.BOOKMARKS),null,null,null,null,null,null);
  boolean hasNext=cursor.moveToFirst();
  ArrayList<String[]> row=new ArrayList<>();
  while (hasNext) {
    row.add(new String[]{cursor.getString(cursor.getColumnIndex(COLUMN_NAME)),cursor.getString(cursor.getColumnIndex(COLUMN_PATH))});
    hasNext=cursor.moveToNext();
  }
  cursor.close();
  return row;
}
Program: 162473
Project: 162473
Buggy source:
@Override public void onPostExecute(Boolean b){
  Intent intent=new Intent(MainActivity.KEY_INTENT_LOAD_LIST);
  String path=files.get(0).getParent(cd);
  intent.putExtra(MainActivity.KEY_INTENT_LOAD_LIST_FILE,path);
  cd.sendBroadcast(intent);
  if (!b) {
    Toast.makeText(cd,cd.getResources().getString(R.string.error),Toast.LENGTH_SHORT).show();
  }
 else   if (compressedExplorerFragment == null) {
    Toast.makeText(cd,cd.getResources().getString(R.string.done),Toast.LENGTH_SHORT).show();
  }
  if (compressedExplorerFragment != null) {
    compressedExplorerFragment.files.clear();
  }
}

Fixed version (ground truth):
@Override public void onPostExecute(Boolean wasDeleted){
  Intent intent=new Intent(MainActivity.KEY_INTENT_LOAD_LIST);
  String path=files.get(0).getParent(cd);
  intent.putExtra(MainActivity.KEY_INTENT_LOAD_LIST_FILE,path);
  cd.sendBroadcast(intent);
  if (!wasDeleted) {
    Toast.makeText(cd,cd.getResources().getString(R.string.error),Toast.LENGTH_SHORT).show();
  }
 else   if (compressedExplorerFragment == null) {
    Toast.makeText(cd,cd.getResources().getString(R.string.done),Toast.LENGTH_SHORT).show();
  }
  if (compressedExplorerFragment != null) {
    compressedExplorerFragment.files.clear();
  }
}