Program: 162454
Project: 162454
Buggy source:
public void refreshDrawer(){
  Menu menu=navView.getMenu();
  menu.clear();
  actionViewStateManager.deselectCurrentActionView();
  int order=0;
  ArrayList<String> storageDirectories=mainActivity.getStorageDirectories();
  storage_count=0;
  for (  String file : storageDirectories) {
    File f=new File(file);
    String name;
    @DrawableRes int icon1=R.drawable.ic_sd_storage_white_24dp;
    if ("String_Node_Str".equals(file) || "String_Node_Str".equals(file)) {
      name=resources.getString(R.string.storage);
    }
 else     if ("String_Node_Str".equals(file)) {
      name=resources.getString(R.string.extstorage);
    }
 else     if ("String_Node_Str".equals(file)) {
      name=resources.getString(R.string.rootdirectory);
      icon1=R.drawable.ic_drawer_root_white;
    }
 else     if (file.contains(OTGUtil.PREFIX_OTG)) {
      name="String_Node_Str";
      icon1=R.drawable.ic_usb_white_24dp;
    }
 else     name=f.getName();
    if (!f.isDirectory() || f.canExecute()) {
      addNewItem(menu,STORAGES_GROUP,order++,name,new MenuMetadata(file),icon1,R.drawable.ic_show_chart_black_24dp);
      if (storage_count == 0)       firstPath=file;
 else       if (storage_count == 1)       secondPath=file;
      storage_count++;
    }
  }
  dataUtils.setStorages(storageDirectories);
  if (dataUtils.getServers().size() > 0) {
    Collections.sort(dataUtils.getServers(),new BookSorter());
synchronized (dataUtils.getServers()) {
      for (      String[] file : dataUtils.getServers()) {
        addNewItem(menu,SERVERS_GROUP,order++,file[0],new MenuMetadata(file[1]),R.drawable.ic_settings_remote_white_24dp,R.drawable.ic_edit_24dp);
      }
    }
  }
  ArrayList<String[]> accountAuthenticationList=new ArrayList<>();
  if (CloudSheetFragment.isCloudProviderAvailable(mainActivity)) {
    for (    CloudStorage cloudStorage : dataUtils.getAccounts()) {
      if (cloudStorage instanceof Dropbox) {
        addNewItem(menu,CLOUDS_GROUP,order++,CloudHandler.CLOUD_NAME_DROPBOX,new MenuMetadata(CloudHandler.CLOUD_PREFIX_DROPBOX + "String_Node_Str"),R.drawable.ic_dropbox_white_24dp,R.drawable.ic_edit_24dp);
        accountAuthenticationList.add(new String[]{CloudHandler.CLOUD_NAME_DROPBOX,CloudHandler.CLOUD_PREFIX_DROPBOX + "String_Node_Str"});
      }
 else       if (cloudStorage instanceof Box) {
        addNewItem(menu,CLOUDS_GROUP,order++,CloudHandler.CLOUD_NAME_BOX,new MenuMetadata(CloudHandler.CLOUD_PREFIX_BOX + "String_Node_Str"),R.drawable.ic_box_white_24dp,R.drawable.ic_edit_24dp);
        accountAuthenticationList.add(new String[]{CloudHandler.CLOUD_NAME_BOX,CloudHandler.CLOUD_PREFIX_BOX + "String_Node_Str"});
      }
 else       if (cloudStorage instanceof OneDrive) {
        addNewItem(menu,CLOUDS_GROUP,order++,CloudHandler.CLOUD_NAME_ONE_DRIVE,new MenuMetadata(CloudHandler.CLOUD_PREFIX_ONE_DRIVE + "String_Node_Str"),R.drawable.ic_onedrive_white_24dp,R.drawable.ic_edit_24dp);
        accountAuthenticationList.add(new String[]{CloudHandler.CLOUD_NAME_ONE_DRIVE,CloudHandler.CLOUD_PREFIX_ONE_DRIVE + "String_Node_Str"});
      }
 else       if (cloudStorage instanceof GoogleDrive) {
        addNewItem(menu,CLOUDS_GROUP,order++,CloudHandler.CLOUD_NAME_GOOGLE_DRIVE,new MenuMetadata(CloudHandler.CLOUD_PREFIX_GOOGLE_DRIVE + "String_Node_Str"),R.drawable.ic_google_drive_white_24dp,R.drawable.ic_edit_24dp);
        accountAuthenticationList.add(new String[]{CloudHandler.CLOUD_NAME_GOOGLE_DRIVE,CloudHandler.CLOUD_PREFIX_GOOGLE_DRIVE + "String_Node_Str"});
      }
    }
    Collections.sort(accountAuthenticationList,new BookSorter());
  }
  if (mainActivity.getBoolean(PREFERENCE_SHOW_SIDEBAR_FOLDERS)) {
    if (dataUtils.getBooks().size() > 0) {
      Collections.sort(dataUtils.getBooks(),new BookSorter());
synchronized (dataUtils.getBooks()) {
        for (        String[] file : dataUtils.getBooks()) {
          addNewItem(menu,FOLDERS_GROUP,order++,file[0],new MenuMetadata(file[1]),R.drawable.ic_folder_white_24dp,R.drawable.ic_edit_24dp);
        }
      }
    }
  }
  Boolean[] quickAccessPref=TinyDB.getBooleanArray(mainActivity.getPrefs(),QuickAccessPref.KEY,QuickAccessPref.DEFAULT);
  if (mainActivity.getBoolean(PREFERENCE_SHOW_SIDEBAR_QUICKACCESSES)) {
    if (quickAccessPref[0]) {
      addNewItem(menu,QUICKACCESSES_GROUP,order++,R.string.quick,new MenuMetadata("String_Node_Str"),R.drawable.ic_star_white_24dp,null);
    }
    if (quickAccessPref[1]) {
      addNewItem(menu,QUICKACCESSES_GROUP,order++,R.string.recent,new MenuMetadata("String_Node_Str"),R.drawable.ic_history_white_24dp,null);
    }
    if (quickAccessPref[2]) {
      addNewItem(menu,QUICKACCESSES_GROUP,order++,R.string.images,new MenuMetadata("String_Node_Str"),R.drawable.ic_photo_library_white_24dp,null);
    }
    if (quickAccessPref[3]) {
      addNewItem(menu,QUICKACCESSES_GROUP,order++,R.string.videos,new MenuMetadata("String_Node_Str"),R.drawable.ic_video_library_white_24dp,null);
    }
    if (quickAccessPref[4]) {
      addNewItem(menu,QUICKACCESSES_GROUP,order++,R.string.audio,new MenuMetadata("String_Node_Str"),R.drawable.ic_library_music_white_24dp,null);
    }
    if (quickAccessPref[5]) {
      addNewItem(menu,QUICKACCESSES_GROUP,order++,R.string.documents,new MenuMetadata("String_Node_Str"),R.drawable.ic_library_books_white_24dp,null);
    }
    if (quickAccessPref[6]) {
      addNewItem(menu,QUICKACCESSES_GROUP,order++,R.string.apks,new MenuMetadata("String_Node_Str"),R.drawable.ic_apk_library_white_24dp,null);
    }
  }
  addNewItem(menu,LASTGROUP,order++,R.string.ftp,new MenuMetadata(() -> {
    FragmentTransaction transaction2=mainActivity.getSupportFragmentManager().beginTransaction();
    transaction2.replace(R.id.content_frame,new FTPServerFragment());
    mainActivity.getAppbar().getAppbarLayout().animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
    pending_fragmentTransaction=transaction2;
    if (!isDrawerLocked)     close();
 else     onDrawerClosed();
  }
),R.drawable.ic_ftp_white_24dp,null);
  addNewItem(menu,LASTGROUP,order++,R.string.apps,new MenuMetadata(() -> {
    FragmentTransaction transaction2=mainActivity.getSupportFragmentManager().beginTransaction();
    transaction2.replace(R.id.content_frame,new AppsListFragment());
    mainActivity.getAppbar().getAppbarLayout().animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
    pending_fragmentTransaction=transaction2;
    if (!isDrawerLocked)     close();
 else     onDrawerClosed();
  }
),R.drawable.ic_android_white_24dp,null);
  addNewItem(menu,LASTGROUP,order++,R.string.setting,new MenuMetadata(() -> {
    Intent in=new Intent(mainActivity,PreferencesActivity.class);
    mainActivity.startActivity(in);
    mainActivity.finish();
  }
),R.drawable.ic_settings_white_24dp,null);
  for (int i=0; i < navView.getMenu().size(); i++) {
    navView.getMenu().getItem(i).setEnabled(true);
  }
  for (  int group : GROUPS) {
    menu.setGroupCheckable(group,true,true);
  }
  MenuItem item=navView.getSelected();
  if (item != null) {
    item.setChecked(true);
    actionViewStateManager.selectActionView(item);
    isSomethingSelected=true;
  }
}

