Program: 92224
Project: 92224
Buggy source:
/** 
 * Finish the import.
 * @return <code>true</code> if successful else false
 */
public boolean finish(){
  File sourceDir=new File(getSourceDirectoryName());
  if (!sourceDir.isDirectory()) {
    setErrorMessage(Messages.ImportTraceWizard_InvalidTraceDirectory);
    return false;
  }
  String sourceDirPath;
  try {
    sourceDirPath=sourceDir.getCanonicalPath();
  }
 catch (  IOException e) {
    MessageDialog.openInformation(getContainer().getShell(),Messages.ImportTraceWizard_Information,Messages.ImportTraceWizard_InvalidTraceDirectory);
    return false;
  }
  fRootDirectory=getSourceDirectoryName();
  List<FileSystemElement> selectedResources=getSelectedResources();
  Iterator<FileSystemElement> resources=selectedResources.iterator();
  Map<String,File> fileSystemObjects=new HashMap<String,File>();
  while (resources.hasNext()) {
    File file=(File)resources.next().getFileSystemObject();
    String key=file.getAbsolutePath();
    fileSystemObjects.put(key,file);
  }
  if (fileSystemObjects.size() > 0) {
    boolean ok=importResources(sourceDirPath,fileSystemObjects);
    String traceBundle=null;
    String traceTypeId=null;
    String traceIcon=null;
    String traceType=fTraceTypes.getText();
    boolean traceTypeOK=false;
    if (traceType.startsWith(CUSTOM_TXT_CATEGORY)) {
      for (      CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {
        if (traceType.equals(CUSTOM_TXT_CATEGORY + "String_Node_Str" + def.definitionName)) {
          traceTypeOK=true;
          traceBundle=Activator.getDefault().getBundle().getSymbolicName();
          traceTypeId=CustomTxtTrace.class.getCanonicalName() + "String_Node_Str" + def.definitionName;
          traceIcon=DEFAULT_TRACE_ICON_PATH;
          break;
        }
      }
    }
 else     if (traceType.startsWith(CUSTOM_XML_CATEGORY)) {
      for (      CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {
        if (traceType.equals(CUSTOM_XML_CATEGORY + "String_Node_Str" + def.definitionName)) {
          traceTypeOK=true;
          traceBundle=Activator.getDefault().getBundle().getSymbolicName();
          traceTypeId=CustomXmlTrace.class.getCanonicalName() + "String_Node_Str" + def.definitionName;
          traceIcon=DEFAULT_TRACE_ICON_PATH;
          break;
        }
      }
    }
 else {
      IConfigurationElement ce=fTraceAttributes.get(traceType);
      if (ce != null) {
        traceTypeOK=true;
        traceBundle=ce.getContributor().getName();
        traceTypeId=ce.getAttribute(TmfTraceType.ID_ATTR);
        traceIcon=ce.getAttribute(TmfTraceType.ICON_ATTR);
      }
    }
    if (ok && traceTypeOK && !traceType.equals("String_Node_Str")) {
      List<String> files=new ArrayList<String>(fileSystemObjects.keySet());
      Collections.sort(files);
      String prefix=null;
      for (int i=0; i < files.size(); i++) {
        File file=fileSystemObjects.get(files.get(i));
        String name=file.getAbsolutePath();
        if (fTargetFolder != null && (prefix == null || !name.startsWith(prefix))) {
          prefix=name;
          IResource resource=fTargetFolder.findMember(file.getName());
          if (resource != null) {
            try {
              resource.setPersistentProperty(TmfCommonConstants.TRACEBUNDLE,traceBundle);
              resource.setPersistentProperty(TmfCommonConstants.TRACETYPE,traceTypeId);
              resource.setPersistentProperty(TmfCommonConstants.TRACEICON,traceIcon);
              for (              TmfTraceElement traceElement : TmfProjectRegistry.getProject(resource.getProject()).getTracesFolder().getTraces()) {
                if (traceElement.getName().equals(resource.getName())) {
                  traceElement.refreshTraceType();
                  break;
                }
              }
            }
 catch (            CoreException e) {
              Activator.getDefault().logError("String_Node_Str" + resource.getName(),e);
            }
          }
        }
      }
    }
    return ok;
  }
  MessageDialog.openInformation(getContainer().getShell(),Messages.ImportTraceWizard_Information,Messages.ImportTraceWizard_SelectTraceNoneSelected);
  return false;
}

Fixed version (ground truth):
/** 
 * Finish the import.
 * @return <code>true</code> if successful else false
 */
public boolean finish(){
  File sourceDir=new File(getSourceDirectoryName());
  if (!sourceDir.isDirectory()) {
    setErrorMessage(Messages.ImportTraceWizard_InvalidTraceDirectory);
    return false;
  }
  String sourceDirPath;
  try {
    sourceDirPath=sourceDir.getCanonicalPath();
  }
 catch (  IOException e) {
    MessageDialog.openInformation(getContainer().getShell(),Messages.ImportTraceWizard_Information,Messages.ImportTraceWizard_InvalidTraceDirectory);
    return false;
  }
  fRootDirectory=getSourceDirectoryName();
  List<FileSystemElement> selectedResources=getSelectedResources();
  Iterator<FileSystemElement> resources=selectedResources.iterator();
  Map<String,File> fileSystemObjects=new HashMap<String,File>();
  while (resources.hasNext()) {
    File file=(File)resources.next().getFileSystemObject();
    String key=file.getAbsolutePath();
    fileSystemObjects.put(key,file);
  }
  if (fileSystemObjects.size() > 0) {
    boolean ok=importResources(sourceDirPath,fileSystemObjects);
    String traceBundle=null;
    String traceTypeId=null;
    String traceIcon=null;
    String traceType=fTraceTypes.getText();
    boolean traceTypeOK=false;
    if (traceType.startsWith(CUSTOM_TXT_CATEGORY)) {
      for (      CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {
        if (traceType.equals(CUSTOM_TXT_CATEGORY + "String_Node_Str" + def.definitionName)) {
          traceTypeOK=true;
          traceBundle=Activator.getDefault().getBundle().getSymbolicName();
          traceTypeId=CustomTxtTrace.class.getCanonicalName() + "String_Node_Str" + def.definitionName;
          traceIcon=DEFAULT_TRACE_ICON_PATH;
          break;
        }
      }
    }
 else     if (traceType.startsWith(CUSTOM_XML_CATEGORY)) {
      for (      CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {
        if (traceType.equals(CUSTOM_XML_CATEGORY + "String_Node_Str" + def.definitionName)) {
          traceTypeOK=true;
          traceBundle=Activator.getDefault().getBundle().getSymbolicName();
          traceTypeId=CustomXmlTrace.class.getCanonicalName() + "String_Node_Str" + def.definitionName;
          traceIcon=DEFAULT_TRACE_ICON_PATH;
          break;
        }
      }
    }
 else {
      IConfigurationElement ce=fTraceAttributes.get(traceType);
      if (ce != null) {
        traceTypeOK=true;
        traceBundle=ce.getContributor().getName();
        traceTypeId=ce.getAttribute(TmfTraceType.ID_ATTR);
        traceIcon=ce.getAttribute(TmfTraceType.ICON_ATTR);
      }
    }
    if (ok && traceTypeOK && !traceType.equals("String_Node_Str")) {
      List<String> files=new ArrayList<String>(fileSystemObjects.keySet());
      Collections.sort(files,new Comparator<String>(){
        @Override public int compare(        String o1,        String o2){
          String v1=o1 + File.separatorChar;
          String v2=o2 + File.separatorChar;
          return v1.compareTo(v2);
        }
      }
);
      String prefix=null;
      for (int i=0; i < files.size(); i++) {
        File file=fileSystemObjects.get(files.get(i));
        String name=file.getAbsolutePath();
        if (fTargetFolder != null && (prefix == null || !name.startsWith(prefix))) {
          prefix=name;
          IResource resource=fTargetFolder.findMember(file.getName());
          if (resource != null) {
            try {
              resource.setPersistentProperty(TmfCommonConstants.TRACEBUNDLE,traceBundle);
              resource.setPersistentProperty(TmfCommonConstants.TRACETYPE,traceTypeId);
              resource.setPersistentProperty(TmfCommonConstants.TRACEICON,traceIcon);
              for (              TmfTraceElement traceElement : TmfProjectRegistry.getProject(resource.getProject()).getTracesFolder().getTraces()) {
                if (traceElement.getName().equals(resource.getName())) {
                  traceElement.refreshTraceType();
                  break;
                }
              }
            }
 catch (            CoreException e) {
              Activator.getDefault().logError("String_Node_Str" + resource.getName(),e);
            }
          }
        }
      }
    }
    return ok;
  }
  MessageDialog.openInformation(getContainer().getShell(),Messages.ImportTraceWizard_Information,Messages.ImportTraceWizard_SelectTraceNoneSelected);
  return false;
}