Program: 118148
Project: 118148
Buggy source:
public void selectionChanged(final IStructuredSelection selection){
  if (!selection.isEmpty() && selectedContext == null) {
    RepositoryNode repositoryNode=(RepositoryNode)selection.getFirstElement();
    if (repositoryNode.getObject() != null) {
      Item item=repositoryNode.getObject().getProperty().getItem();
      if (item instanceof DatabaseConnectionItem) {
        org.talend.core.model.metadata.builder.connection.Connection connection=((DatabaseConnectionItem)item).getConnection();
        if (connection.isContextMode()) {
          ContextItem contextItem=ContextUtils.getContextItemById2(connection.getContextId());
          if (contextItem != null && connection.isContextMode()) {
            ContextSetsSelectionDialog setsDialog=new ContextSetsSelectionDialog(shell,contextItem,false);
            setsDialog.open();
            selectedContext=setsDialog.getSelectedContext();
          }
        }
      }
    }
  }
  IRunnableWithProgress progress=new IRunnableWithProgress(){
    public void run(    IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
      monitor.beginTask("String_Node_Str",IProgressMonitor.UNKNOWN);
      try {
        Display.getDefault().asyncExec(new Runnable(){
          public void run(){
            INode node=null;
            String msg=null;
            if (!selection.isEmpty()) {
              try {
                final RepositoryNode repositoryNode=(RepositoryNode)selection.getFirstElement();
                if (SQLBuilderRepositoryNodeManager.getRepositoryType(repositoryNode) == RepositoryNodeType.FOLDER) {
                  return;
                }
                sessionTreeNode=nodeManager.getSessionTreeNode(repositoryNode,selectedContext);
                node=nodeManager.convert2INode(repositoryNode,selectedContext,sessionTreeNode);
              }
 catch (              Exception e) {
                msg=e.getMessage();
                SqlBuilderPlugin.log(msg,e);
              }
              final INode argNode=node;
              final String argMsg=msg;
              dbDetailsComposite.setSelectedNode(argNode,argMsg);
              wapperDriver=sessionTreeNode.getWapperDriver();
              String dbType=sessionTreeNode.getDatabaseConnection().getDatabaseType();
              String driverClassName=sessionTreeNode.getDatabaseConnection().getDriverClass();
              if (wapperDriver != null && (driverClassName.equals(EDatabase4DriverClassName.JAVADB_EMBEDED.getDriverClass()) || dbType.equals(EDatabaseTypeName.JAVADB_EMBEDED.getDisplayName()) || dbType.equals(EDatabaseTypeName.JAVADB_DERBYCLIENT.getDisplayName())|| dbType.equals(EDatabaseTypeName.JAVADB_JCCJDBC.getDisplayName()))) {
                try {
                  wapperDriver.connect("String_Node_Str",null);
                }
 catch (                SQLException e) {
                }
              }
            }
          }
        }
);
      }
  finally {
        monitor.done();
      }
    }
  }
;
  UIUtils.runWithProgress(progress,true,getProgressMonitor(),getShell());
}

Fixed version (ground truth):
@Override public void selectionChanged(final IStructuredSelection selection){
  if (!selection.isEmpty() && selectedContext == null) {
    RepositoryNode repositoryNode=(RepositoryNode)selection.getFirstElement();
    if (repositoryNode.getObject() != null) {
      Item item=repositoryNode.getObject().getProperty().getItem();
      if (item instanceof DatabaseConnectionItem) {
        org.talend.core.model.metadata.builder.connection.Connection connection=((DatabaseConnectionItem)item).getConnection();
        if (connection.isContextMode()) {
          ContextItem contextItem=ContextUtils.getContextItemById2(connection.getContextId());
          if (contextItem != null && connection.isContextMode()) {
            ContextSetsSelectionDialog setsDialog=new ContextSetsSelectionDialog(shell,contextItem,false);
            setsDialog.open();
            selectedContext=setsDialog.getSelectedContext();
          }
        }
      }
    }
  }
  IRunnableWithProgress progress=new IRunnableWithProgress(){
    @Override public void run(    IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
      monitor.beginTask("String_Node_Str",IProgressMonitor.UNKNOWN);
      try {
        Display.getDefault().asyncExec(new Runnable(){
          @Override public void run(){
            INode node=null;
            String msg=null;
            if (!selection.isEmpty()) {
              try {
                final RepositoryNode repositoryNode=(RepositoryNode)selection.getFirstElement();
                if (SQLBuilderRepositoryNodeManager.getRepositoryType(repositoryNode) == RepositoryNodeType.FOLDER) {
                  return;
                }
                sessionTreeNode=nodeManager.getSessionTreeNode(repositoryNode,selectedContext);
                node=nodeManager.convert2INode(repositoryNode,selectedContext,sessionTreeNode);
              }
 catch (              Exception e) {
                msg=e.getMessage();
                SqlBuilderPlugin.log(msg,e);
              }
              final INode argNode=node;
              final String argMsg=msg;
              dbDetailsComposite.setSelectedNode(argNode,argMsg);
              wapperDriver=sessionTreeNode.getWapperDriver();
              String dbType=sessionTreeNode.getDatabaseConnection().getDatabaseType();
              String driverClassName=sessionTreeNode.getDatabaseConnection().getDriverClass();
              if (wapperDriver != null && (driverClassName.equals(EDatabase4DriverClassName.JAVADB_EMBEDED.getDriverClass()) || dbType.equals(EDatabaseTypeName.JAVADB_EMBEDED.getDisplayName()) || dbType.equals(EDatabaseTypeName.JAVADB_DERBYCLIENT.getDisplayName())|| dbType.equals(EDatabaseTypeName.JAVADB_JCCJDBC.getDisplayName()))) {
                try {
                  wapperDriver.connect("String_Node_Str",null);
                }
 catch (                SQLException e) {
                }
              }
            }
          }
        }
);
      }
  finally {
        monitor.done();
      }
    }
  }
;
  UIUtils.runWithProgress(progress,true,getProgressMonitor(),getShell());
}