Fixed version (ground truth):
public void refreshDrawer(){
  Menu menu=navView.getMenu();
  menu.clear();
  actionViewStateManager.deselectCurrentActionView();
  int order=0;
  ArrayList<String> storageDirectories=mainActivity.getStorageDirectories();
  storage_count=0;
  for (  String file : storageDirectories) {
    File f=new File(file);
    String name;
    @DrawableRes int icon1=R.drawable.ic_sd_storage_white_24dp;
    if ("String_Node_Str".equals(file) || "String_Node_Str".equals(file) || "String_Node_Str".equals(file)) {
      name=resources.getString(R.string.storage);
    }
 else     if ("String_Node_Str".equals(file)) {
      name=resources.getString(R.string.extstorage);
    }
 else     if ("String_Node_Str".equals(file)) {
      name=resources.getString(R.string.rootdirectory);
      icon1=R.drawable.ic_drawer_root_white;
    }
 else     if (file.contains(OTGUtil.PREFIX_OTG)) {
      name="String_Node_Str";
      icon1=R.drawable.ic_usb_white_24dp;
    }
 else     name=f.getName();
    if (f.isDirectory() || f.canExecute()) {
      addNewItem(menu,STORAGES_GROUP,order++,name,new MenuMetadata(file),icon1,R.drawable.ic_show_chart_black_24dp);
      if (storage_count == 0)       firstPath=file;
 else       if (storage_count == 1)       secondPath=file;
      storage_count++;
    }
  }
  dataUtils.setStorages(storageDirectories);
  if (dataUtils.getServers().size() > 0) {
    Collections.sort(dataUtils.getServers(),new BookSorter());
synchronized (dataUtils.getServers()) {
      for (      String[] file : dataUtils.getServers()) {
        addNewItem(menu,SERVERS_GROUP,order++,file[0],new MenuMetadata(file[1]),R.drawable.ic_settings_remote_white_24dp,R.drawable.ic_edit_24dp);
      }
    }
  }
  ArrayList<String[]> accountAuthenticationList=new ArrayList<>();
  if (CloudSheetFragment.isCloudProviderAvailable(mainActivity)) {
    for (    CloudStorage cloudStorage : dataUtils.getAccounts()) {
      if (cloudStorage instanceof Dropbox) {
        addNewItem(menu,CLOUDS_GROUP,order++,CloudHandler.CLOUD_NAME_DROPBOX,new MenuMetadata(CloudHandler.CLOUD_PREFIX_DROPBOX + "String_Node_Str"),R.drawable.ic_dropbox_white_24dp,R.drawable.ic_edit_24dp);
        accountAuthenticationList.add(new String[]{CloudHandler.CLOUD_NAME_DROPBOX,CloudHandler.CLOUD_PREFIX_DROPBOX + "String_Node_Str"});
      }
 else       if (cloudStorage instanceof Box) {
        addNewItem(menu,CLOUDS_GROUP,order++,CloudHandler.CLOUD_NAME_BOX,new MenuMetadata(CloudHandler.CLOUD_PREFIX_BOX + "String_Node_Str"),R.drawable.ic_box_white_24dp,R.drawable.ic_edit_24dp);
        accountAuthenticationList.add(new String[]{CloudHandler.CLOUD_NAME_BOX,CloudHandler.CLOUD_PREFIX_BOX + "String_Node_Str"});
      }
 else       if (cloudStorage instanceof OneDrive) {
        addNewItem(menu,CLOUDS_GROUP,order++,CloudHandler.CLOUD_NAME_ONE_DRIVE,new MenuMetadata(CloudHandler.CLOUD_PREFIX_ONE_DRIVE + "String_Node_Str"),R.drawable.ic_onedrive_white_24dp,R.drawable.ic_edit_24dp);
        accountAuthenticationList.add(new String[]{CloudHandler.CLOUD_NAME_ONE_DRIVE,CloudHandler.CLOUD_PREFIX_ONE_DRIVE + "String_Node_Str"});
      }
 else       if (cloudStorage instanceof GoogleDrive) {
        addNewItem(menu,CLOUDS_GROUP,order++,CloudHandler.CLOUD_NAME_GOOGLE_DRIVE,new MenuMetadata(CloudHandler.CLOUD_PREFIX_GOOGLE_DRIVE + "String_Node_Str"),R.drawable.ic_google_drive_white_24dp,R.drawable.ic_edit_24dp);
        accountAuthenticationList.add(new String[]{CloudHandler.CLOUD_NAME_GOOGLE_DRIVE,CloudHandler.CLOUD_PREFIX_GOOGLE_DRIVE + "String_Node_Str"});
      }
    }
    Collections.sort(accountAuthenticationList,new BookSorter());
  }
  if (mainActivity.getBoolean(PREFERENCE_SHOW_SIDEBAR_FOLDERS)) {
    if (dataUtils.getBooks().size() > 0) {
      Collections.sort(dataUtils.getBooks(),new BookSorter());
synchronized (dataUtils.getBooks()) {
        for (        String[] file : dataUtils.getBooks()) {
          addNewItem(menu,FOLDERS_GROUP,order++,file[0],new MenuMetadata(file[1]),R.drawable.ic_folder_white_24dp,R.drawable.ic_edit_24dp);
        }
      }
    }
  }
  Boolean[] quickAccessPref=TinyDB.getBooleanArray(mainActivity.getPrefs(),QuickAccessPref.KEY,QuickAccessPref.DEFAULT);
  if (mainActivity.getBoolean(PREFERENCE_SHOW_SIDEBAR_QUICKACCESSES)) {
    if (quickAccessPref[0]) {
      addNewItem(menu,QUICKACCESSES_GROUP,order++,R.string.quick,new MenuMetadata("String_Node_Str"),R.drawable.ic_star_white_24dp,null);
    }
    if (quickAccessPref[1]) {
      addNewItem(menu,QUICKACCESSES_GROUP,order++,R.string.recent,new MenuMetadata("String_Node_Str"),R.drawable.ic_history_white_24dp,null);
    }
    if (quickAccessPref[2]) {
      addNewItem(menu,QUICKACCESSES_GROUP,order++,R.string.images,new MenuMetadata("String_Node_Str"),R.drawable.ic_photo_library_white_24dp,null);
    }
    if (quickAccessPref[3]) {
      addNewItem(menu,QUICKACCESSES_GROUP,order++,R.string.videos,new MenuMetadata("String_Node_Str"),R.drawable.ic_video_library_white_24dp,null);
    }
    if (quickAccessPref[4]) {
      addNewItem(menu,QUICKACCESSES_GROUP,order++,R.string.audio,new MenuMetadata("String_Node_Str"),R.drawable.ic_library_music_white_24dp,null);
    }
    if (quickAccessPref[5]) {
      addNewItem(menu,QUICKACCESSES_GROUP,order++,R.string.documents,new MenuMetadata("String_Node_Str"),R.drawable.ic_library_books_white_24dp,null);
    }
    if (quickAccessPref[6]) {
      addNewItem(menu,QUICKACCESSES_GROUP,order++,R.string.apks,new MenuMetadata("String_Node_Str"),R.drawable.ic_apk_library_white_24dp,null);
    }
  }
  addNewItem(menu,LASTGROUP,order++,R.string.ftp,new MenuMetadata(() -> {
    FragmentTransaction transaction2=mainActivity.getSupportFragmentManager().beginTransaction();
    transaction2.replace(R.id.content_frame,new FTPServerFragment());
    mainActivity.getAppbar().getAppbarLayout().animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
    pending_fragmentTransaction=transaction2;
    if (!isDrawerLocked)     close();
 else     onDrawerClosed();
  }
),R.drawable.ic_ftp_white_24dp,null);
  addNewItem(menu,LASTGROUP,order++,R.string.apps,new MenuMetadata(() -> {
    FragmentTransaction transaction2=mainActivity.getSupportFragmentManager().beginTransaction();
    transaction2.replace(R.id.content_frame,new AppsListFragment());
    mainActivity.getAppbar().getAppbarLayout().animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
    pending_fragmentTransaction=transaction2;
    if (!isDrawerLocked)     close();
 else     onDrawerClosed();
  }
),R.drawable.ic_android_white_24dp,null);
  addNewItem(menu,LASTGROUP,order++,R.string.setting,new MenuMetadata(() -> {
    Intent in=new Intent(mainActivity,PreferencesActivity.class);
    mainActivity.startActivity(in);
    mainActivity.finish();
  }
),R.drawable.ic_settings_white_24dp,null);
  for (int i=0; i < navView.getMenu().size(); i++) {
    navView.getMenu().getItem(i).setEnabled(true);
  }
  for (  int group : GROUPS) {
    menu.setGroupCheckable(group,true,true);
  }
  MenuItem item=navView.getSelected();
  if (item != null) {
    item.setChecked(true);
    actionViewStateManager.selectActionView(item);
    isSomethingSelected=true;
  }
}