Program: 86167
Project: 86167
Buggy source:
protected void reservationStart(){
  if (invalidated) {
    new RestoreSessionTask(false).execute();
  }
  OpacApi api=null;
  try {
    api=app.getApi();
  }
 catch (  OpacClient.LibraryRemovedException e) {
    return;
  }
  if (api instanceof EbookServiceApi) {
    SharedPreferences sp=PreferenceManager.getDefaultSharedPreferences(getActivity());
    if (sp.getString("String_Node_Str","String_Node_Str").equals("String_Node_Str") && ((EbookServiceApi)api).isEbook(item)) {
      AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
      builder.setMessage(getString(R.string.opac_error_email)).setCancelable(false).setNegativeButton(R.string.close,new DialogInterface.OnClickListener(){
        @Override public void onClick(        DialogInterface dialog,        int id){
          dialog.cancel();
        }
      }
).setPositiveButton(R.string.prefs,new DialogInterface.OnClickListener(){
        @Override public void onClick(        DialogInterface dialog,        int id){
          dialog.dismiss();
          app.toPrefs(getActivity());
        }
      }
);
      AlertDialog alert=builder.create();
      alert.show();
      return;
    }
  }
  AccountDataSource data=new AccountDataSource(getActivity());
  final List<Account> accounts=data.getAccountsWithPassword(app.getLibrary().getIdent());
  if (accounts.size() == 0) {
    dialog_no_credentials();
  }
 else   if (accounts.size() > 1 && !getActivity().getIntent().getBooleanExtra("String_Node_Str",false) && (api.getSupportFlags() & OpacApi.SUPPORT_FLAG_CHANGE_ACCOUNT) != 0 && !(SearchResultDetailFragment.this.id == null || SearchResultDetailFragment.this.id.equals("String_Node_Str") || SearchResultDetailFragment.this.id.equals("String_Node_Str"))) {
    AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
    LayoutInflater inflater=getLayoutInflater(null);
    View view=inflater.inflate(R.layout.dialog_simple_list,null,false);
    ListView lv=(ListView)view.findViewById(R.id.lvBibs);
    AccountListAdapter adapter=new AccountListAdapter(getActivity(),accounts);
    lv.setAdapter(adapter);
    lv.setOnItemClickListener(new OnItemClickListener(){
      @Override public void onItemClick(      AdapterView<?> parent,      View view,      int position,      long id){
        if (accounts.get(position).getId() != app.getAccount().getId() || account_switched) {
          if (SearchResultDetailFragment.this.id == null || SearchResultDetailFragment.this.id.equals("String_Node_Str") || SearchResultDetailFragment.this.id.equals("String_Node_Str")) {
            Toast.makeText(getActivity(),R.string.accchange_sorry,Toast.LENGTH_LONG).show();
          }
 else {
            if (app.getAccount().getId() != accounts.get(position).getId()) {
              app.setAccount(accounts.get(position).getId());
            }
            Intent intent=new Intent(getActivity(),SearchResultDetailActivity.class);
            intent.putExtra(SearchResultDetailFragment.ARG_ITEM_ID,SearchResultDetailFragment.this.id);
            intent.putExtra("String_Node_Str",true);
            startActivity(intent);
          }
        }
 else {
          reservationDo();
        }
        adialog.dismiss();
      }
    }
);
    builder.setTitle(R.string.account_select).setView(view).setNegativeButton(R.string.cancel,new DialogInterface.OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int id){
        adialog.cancel();
      }
    }
);
    adialog=builder.create();
    adialog.show();
  }
 else {
    reservationDo();
  }
}

Fixed version (ground truth):
protected void reservationStart(){
  if (invalidated) {
    new RestoreSessionTask(false).execute();
  }
  OpacApi api=null;
  try {
    api=app.getApi();
  }
 catch (  OpacClient.LibraryRemovedException e) {
    return;
  }
  if (api instanceof EbookServiceApi) {
    SharedPreferences sp=PreferenceManager.getDefaultSharedPreferences(getActivity());
    if (sp.getString("String_Node_Str","String_Node_Str").equals("String_Node_Str") && ((EbookServiceApi)api).isEbook(item)) {
      AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
      builder.setMessage(getString(R.string.opac_error_email)).setCancelable(false).setNegativeButton(R.string.close,new DialogInterface.OnClickListener(){
        @Override public void onClick(        DialogInterface dialog,        int id){
          dialog.cancel();
        }
      }
).setPositiveButton(R.string.prefs,new DialogInterface.OnClickListener(){
        @Override public void onClick(        DialogInterface dialog,        int id){
          dialog.dismiss();
          app.toPrefs(getActivity());
        }
      }
);
      AlertDialog alert=builder.create();
      alert.show();
      return;
    }
  }
  AccountDataSource data=new AccountDataSource(getActivity());
  final List<Account> accounts=data.getAccountsWithPassword(app.getLibrary().getIdent());
  if (accounts.size() == 0) {
    dialog_no_credentials();
  }
 else   if (accounts.size() > 1 && !getActivity().getIntent().getBooleanExtra("String_Node_Str",false) && (api.getSupportFlags() & OpacApi.SUPPORT_FLAG_CHANGE_ACCOUNT) != 0 && !(SearchResultDetailFragment.this.id == null || SearchResultDetailFragment.this.id.equals("String_Node_Str") || SearchResultDetailFragment.this.id.equals("String_Node_Str"))) {
    AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
    LayoutInflater inflater=getActivity().getLayoutInflater();
    View view=inflater.inflate(R.layout.dialog_simple_list,null,false);
    ListView lv=(ListView)view.findViewById(R.id.lvBibs);
    AccountListAdapter adapter=new AccountListAdapter(getActivity(),accounts);
    lv.setAdapter(adapter);
    lv.setOnItemClickListener(new OnItemClickListener(){
      @Override public void onItemClick(      AdapterView<?> parent,      View view,      int position,      long id){
        if (accounts.get(position).getId() != app.getAccount().getId() || account_switched) {
          if (SearchResultDetailFragment.this.id == null || SearchResultDetailFragment.this.id.equals("String_Node_Str") || SearchResultDetailFragment.this.id.equals("String_Node_Str")) {
            Toast.makeText(getActivity(),R.string.accchange_sorry,Toast.LENGTH_LONG).show();
          }
 else {
            if (app.getAccount().getId() != accounts.get(position).getId()) {
              app.setAccount(accounts.get(position).getId());
            }
            Intent intent=new Intent(getActivity(),SearchResultDetailActivity.class);
            intent.putExtra(SearchResultDetailFragment.ARG_ITEM_ID,SearchResultDetailFragment.this.id);
            intent.putExtra("String_Node_Str",true);
            startActivity(intent);
          }
        }
 else {
          reservationDo();
        }
        adialog.dismiss();
      }
    }
);
    builder.setTitle(R.string.account_select).setView(view).setNegativeButton(R.string.cancel,new DialogInterface.OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int id){
        adialog.cancel();
      }
    }
);
    adialog=builder.create();
    adialog.show();
  }
 else {
    reservationDo();
  }
}