Program: 92060
Project: 92060
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;
  }
  try {
    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(fileSystemObjects);
    String traceBundle=null;
    String traceTypeId=null;
    String traceIcon=null;
    String traceType=fTraceTypes.getText();
    boolean traceTypeOK=false;
    if (traceType.startsWith(TmfTraceType.CUSTOM_TXT_CATEGORY)) {
      for (      CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {
        if (traceType.equals(TmfTraceType.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(TmfTraceType.CUSTOM_XML_CATEGORY)) {
      for (      CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {
        if (traceType.equals(TmfTraceType.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 {
      String temp[]=traceType.split("String_Node_Str",2);
      if (temp.length < 2) {
        Activator.getDefault().logError("String_Node_Str" + traceType);
        return false;
      }
      final String traceId=TmfTraceType.getInstance().getTraceTypeId(temp[0],temp[1]);
      if (traceId != null) {
        if (!TmfTraceType.getInstance().validateTrace(traceId,getSelectedResources())) {
          setMessage(null);
          setErrorMessage(Messages.ImportTraceWizard_TraceValidationFailed);
          return false;
        }
      }
 else {
        setMessage(null);
        setErrorMessage(Messages.ImportTraceWizard_TraceValidationFailed);
        return false;
      }
      IConfigurationElement ce=TmfTraceType.getInstance().getTraceAttributes(traceId);
      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() + File.separatorChar;
        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);
              TmfProjectElement tmfProject=TmfProjectRegistry.getProject(resource.getProject());
              if (tmfProject != null) {
                for (                TmfTraceElement traceElement : tmfProject.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;
  }
  try {
    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(fileSystemObjects);
    String traceBundle=null;
    String traceTypeId=null;
    String traceIcon=null;
    String traceType=fTraceTypes.getText();
    boolean traceTypeOK=false;
    if (traceType.startsWith(TmfTraceType.CUSTOM_TXT_CATEGORY)) {
      for (      CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {
        if (traceType.equals(TmfTraceType.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(TmfTraceType.CUSTOM_XML_CATEGORY)) {
      for (      CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {
        if (traceType.equals(TmfTraceType.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 {
      if (!traceType.equals("String_Node_Str")) {
        String temp[]=traceType.split("String_Node_Str",2);
        if (temp.length < 2) {
          Activator.getDefault().logError("String_Node_Str" + traceType);
          return false;
        }
        final String traceId=TmfTraceType.getInstance().getTraceTypeId(temp[0],temp[1]);
        if (traceId != null) {
          if (!TmfTraceType.getInstance().validateTrace(traceId,getSelectedResources())) {
            setMessage(null);
            setErrorMessage(Messages.ImportTraceWizard_TraceValidationFailed);
            return false;
          }
        }
 else {
          setMessage(null);
          setErrorMessage(Messages.ImportTraceWizard_TraceValidationFailed);
          return false;
        }
        IConfigurationElement ce=TmfTraceType.getInstance().getTraceAttributes(traceId);
        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() + File.separatorChar;
        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);
              TmfProjectElement tmfProject=TmfProjectRegistry.getProject(resource.getProject());
              if (tmfProject != null) {
                for (                TmfTraceElement traceElement : tmfProject.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;
}