Program: 86278
Project: 86278
Buggy source:
@Override public List<SearchField> getSearchFields(MetaDataSource metadata,Library library) throws OpacErrorException {
  try {
    metadata.open();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  if (!metadata.hasMeta(library.getIdent())) {
    try {
      start();
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
  if (!metadata.hasMeta(library.getIdent()))   throw new OpacErrorException("String_Node_Str");
  Map<String,String> all=new HashMap<String,String>();
  all.put("String_Node_Str","String_Node_Str");
  all.put("String_Node_Str","String_Node_Str");
  List<SearchField> searchFields=new ArrayList<SearchField>();
  Set<String> fieldsCompat=new HashSet<String>(Arrays.asList(getSearchFieldsCompat()));
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_FREE)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_FREE,"String_Node_Str",false,false,"String_Node_Str",true,false));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_TITLE)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_TITLE,"String_Node_Str",false,false,"String_Node_Str",false,false));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_AUTHOR)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_AUTHOR,"String_Node_Str",false,false,"String_Node_Str",false,false));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_DIGITAL)) {
    searchFields.add(new CheckboxSearchField(KEY_SEARCH_QUERY_DIGITAL,"String_Node_Str",false));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_AVAILABLE)) {
    searchFields.add(new CheckboxSearchField(KEY_SEARCH_QUERY_AVAILABLE,"String_Node_Str",false));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_ISBN)) {
    searchFields.add(new BarcodeSearchField(KEY_SEARCH_QUERY_ISBN,"String_Node_Str",false,false,"String_Node_Str"));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_BARCODE)) {
    searchFields.add(new BarcodeSearchField(KEY_SEARCH_QUERY_BARCODE,"String_Node_Str",false,true,"String_Node_Str"));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_YEAR)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_YEAR,"String_Node_Str",false,false,"String_Node_Str",false,true));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_YEAR_RANGE_START)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_YEAR_RANGE_START,"String_Node_Str",false,false,"String_Node_Str",false,true));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_YEAR_RANGE_END)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_YEAR_RANGE_END,"String_Node_Str",false,true,"String_Node_Str",false,true));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_BRANCH)) {
    List<Map<String,String>> data=metadata.getMeta(library.getIdent(),MetaDataSource.META_TYPE_BRANCH);
    data.add(0,all);
    searchFields.add(new DropdownSearchField(KEY_SEARCH_QUERY_BRANCH,"String_Node_Str",false,data));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_HOME_BRANCH)) {
    List<Map<String,String>> data=metadata.getMeta(library.getIdent(),MetaDataSource.META_TYPE_HOME_BRANCH);
    data.add(0,all);
    searchFields.add(new DropdownSearchField(KEY_SEARCH_QUERY_HOME_BRANCH,"String_Node_Str",false,data));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_CATEGORY)) {
    List<Map<String,String>> data=metadata.getMeta(library.getIdent(),MetaDataSource.META_TYPE_CATEGORY);
    data.add(0,all);
    searchFields.add(new DropdownSearchField(KEY_SEARCH_QUERY_CATEGORY,"String_Node_Str",false,data));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_PUBLISHER)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_PUBLISHER,"String_Node_Str",false,false,"String_Node_Str",false,false));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_KEYWORDA)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_KEYWORDA,"String_Node_Str",true,false,"String_Node_Str",false,false));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_KEYWORDB)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_KEYWORDB,"String_Node_Str",true,true,"String_Node_Str",false,false));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_SYSTEM)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_SYSTEM,"String_Node_Str",true,false,"String_Node_Str",false,false));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_AUDIENCE)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_AUDIENCE,"String_Node_Str",true,false,"String_Node_Str",false,false));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_LOCATION)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_LOCATION,"String_Node_Str",false,false,"String_Node_Str",false,false));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_ORDER)) {
  }
  return searchFields;
}

