Program: 122695
Project: 122695
Buggy source:
private void createSelectionListener(){
  tableViewer.addSelectionChangedListener(new ISelectionChangedListener(){
    public void selectionChanged(    SelectionChangedEvent event){
      BusinessAssignment businessAssignment=getBusinessAssignment(event.getSelection());
      if (businessAssignment != null) {
        final IRepositoryView repositoryView=getRepositoryView();
        if (repositoryView != null) {
          IProjectRepositoryNode rootRepositoryNode=repositoryView.getRoot();
          TalendItem item=businessAssignment.getTalendItem();
          if (item instanceof Routine && rootRepositoryNode instanceof ProjectRepositoryNode) {
            RepositoryNodeUtilities.expandParentNode(getRepositoryView(),((ProjectRepositoryNode)rootRepositoryNode).getRootRepositoryNode(ERepositoryObjectType.CODE));
          }
          selectChild(item,(IRepositoryNode)rootRepositoryNode);
        }
      }
    }
    private void selectChild(    TalendItem item,    IRepositoryNode rootRepositoryNode){
      try {
        RepositoryNode curNode=null;
        JobSettingsView viewer=(JobSettingsView)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(JobSettingsView.ID);
        IRepositoryViewObject lastVersion=ProxyRepositoryFactory.getInstance().getLastVersion(item.getId());
        if (lastVersion != null) {
          curNode=RepositoryNodeUtilities.getRepositoryNode(lastVersion);
          select(viewer,curNode);
        }
 else         if (item instanceof TableMetadata) {
          MetadataTable table=MetadataTool.getMetadataTableFromRepository(item.getId());
          if (table != null) {
            String id=item.getId().split("String_Node_Str")[0];
            RepositoryNode node=RepositoryNodeUtilities.getMetadataTableFromConnection(item.getId());
            IRepositoryView view=getRepositoryView();
            if (view != null) {
              RepositoryNodeUtilities.expandParentNode(view,node);
              select(viewer,node);
            }
          }
        }
 else         if (item instanceof Query) {
          org.talend.core.model.metadata.builder.connection.Query query=MetadataTool.getQueryFromRepository(item.getId());
          if (query != null) {
            String id=item.getId().split("String_Node_Str")[0];
            IRepositoryView view=getRepositoryView();
            RepositoryNode node=RepositoryNodeUtilities.getQueryFromConnection(item.getId());
            RepositoryNodeUtilities.expandParentNode(view,node);
            select(viewer,node);
          }
        }
 else         if (item instanceof SAPFunction) {
          SAPFunctionUnit function=MetadataTool.getSAPFunctionFromRepository(item.getId());
          if (function != null) {
            IRepositoryView view=getRepositoryView();
            RepositoryNode node=RepositoryNodeUtilities.getSAPFunctionFromConnection(item.getId());
            RepositoryNodeUtilities.expandParentNode(view,node);
            select(viewer,node);
          }
        }
 else {
          for (          IRepositoryNode node : rootRepositoryNode.getChildren()) {
            RepositoryNode rNode=(RepositoryNode)node;
            if (item instanceof SQLPattern && rNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.SQLPATTERNS) {
              if (rNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
                SQLPatternItem sqlItem=(SQLPatternItem)rNode.getObject().getProperty().getItem();
                if (sqlItem.isSystem() && item.getLabel().equals(rNode.getObject().getLabel())) {
                  select(viewer,rNode);
                }
              }
 else {
                selectChild(item,rNode);
              }
            }
 else             if (item instanceof Routine && rNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.ROUTINES) {
              if (rNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
                RoutineItem sqlItem=(RoutineItem)rNode.getObject().getProperty().getItem();
                if (sqlItem.isBuiltIn() && item.getLabel().equals(rNode.getObject().getLabel())) {
                  select(viewer,rNode);
                }
              }
 else {
                selectChild(item,rNode);
              }
            }
          }
        }
      }
 catch (      PersistenceException e) {
        ExceptionHandler.process(e);
      }
    }
    private void select(    JobSettingsView viewer,    RepositoryNode repositoryNode){
      if (viewer == null) {
        return;
      }
      if (repositoryNode == null) {
        return;
      }
      CorePlugin.getDefault().getRepositoryService().removeRepositoryTreeViewListener(viewer);
      final IRepositoryView repositoryView=getRepositoryView();
      if (repositoryView != null) {
        repositoryView.getViewer().setSelection(new StructuredSelection(repositoryNode));
      }
      CorePlugin.getDefault().getRepositoryService().addRepositoryTreeViewListener(viewer);
    }
  }
);
}

