Program: 86221
Project: 86221
Buggy source:
public Map<String,String> saveQuery(){
  if (app.getLibrary() == null) {
    return null;
  }
  saveHomeBranch();
  Map<String,String> query=new HashMap<>();
  if (fields == null) {
    SearchFieldDataSource dataSource=new JsonSearchFieldDataSource(app);
    int versionCode=0;
    try {
      versionCode=app.getPackageManager().getPackageInfo(app.getPackageName(),0).versionCode;
    }
 catch (    NameNotFoundException e) {
      e.printStackTrace();
    }
    if (dataSource.hasSearchFields(app.getLibrary().getIdent()) && dataSource.getLastSearchFieldUpdateVersion(app.getLibrary().getIdent()) == versionCode) {
      if (task != null && !task.isCancelled()) {
        task.cancel(true);
      }
      fields=dataSource.getSearchFields(app.getLibrary().getIdent());
    }
 else {
      return null;
    }
  }
  for (  SearchField field : fields) {
    if (!field.isVisible()) {
      continue;
    }
    ViewGroup v=(ViewGroup)view.findViewWithTag(field.getId());
    if (v == null) {
      return null;
    }
    if (field instanceof TextSearchField) {
      EditText text;
      if (((TextSearchField)field).isFreeSearch()) {
        text=etSimpleSearch;
      }
 else {
        text=(EditText)v.findViewById(R.id.edittext);
      }
      query.put(field.getId(),text.getEditableText().toString());
    }
 else     if (field instanceof BarcodeSearchField) {
      EditText text=(EditText)v.findViewById(R.id.edittext);
      query.put(field.getId(),text.getEditableText().toString());
    }
 else     if (field instanceof DropdownSearchField) {
      Spinner spinner=(Spinner)v.findViewById(R.id.spinner);
      if (spinner.getSelectedItemPosition() > 0) {
        query.put(field.getId(),((DropdownSearchField)field).getDropdownValues().get(spinner.getSelectedItemPosition()).getKey());
      }
    }
 else     if (field instanceof CheckboxSearchField) {
      CheckBox checkbox=(CheckBox)v.findViewById(R.id.checkbox);
      query.put(field.getId(),String.valueOf(checkbox.isChecked()));
    }
  }
  return query;
}

Fixed version (ground truth):
public Map<String,String> saveQuery(){
  if (app.getLibrary() == null) {
    return null;
  }
  saveHomeBranch();
  Map<String,String> query=new HashMap<>();
  if (fields == null) {
    SearchFieldDataSource dataSource=new JsonSearchFieldDataSource(app);
    int versionCode=0;
    try {
      versionCode=app.getPackageManager().getPackageInfo(app.getPackageName(),0).versionCode;
    }
 catch (    NameNotFoundException e) {
      e.printStackTrace();
    }
    if (dataSource.hasSearchFields(app.getLibrary().getIdent()) && dataSource.getLastSearchFieldUpdateVersion(app.getLibrary().getIdent()) == versionCode) {
      if (task != null && !task.isCancelled()) {
        task.cancel(true);
      }
      fields=dataSource.getSearchFields(app.getLibrary().getIdent());
    }
 else {
      return null;
    }
  }
  for (  SearchField field : fields) {
    if (!field.isVisible()) {
      continue;
    }
    if (field instanceof TextSearchField && ((TextSearchField)field).isFreeSearch()) {
      query.put(field.getId(),etSimpleSearch.getEditableText().toString());
      continue;
    }
    ViewGroup v=(ViewGroup)view.findViewWithTag(field.getId());
    if (v == null) {
      continue;
    }
    if (field instanceof TextSearchField) {
      EditText text=(EditText)v.findViewById(R.id.edittext);
      query.put(field.getId(),text.getEditableText().toString());
    }
 else     if (field instanceof BarcodeSearchField) {
      EditText text=(EditText)v.findViewById(R.id.edittext);
      query.put(field.getId(),text.getEditableText().toString());
    }
 else     if (field instanceof DropdownSearchField) {
      Spinner spinner=(Spinner)v.findViewById(R.id.spinner);
      if (spinner.getSelectedItemPosition() > 0) {
        query.put(field.getId(),((DropdownSearchField)field).getDropdownValues().get(spinner.getSelectedItemPosition()).getKey());
      }
    }
 else     if (field instanceof CheckboxSearchField) {
      CheckBox checkbox=(CheckBox)v.findViewById(R.id.checkbox);
      query.put(field.getId(),String.valueOf(checkbox.isChecked()));
    }
  }
  return query;
}