Program: 138650
Project: 138650
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().getAlias().getName().equals(property.getLabel())) {
          activePage.closeEditor(reference.getEditor(false),false);
        }
      }
 else       if (editorInput instanceof ConnectionItemEditorInput) {
        ConnectionItemEditorInput connectionInput=(ConnectionItemEditorInput)editorInput;
        if (property.equals(connectionInput.getReposViewObj().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(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.equals(connectionInput.getReposViewObj().getProperty())) {
          activePage.closeEditor(reference.getEditor(false),false);
        }
      }
    }
 catch (    PartInitException e) {
      e.printStackTrace();
    }
  }
}