Fixed version (ground truth):
private void createSelectionListener(){
  tableViewer.addSelectionChangedListener(new ISelectionChangedListener(){
    @Override public void selectionChanged(    SelectionChangedEvent event){
      BusinessAssignment businessAssignment=getBusinessAssignment(event.getSelection());
      if (businessAssignment != null) {
        final IRepositoryView repositoryView=getRepositoryView();
        if (repositoryView != null) {
          IProjectRepositoryNode rootRepositoryNode=repositoryView.getRoot();
          TalendItem item=businessAssignment.getTalendItem();
          if (item instanceof Routine && rootRepositoryNode instanceof ProjectRepositoryNode) {
            RepositoryNodeUtilities.expandParentNode(getRepositoryView(),((ProjectRepositoryNode)rootRepositoryNode).getRootRepositoryNode(ERepositoryObjectType.CODE));
          }
          selectChild(item,(IRepositoryNode)rootRepositoryNode);
        }
      }
    }
    private void selectChild(    TalendItem item,    IRepositoryNode rootRepositoryNode){
      try {
        RepositoryNode curNode=null;
        JobSettingsView viewer=(JobSettingsView)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(JobSettingsView.ID);
        IRepositoryViewObject lastVersion=ProxyRepositoryFactory.getInstance().getLastVersion(item.getId());
        if (lastVersion != null) {
          curNode=RepositoryNodeUtilities.getRepositoryNode(lastVersion);
          select(viewer,curNode);
        }
 else         if (item instanceof TableMetadata) {
          MetadataTable table=MetadataTool.getMetadataTableFromRepository(item.getId());
          if (table != null) {
            String id=item.getId().split("String_Node_Str")[0];
            RepositoryNode node=RepositoryNodeUtilities.getMetadataTableFromConnection(item.getId());
            IRepositoryView view=getRepositoryView();
            if (view != null) {
              RepositoryNodeUtilities.expandParentNode(view,node);
              select(viewer,node);
            }
          }
        }
 else         if (item instanceof Query) {
          org.talend.core.model.metadata.builder.connection.Query query=MetadataTool.getQueryFromRepository(item.getId());
          if (query != null) {
            String id=item.getId().split("String_Node_Str")[0];
            IRepositoryView view=getRepositoryView();
            RepositoryNode node=RepositoryNodeUtilities.getQueryFromConnection(item.getId());
            RepositoryNodeUtilities.expandParentNode(view,node);
            select(viewer,node);
          }
        }
 else         if (item instanceof SAPFunction) {
          SAPFunctionUnit function=MetadataTool.getSAPFunctionFromRepository(item.getId());
          if (function != null) {
            IRepositoryView view=getRepositoryView();
            RepositoryNode node=RepositoryNodeUtilities.getSAPFunctionFromConnection(item.getId());
            RepositoryNodeUtilities.expandParentNode(view,node);
            select(viewer,node);
          }
        }
 else {
          for (          IRepositoryNode node : rootRepositoryNode.getChildren()) {
            RepositoryNode rNode=(RepositoryNode)node;
            if (item instanceof SQLPattern && rNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.SQLPATTERNS) {
              if (rNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
                SQLPatternItem sqlItem=(SQLPatternItem)rNode.getObject().getProperty().getItem();
                if (sqlItem.isSystem() && item.getLabel().equals(rNode.getObject().getLabel())) {
                  select(viewer,rNode);
                }
              }
 else {
                selectChild(item,rNode);
              }
            }
 else             if (item instanceof Routine && rNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.ROUTINES) {
              if (rNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
                RoutineItem sqlItem=(RoutineItem)rNode.getObject().getProperty().getItem();
                if (sqlItem.isBuiltIn() && item.getLabel().equals(rNode.getObject().getLabel())) {
                  select(viewer,rNode);
                }
              }
 else {
                selectChild(item,rNode);
              }
            }
          }
        }
      }
 catch (      PersistenceException e) {
        ExceptionHandler.process(e);
      }
    }
    private void select(    JobSettingsView viewer,    RepositoryNode repositoryNode){
      if (viewer == null) {
        return;
      }
      if (repositoryNode == null) {
        return;
      }
      CorePlugin.getDefault().getRepositoryService().removeRepositoryTreeViewListener(viewer);
      final IRepositoryView repositoryView=getRepositoryView();
      if (repositoryView != null) {
        repositoryView.getViewer().setSelection(new StructuredSelection(repositoryNode));
      }
      CorePlugin.getDefault().getRepositoryService().addRepositoryTreeViewListener(viewer);
    }
  }
);
}