Program: 149530
Project: 149530
Buggy source:
/** 
 * Load templates from directory.
 * @param settings the settings
 */
private void loadSelectedCustomTemplatesFromDirectory(ConfigurationTemplateSettings.Builder settings){
  String newDirectory=Utils.getDirectory("String_Node_Str",settings.getConfigurationDirectory());
  if (newDirectory == null)   return;
  settings.setConfigurationDirectory(newDirectory);
  File[] fileList=(new File(newDirectory)).listFiles(new FilenameFilter(){
    public boolean accept(    File arg0,    String arg1){
      return arg0.isFile() && !arg1.toLowerCase().endsWith("String_Node_Str");
    }
  }
);
  if (fileList == null)   return;
  String[] list=new String[fileList.length];
  int n=0;
  for (  File file : fileList) {
    if (file.isFile()) {
      list[n++]=file.getPath();
    }
  }
  final String[] sortedList=StringSorter.sortNumerically(list);
  MultiDialog md=new MultiDialog("String_Node_Str",new MultiDialog.BaseItems(){
    public int size(){
      return sortedList.length;
    }
    public String getFormattedName(    int i){
      String[] path=Utils.decodePath(sortedList[i]);
      return path[1];
    }
  }
);
  md.addSelected(settings.getSelectedCustomTemplatesList());
  md.showDialog();
  if (md.wasCanceled())   return;
  ArrayList<String> selected=md.getSelectedResults();
  if (selected.isEmpty())   return;
  settings.clearSelectedCustomTemplates();
  settings.addAllSelectedCustomTemplates(selected);
  int count=0;
  TemplateSettings.Builder builder=TemplateSettings.newBuilder();
  for (  String path : selected) {
    builder.clear();
    File file=new File(newDirectory,path);
    if (SettingsManager.fromJSON(file,builder,0)) {
      count++;
      String name=Utils.removeExtension(file.getName());
      addTemplate(name,builder.build(),TemplateType.CUSTOM,file,null);
    }
  }
  if (count > 0)   saveDefaultTemplates();
  IJ.showMessage("String_Node_Str" + TextUtils.pleural(count,"String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * Load templates from directory.
 * @param settings the settings
 */
private void loadSelectedCustomTemplatesFromDirectory(ConfigurationTemplateSettings.Builder settings){
  String newDirectory=Utils.getDirectory("String_Node_Str",settings.getConfigurationDirectory());
  if (newDirectory == null)   return;
  settings.setConfigurationDirectory(newDirectory);
  File[] fileList=(new File(newDirectory)).listFiles(new FileFilter(){
    public boolean accept(    File file){
      return file.isFile() && !file.getName().toLowerCase().endsWith("String_Node_Str");
    }
  }
);
  if (fileList == null)   return;
  String[] list=new String[fileList.length];
  int n=0;
  for (  File file : fileList) {
    if (file.isFile()) {
      list[n++]=file.getPath();
    }
  }
  final String[] sortedList=StringSorter.sortNumerically(list);
  MultiDialog md=new MultiDialog("String_Node_Str",new MultiDialog.BaseItems(){
    public int size(){
      return sortedList.length;
    }
    public String getFormattedName(    int i){
      String[] path=Utils.decodePath(sortedList[i]);
      return path[1];
    }
  }
);
  md.addSelected(settings.getSelectedCustomTemplatesList());
  md.showDialog();
  if (md.wasCanceled())   return;
  ArrayList<String> selected=md.getSelectedResults();
  if (selected.isEmpty())   return;
  settings.clearSelectedCustomTemplates();
  settings.addAllSelectedCustomTemplates(selected);
  int count=0;
  TemplateSettings.Builder builder=TemplateSettings.newBuilder();
  for (  String path : selected) {
    builder.clear();
    File file=new File(newDirectory,path);
    if (SettingsManager.fromJSON(file,builder,0)) {
      count++;
      String name=Utils.removeExtension(file.getName());
      addTemplate(name,builder.build(),TemplateType.CUSTOM,file,null);
    }
  }
  if (count > 0)   saveDefaultTemplates();
  IJ.showMessage("String_Node_Str" + TextUtils.pleural(count,"String_Node_Str"));
}