Program: 138477
Project: 138477
Buggy source:
/** 
 * DOC qiongli close editor by file.
 * @param fileRes
 */
public void closeEditorIfOpened(Property property){
  IWorkbenchPage activePage=CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
  IEditorReference[] editorReferences=activePage.getEditorReferences();
  IEditorInput editorInput=null;
  for (  IEditorReference reference : editorReferences) {
    try {
      editorInput=reference.getEditorInput();
      if (editorInput instanceof FileEditorInput) {
        FileEditorInput fileInput=(FileEditorInput)editorInput;
        if (property.eResource() != null) {
          IPath propPath=new Path(property.eResource().getURI().lastSegment()).removeFileExtension();
          IPath filePath=new Path(fileInput.getFile().getName()).removeFileExtension();
          if (filePath.equals(propPath)) {
            activePage.closeEditor(reference.getEditor(false),false);
            break;
          }
        }
      }
 else       if (editorInput instanceof SQLEditorInput) {
        SQLEditorInput sqlEditorInput=(SQLEditorInput)editorInput;
        if (sqlEditorInput.getUser() == null) {
          if (sqlEditorInput.getName().equals(property.getLabel())) {
            activePage.closeEditor(reference.getEditor(false),false);
          }
        }
 else         if (sqlEditorInput.getUser().getAlias().getName().equals(property.getLabel())) {
          activePage.closeEditor(reference.getEditor(false),false);
        }
      }
 else       if (editorInput instanceof ConnectionItemEditorInput) {
        ConnectionItemEditorInput connectionInput=(ConnectionItemEditorInput)editorInput;
        if (property != null && property.equals(connectionInput.getItem().getProperty())) {
          activePage.closeEditor(reference.getEditor(false),false);
        }
      }
    }
 catch (    PartInitException e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
/** 
 * DOC qiongli close editor by file.
 * @param fileRes
 */
public void closeEditorIfOpened(Item item){
  IWorkbenchPage activePage=CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
  IEditorReference[] editorReferences=activePage.getEditorReferences();
  IEditorInput editorInput=null;
  Property property=item.getProperty();
  for (  IEditorReference reference : editorReferences) {
    try {
      editorInput=reference.getEditorInput();
      if (editorInput instanceof FileEditorInput) {
        FileEditorInput fileInput=(FileEditorInput)editorInput;
        if (property.eResource() != null) {
          IPath itemPath=PropertyHelper.getItemPath(property);
          if (itemPath != null && itemPath.equals(fileInput.getFile().getFullPath())) {
            activePage.closeEditor(reference.getEditor(false),false);
            break;
          }
        }
      }
 else       if (editorInput instanceof SQLEditorInput) {
        SQLEditorInput sqlEditorInput=(SQLEditorInput)editorInput;
        if (sqlEditorInput.getUser() == null) {
          if (sqlEditorInput.getName().equals(property.getLabel())) {
            activePage.closeEditor(reference.getEditor(false),false);
          }
        }
 else         if (sqlEditorInput.getUser().getAlias().getName().equals(property.getLabel())) {
          activePage.closeEditor(reference.getEditor(false),false);
        }
      }
 else       if (editorInput instanceof AbstractItemEditorInput) {
        AbstractItemEditorInput input=(AbstractItemEditorInput)editorInput;
        Item it=input.getItem();
        if (it != null && item.equals(it)) {
          activePage.closeEditor(reference.getEditor(false),false);
        }
      }
    }
 catch (    PartInitException e) {
      e.printStackTrace();
    }
  }
}