Fixed version (ground truth):
@Override public List<SearchField> getSearchFields(MetaDataSource metadata,Library library) throws OpacErrorException {
  List<SearchField> searchFields=new ArrayList<SearchField>();
  Set<String> fieldsCompat=new HashSet<String>(Arrays.asList(getSearchFieldsCompat()));
  try {
    metadata.open();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_BRANCH) || fieldsCompat.contains(KEY_SEARCH_QUERY_HOME_BRANCH) || fieldsCompat.contains(KEY_SEARCH_QUERY_CATEGORY)) {
    if (!metadata.hasMeta(library.getIdent())) {
      metadata.close();
      try {
        start();
      }
 catch (      IOException e) {
        e.printStackTrace();
      }
      try {
        metadata.open();
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
    }
    if (!metadata.hasMeta(library.getIdent()))     throw new OpacErrorException("String_Node_Str");
  }
  Map<String,String> all=new HashMap<String,String>();
  all.put("String_Node_Str","String_Node_Str");
  all.put("String_Node_Str","String_Node_Str");
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_FREE)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_FREE,"String_Node_Str",false,false,"String_Node_Str",true,false));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_TITLE)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_TITLE,"String_Node_Str",false,false,"String_Node_Str",false,false));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_AUTHOR)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_AUTHOR,"String_Node_Str",false,false,"String_Node_Str",false,false));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_DIGITAL)) {
    searchFields.add(new CheckboxSearchField(KEY_SEARCH_QUERY_DIGITAL,"String_Node_Str",false));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_AVAILABLE)) {
    searchFields.add(new CheckboxSearchField(KEY_SEARCH_QUERY_AVAILABLE,"String_Node_Str",false));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_ISBN)) {
    searchFields.add(new BarcodeSearchField(KEY_SEARCH_QUERY_ISBN,"String_Node_Str",false,false,"String_Node_Str"));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_BARCODE)) {
    searchFields.add(new BarcodeSearchField(KEY_SEARCH_QUERY_BARCODE,"String_Node_Str",false,true,"String_Node_Str"));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_YEAR)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_YEAR,"String_Node_Str",false,false,"String_Node_Str",false,true));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_YEAR_RANGE_START)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_YEAR_RANGE_START,"String_Node_Str",false,false,"String_Node_Str",false,true));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_YEAR_RANGE_END)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_YEAR_RANGE_END,"String_Node_Str",false,true,"String_Node_Str",false,true));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_BRANCH)) {
    List<Map<String,String>> data=metadata.getMeta(library.getIdent(),MetaDataSource.META_TYPE_BRANCH);
    data.add(0,all);
    searchFields.add(new DropdownSearchField(KEY_SEARCH_QUERY_BRANCH,"String_Node_Str",false,data));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_HOME_BRANCH)) {
    List<Map<String,String>> data=metadata.getMeta(library.getIdent(),MetaDataSource.META_TYPE_HOME_BRANCH);
    data.add(0,all);
    searchFields.add(new DropdownSearchField(KEY_SEARCH_QUERY_HOME_BRANCH,"String_Node_Str",false,data));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_CATEGORY)) {
    List<Map<String,String>> data=metadata.getMeta(library.getIdent(),MetaDataSource.META_TYPE_CATEGORY);
    data.add(0,all);
    searchFields.add(new DropdownSearchField(KEY_SEARCH_QUERY_CATEGORY,"String_Node_Str",false,data));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_PUBLISHER)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_PUBLISHER,"String_Node_Str",false,false,"String_Node_Str",false,false));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_KEYWORDA)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_KEYWORDA,"String_Node_Str",true,false,"String_Node_Str",false,false));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_KEYWORDB)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_KEYWORDB,"String_Node_Str",true,true,"String_Node_Str",false,false));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_SYSTEM)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_SYSTEM,"String_Node_Str",true,false,"String_Node_Str",false,false));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_AUDIENCE)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_AUDIENCE,"String_Node_Str",true,false,"String_Node_Str",false,false));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_LOCATION)) {
    searchFields.add(new TextSearchField(KEY_SEARCH_QUERY_LOCATION,"String_Node_Str",false,false,"String_Node_Str",false,false));
  }
  if (fieldsCompat.contains(KEY_SEARCH_QUERY_ORDER)) {
  }
  return searchFields;
}