Program: 86192
Project: 86192
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
  final String bib=app.getLibrary().getIdent();
  if (item.getItemId() == R.id.action_reservation) {
    reservationStart();
    return true;
  }
 else   if (item.getItemId() == R.id.action_lendebook) {
    bookingStart();
    return true;
  }
 else   if (item.getItemId() == R.id.action_tocollection) {
    if (getActivity().getIntent().getBooleanExtra("String_Node_Str",false)) {
      getActivity().finish();
    }
 else {
      Intent intent=new Intent(getActivity(),SearchResultDetailActivity.class);
      intent.putExtra(SearchResultDetailFragment.ARG_ITEM_ID,getItem().getCollectionId());
      startActivity(intent);
      getActivity().finish();
    }
    return true;
  }
 else   if (item.getItemId() == R.id.action_share) {
    if (getItem() == null) {
      Toast toast=Toast.makeText(getActivity(),getString(R.string.share_wait),Toast.LENGTH_SHORT);
      toast.show();
    }
 else {
      final String title=getItem().getTitle();
      final String id=getItem().getId();
      final CharSequence[] items={getString(R.string.share_link),getString(R.string.share_details)};
      AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
      builder.setTitle(R.string.share_dialog_select);
      builder.setItems(items,new DialogInterface.OnClickListener(){
        @Override public void onClick(        DialogInterface dialog,        int di){
          if (di == 0) {
            Intent intent=new Intent(android.content.Intent.ACTION_SEND);
            intent.setType("String_Node_Str");
            intent.addFlags(CompatibilityUtils.getNewDocumentIntentFlag());
            intent.putExtra(Intent.EXTRA_SUBJECT,title);
            String t=title;
            try {
              t=java.net.URLEncoder.encode(t,"String_Node_Str");
            }
 catch (            UnsupportedEncodingException e) {
            }
            String shareUrl=app.getApi().getShareUrl(id,t);
            if (shareUrl != null) {
              intent.putExtra(Intent.EXTRA_TEXT,shareUrl);
              startActivity(Intent.createChooser(intent,getResources().getString(R.string.share)));
            }
 else {
              Toast toast=Toast.makeText(getActivity(),getString(R.string.share_notsupported),Toast.LENGTH_SHORT);
              toast.show();
            }
          }
 else {
            Intent intent=new Intent(android.content.Intent.ACTION_SEND);
            intent.setType("String_Node_Str");
            intent.addFlags(CompatibilityUtils.getNewDocumentIntentFlag());
            intent.putExtra(Intent.EXTRA_SUBJECT,title);
            String t=title;
            try {
              t=t != null ? java.net.URLEncoder.encode(t,"String_Node_Str") : "String_Node_Str";
            }
 catch (            UnsupportedEncodingException e) {
            }
            String text=t + "String_Node_Str";
            for (            Detail detail : getItem().getDetails()) {
              String colon="String_Node_Str";
              if (!detail.getDesc().endsWith("String_Node_Str")) {
                colon="String_Node_Str";
              }
              text+=detail.getDesc() + colon + "String_Node_Str"+ detail.getContent()+ "String_Node_Str";
            }
            String shareUrl=app.getApi().getShareUrl(id,t);
            if (shareUrl != null) {
              text+=shareUrl;
            }
            intent.putExtra(Intent.EXTRA_TEXT,text);
            startActivity(Intent.createChooser(intent,getResources().getString(R.string.share)));
          }
        }
      }
);
      AlertDialog alert=builder.create();
      alert.show();
    }
    return true;
  }
 else   if (item.getItemId() == R.id.action_star) {
    StarDataSource star=new StarDataSource(getActivity());
    if (getItem() == null) {
      Toast toast=Toast.makeText(getActivity(),getString(R.string.star_wait),Toast.LENGTH_SHORT);
      toast.show();
    }
 else     if (getItem().getId() == null || getItem().getId().equals("String_Node_Str")) {
      final String title=getItem().getTitle();
      if (star.isStarredTitle(bib,title)) {
        star.remove(star.getItemByTitle(bib,title));
        item.setIcon(R.drawable.ic_star_0_white_24dp);
      }
 else {
        star.star(null,title,bib,getItem().getMediaType());
        Toast toast=Toast.makeText(getActivity(),getString(R.string.starred),Toast.LENGTH_SHORT);
        toast.show();
        item.setIcon(R.drawable.ic_star_1_white_24dp);
      }
    }
 else {
      final String title=getItem().getTitle();
      final String id=getItem().getId();
      if (star.isStarred(bib,id)) {
        star.remove(star.getItem(bib,id));
        item.setIcon(R.drawable.ic_star_0_white_24dp);
      }
 else {
        star.star(id,title,bib,getItem().getMediaType());
        Toast toast=Toast.makeText(getActivity(),getString(R.string.starred),Toast.LENGTH_SHORT);
        toast.show();
        item.setIcon(R.drawable.ic_star_1_white_24dp);
      }
    }
    return true;
  }
 else {
    return super.onOptionsItemSelected(item);
  }
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
  final String bib=app.getLibrary().getIdent();
  if (item.getItemId() == R.id.action_reservation) {
    reservationStart();
    return true;
  }
 else   if (item.getItemId() == R.id.action_lendebook) {
    bookingStart();
    return true;
  }
 else   if (item.getItemId() == R.id.action_tocollection) {
    if (getActivity().getIntent().getBooleanExtra("String_Node_Str",false)) {
      getActivity().finish();
    }
 else {
      Intent intent=new Intent(getActivity(),SearchResultDetailActivity.class);
      intent.putExtra(SearchResultDetailFragment.ARG_ITEM_ID,getItem().getCollectionId());
      startActivity(intent);
      getActivity().finish();
    }
    return true;
  }
 else   if (item.getItemId() == R.id.action_share) {
    if (getItem() == null) {
      Toast toast=Toast.makeText(getActivity(),getString(R.string.share_wait),Toast.LENGTH_SHORT);
      toast.show();
    }
 else {
      final String title=getItem().getTitle();
      final String id=getItem().getId();
      final CharSequence[] items={getString(R.string.share_link),getString(R.string.share_details)};
      AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
      builder.setTitle(R.string.share_dialog_select);
      builder.setItems(items,new DialogInterface.OnClickListener(){
        @Override public void onClick(        DialogInterface dialog,        int di){
          if (di == 0) {
            Intent intent=new Intent(android.content.Intent.ACTION_SEND);
            intent.setType("String_Node_Str");
            intent.addFlags(CompatibilityUtils.getNewDocumentIntentFlag());
            intent.putExtra(Intent.EXTRA_SUBJECT,title);
            String t=title;
            try {
              t=java.net.URLEncoder.encode(t,"String_Node_Str");
            }
 catch (            UnsupportedEncodingException e) {
            }
            String shareUrl=app.getApi().getShareUrl(id,t);
            if (shareUrl != null) {
              intent.putExtra(Intent.EXTRA_TEXT,shareUrl);
              startActivity(Intent.createChooser(intent,getResources().getString(R.string.share)));
            }
 else {
              Toast toast=Toast.makeText(getActivity(),getString(R.string.share_notsupported),Toast.LENGTH_SHORT);
              toast.show();
            }
          }
 else {
            Intent intent=new Intent(android.content.Intent.ACTION_SEND);
            intent.setType("String_Node_Str");
            intent.addFlags(CompatibilityUtils.getNewDocumentIntentFlag());
            intent.putExtra(Intent.EXTRA_SUBJECT,title);
            String t=title;
            try {
              t=t != null ? java.net.URLEncoder.encode(t,"String_Node_Str") : "String_Node_Str";
            }
 catch (            UnsupportedEncodingException e) {
            }
            String text=t + "String_Node_Str";
            for (            Detail detail : getItem().getDetails()) {
              String colon="String_Node_Str";
              if (!detail.getDesc().endsWith("String_Node_Str")) {
                colon="String_Node_Str";
              }
              text+=detail.getDesc() + colon + "String_Node_Str"+ detail.getContent()+ "String_Node_Str";
            }
            String shareUrl=app.getApi().getShareUrl(id,t);
            if (shareUrl != null) {
              text+=shareUrl;
            }
            intent.putExtra(Intent.EXTRA_TEXT,text);
            startActivity(Intent.createChooser(intent,getResources().getString(R.string.share)));
          }
        }
      }
);
      AlertDialog alert=builder.create();
      alert.show();
    }
    return true;
  }
 else   if (item.getItemId() == R.id.action_star) {
    StarDataSource star=new StarDataSource(getActivity());
    if (getItem() == null) {
      Toast toast=Toast.makeText(getActivity(),getString(R.string.star_wait),Toast.LENGTH_SHORT);
      toast.show();
    }
 else     if (getItem().getId() == null || getItem().getId().equals("String_Node_Str")) {
      final String title=getItem().getTitle();
      if (title == null || title.equals("String_Node_Str")) {
        Toast toast=Toast.makeText(getActivity(),getString(R.string.star_unsupported),Toast.LENGTH_LONG);
        toast.show();
      }
 else {
        if (star.isStarredTitle(bib,title)) {
          star.remove(star.getItemByTitle(bib,title));
          item.setIcon(R.drawable.ic_star_0_white_24dp);
        }
 else {
          star.star(null,title,bib,getItem().getMediaType());
          Toast toast=Toast.makeText(getActivity(),getString(R.string.starred),Toast.LENGTH_SHORT);
          toast.show();
          item.setIcon(R.drawable.ic_star_1_white_24dp);
        }
      }
    }
 else {
      final String title=getItem().getTitle();
      final String id=getItem().getId();
      if (star.isStarred(bib,id)) {
        star.remove(star.getItem(bib,id));
        item.setIcon(R.drawable.ic_star_0_white_24dp);
      }
 else {
        star.star(id,title,bib,getItem().getMediaType());
        Toast toast=Toast.makeText(getActivity(),getString(R.string.starred),Toast.LENGTH_SHORT);
        toast.show();
        item.setIcon(R.drawable.ic_star_1_white_24dp);
      }
    }
    return true;
  }
 else {
    return super.onOptionsItemSelected(item);
  }
}