Program: 97474
Project: 97474
Buggy source:
@Override public Object execute(ExecutionEvent event) throws ExecutionException {
  if (HandlerUtil.getActivePartChecked(event) instanceof ViewPart) {
    ViewPart view=(ViewPart)HandlerUtil.getActivePartChecked(event);
    IWorkbenchPartSite myIWorkbenchPartSite=view.getSite();
    ISelectionProvider selectionProvider=myIWorkbenchPartSite.getSelectionProvider();
    if (selectionProvider != null && selectionProvider.getSelection() instanceof IStructuredSelection) {
      IStructuredSelection selection=(IStructuredSelection)selectionProvider.getSelection();
      List<String> names=new LinkedList<String>();
      List<Artifact> artifacts=new LinkedList<Artifact>();
      ArtifactClipboard clipboard=new ArtifactClipboard(view.getSite().getId());
      Iterator<?> iterator=selection.iterator();
      Object selectionObject=null;
      while (iterator.hasNext()) {
        Object object=iterator.next();
        if (object instanceof IAdaptable) {
          selectionObject=((IAdaptable)object).getAdapter(Branch.class);
          if (selectionObject == null) {
            selectionObject=((IAdaptable)object).getAdapter(Artifact.class);
          }
        }
 else         if (object instanceof Match) {
          selectionObject=((Match)object).getElement();
        }
        if (selectionObject instanceof IOseeBranch) {
          names.add(((IOseeBranch)selectionObject).getName());
        }
 else         if (selectionObject instanceof Artifact) {
          Artifact artifact=(Artifact)selectionObject;
          names.add(artifact.getName());
          artifacts.add(artifact);
        }
      }
      if (!names.isEmpty() && artifacts.isEmpty()) {
        clipboard.setTextToClipboard(names);
      }
 else       if (!names.isEmpty() && !artifacts.isEmpty()) {
        try {
          clipboard.setArtifactsToClipboard(ServiceUtil.getAccessPolicy(),artifacts);
        }
 catch (        OseeCoreException ex) {
          throw new ExecutionException(ex.getLocalizedMessage());
        }
      }
    }
  }
  return null;
}

Fixed version (ground truth):
@Override public Object execute(ExecutionEvent event) throws ExecutionException {
  if (HandlerUtil.getActivePartChecked(event) instanceof ViewPart) {
    ViewPart view=(ViewPart)HandlerUtil.getActivePartChecked(event);
    IWorkbenchPartSite myIWorkbenchPartSite=view.getSite();
    ISelectionProvider selectionProvider=myIWorkbenchPartSite.getSelectionProvider();
    if (selectionProvider != null && selectionProvider.getSelection() instanceof IStructuredSelection) {
      IStructuredSelection selection=(IStructuredSelection)selectionProvider.getSelection();
      List<String> names=new LinkedList<String>();
      List<Artifact> artifacts=new LinkedList<Artifact>();
      ArtifactClipboard clipboard=new ArtifactClipboard(view.getSite().getId());
      Iterator<?> iterator=selection.iterator();
      Object selectionObject=null;
      try {
        while (iterator.hasNext()) {
          Object object=iterator.next();
          if (object instanceof IAdaptable) {
            selectionObject=((IAdaptable)object).getAdapter(Branch.class);
            if (selectionObject == null) {
              selectionObject=((IAdaptable)object).getAdapter(Artifact.class);
            }
          }
 else           if (object instanceof Match) {
            selectionObject=((Match)object).getElement();
          }
          if (selectionObject instanceof IOseeBranch) {
            names.add(((IOseeBranch)selectionObject).getName());
          }
 else           if (selectionObject instanceof Artifact) {
            Artifact artifact=(Artifact)selectionObject;
            names.add(artifact.getName());
            artifacts.add(artifact);
          }
        }
        if (!names.isEmpty() && artifacts.isEmpty()) {
          clipboard.setTextToClipboard(names);
        }
 else         if (!names.isEmpty() && !artifacts.isEmpty()) {
          try {
            clipboard.setArtifactsToClipboard(ServiceUtil.getAccessPolicy(),artifacts);
          }
 catch (          OseeCoreException ex) {
            clipboard.dispose();
            throw new ExecutionException(ex.getLocalizedMessage());
          }
        }
      }
  finally {
        clipboard.dispose();
      }
    }
  }
  return null;
}