Program: 138928
Project: 138928
Buggy source:
/** 
 * DOC bZhou Comment method "openInSqlEditor".
 * @param tdDataProvider
 * @param query
 * @param editorName
 * @return the specified sql editor.
 */
public SQLEditor openInSqlEditor(Connection tdDataProvider,String query,String editorName){
  if (editorName == null) {
    editorName=String.valueOf(SQLExplorerPlugin.getDefault().getEditorSerialNo());
  }
  SQLExplorerPlugin sqlPlugin=SQLExplorerPlugin.getDefault();
  AliasManager aliasManager=sqlPlugin.getAliasManager();
  Alias alias=aliasManager.getAlias(tdDataProvider.getName());
  if (alias == null) {
    List<Connection> allDataProviders=PrvResourceFileHelper.getInstance().getAllDataProviders(ResourceManager.getMetadataFolder());
    for (    Connection dataProvider : allDataProviders) {
      if (dataProvider == tdDataProvider) {
        CWMPlugin.getDefault().addConnetionAliasToSQLPlugin(dataProvider);
        openInSqlEditor(tdDataProvider,query,editorName);
      }
    }
  }
 else {
    try {
      Connection connection=SwitchHelpers.CONNECTION_SWITCH.doSwitch(tdDataProvider);
      if (connection != null) {
        String userName=ConnectionUtils.getUsername(connection);
        SQLEditorInput input=new SQLEditorInput("String_Node_Str" + alias.getName() + "String_Node_Str"+ editorName+ "String_Node_Str");
        input.setUser(alias.getUser(userName));
        IWorkbenchPage page=SQLExplorerPlugin.getDefault().getActivePage();
        SQLEditor editorPart=(SQLEditor)page.openEditor((IEditorInput)input,SQLEditor.class.getName());
        editorPart.setText(query);
        return editorPart;
      }
    }
 catch (    PartInitException e) {
      log.error(e,e);
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * DOC bZhou Comment method "openInSqlEditor".
 * @param tdDataProvider
 * @param query
 * @param editorName
 * @return the specified sql editor.
 */
public SQLEditor openInSqlEditor(Connection tdDataProvider,String query,String editorName){
  if (editorName == null) {
    editorName=String.valueOf(SQLExplorerPlugin.getDefault().getEditorSerialNo());
  }
  SQLExplorerPlugin sqlPlugin=SQLExplorerPlugin.getDefault();
  AliasManager aliasManager=sqlPlugin.getAliasManager();
  Alias alias=aliasManager.getAlias(tdDataProvider.getName());
  if (alias == null) {
    List<Connection> allDataProviders=PrvResourceFileHelper.getInstance().getAllDataProviders(ResourceManager.getMetadataFolder());
    for (    Connection dataProvider : allDataProviders) {
      if (dataProvider == tdDataProvider) {
        CWMPlugin.getDefault().addConnetionAliasToSQLPlugin(dataProvider);
        openInSqlEditor(tdDataProvider,query,editorName);
      }
    }
  }
 else {
    try {
      Connection connection=SwitchHelpers.CONNECTION_SWITCH.doSwitch(tdDataProvider);
      if (connection != null) {
        String userName=ConnectionUtils.getUsernameDefault(connection);
        SQLEditorInput input=new SQLEditorInput("String_Node_Str" + alias.getName() + "String_Node_Str"+ editorName+ "String_Node_Str");
        input.setUser(alias.getUser(userName));
        IWorkbenchPage page=SQLExplorerPlugin.getDefault().getActivePage();
        SQLEditor editorPart=(SQLEditor)page.openEditor((IEditorInput)input,SQLEditor.class.getName());
        editorPart.setText(query);
        return editorPart;
      }
    }
 catch (    PartInitException e) {
      log.error(e,e);
    }
  }
  return null;
}