Program: 124646
Project: 124646
Buggy source:
protected HDFSConnectionBean getHDFSConnectionBean(){
  INode node=(INode)elem;
  IProcess process=node.getProcess();
  IContext context=null;
  IContextManager cm=process.getContextManager();
  if (cm != null) {
    context=cm.getDefaultContext();
  }
  boolean isMr=false;
  HDFSConnectionBean connectionBean=new HDFSConnectionBean();
  String useExistingConnection=ElementParameterParser.getValue(elem,"String_Node_Str");
  if ("String_Node_Str".equalsIgnoreCase(useExistingConnection)) {
    String connectionName=ElementParameterParser.getValue(node,"String_Node_Str");
    List<? extends INode> nodes=node.getProcess().getGeneratingNodes();
    for (    INode iNode : nodes) {
      if (iNode.getUniqueName().equals(connectionName)) {
        node=iNode;
        break;
      }
    }
  }
 else   if (node != null && node.getComponent() != null && node.getComponent().getPaletteType() != null && node.getComponent().getPaletteType().equals("String_Node_Str")) {
    List<? extends INode> nodes=node.getProcess().getGeneratingNodes();
    for (    INode iNode : nodes) {
      IComponent component=iNode.getComponent();
      if (component != null && component.getName() != null && component.getName().equals("String_Node_Str")) {
        isMr=true;
        node=iNode;
        if (node instanceof DataNode || node instanceof BigDataNode) {
          String versionParameter=(String)getParameterValue(node,EHadoopParameter.VERSION.getName());
          if (versionParameter != null) {
            connectionBean.setDfVersion(versionParameter);
          }
          String nameNodeParameter=getParameterValueWithContext(node,context,EHadoopParameter.NAMENODE_URI.getName());
          if (nameNodeParameter != null) {
            connectionBean.setNameNodeURI(nameNodeParameter);
          }
        }
      }
    }
  }
 else   if (node != null && node.getComponent() != null && node.getComponent().getPaletteType() != null && node.getComponent().getPaletteType().startsWith("String_Node_Str")) {
    boolean browseIsSupported=false;
    boolean defineStorageConfiguration=(Boolean)getParameterValue(node,"String_Node_Str");
    if (defineStorageConfiguration) {
      String configurationComponent=(String)getParameterValue(node,"String_Node_Str");
      if (configurationComponent.startsWith("String_Node_Str")) {
        List<? extends INode> nodes=node.getProcess().getGeneratingNodes();
        for (        INode iNode : nodes) {
          if (configurationComponent.equals(iNode.getUniqueName())) {
            browseIsSupported=true;
            isMr=true;
            node=iNode;
            String versionParameter=(String)getParameterValue(node,EHadoopParameter.VERSION.getName());
            if (versionParameter != null) {
              connectionBean.setDfVersion(versionParameter);
            }
            String nameNodeParameter=getParameterValueWithContext(node,context,EHadoopParameter.NAMENODE_URI.getName());
            if (nameNodeParameter != null) {
              connectionBean.setNameNodeURI(nameNodeParameter);
            }
          }
        }
      }
    }
    if (!browseIsSupported) {
      IRunnableWithProgress runnableWithProgress=new IRunnableWithProgress(){
        @Override public void run(        IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
          monitor.beginTask(Messages.getString("String_Node_Str"),IProgressMonitor.UNKNOWN);
          PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable(){
            @Override public void run(){
              new ErrorDialogWidthDetailArea(PlatformUI.getWorkbench().getDisplay().getActiveShell(),HDFSPlugin.PLUGIN_ID,Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"));
              return;
            }
          }
);
        }
      }
;
      ProgressMonitorDialog dialog=new ProgressMonitorDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell());
      try {
        dialog.run(true,true,runnableWithProgress);
      }
 catch (      Exception e) {
        ExceptionHandler.process(e);
      }
      return null;
    }
  }
  String distribution=(String)getParameterValue(node,EHadoopParameter.DISTRIBUTION.getName());
  if (!isMr) {
    String version=(String)getParameterValue(node,EHadoopParameter.VERSION.getName());
    String nameNodeUri=getParameterValueWithContext(node,context,EHadoopParameter.NAMENODE_URI.getName());
    connectionBean.setDfVersion(version);
    connectionBean.setNameNodeURI(nameNodeUri);
  }
  EHadoopVersion4Drivers version4Drivers=EHadoopVersion4Drivers.indexOfByVersion(connectionBean.getDfVersion());
  if (version4Drivers != null && version4Drivers.isSupportGroup()) {
    String group=getParameterValueWithContext(node,context,EHadoopParameter.GROUP.getName());
    connectionBean.setGroup(group);
  }
  String userName=getParameterValueWithContext(node,context,EHadoopParameter.USERNAME.getName());
  Boolean useKrb=(Boolean)getParameterValue(node,EHadoopParameter.USE_KRB.getName());
  Boolean useMaprTicket=(Boolean)getParameterValue(node,EHadoopParameter.USE_MAPRTICKET.getName());
  String nnPrincipal=getParameterValueWithContext(node,context,EHadoopParameter.NAMENODE_PRINCIPAL.getName());
  Boolean useKeytab=(Boolean)getParameterValue(node,EHadoopParameter.USE_KEYTAB.getName());
  String ktPrincipal=getParameterValueWithContext(node,context,EHadoopParameter.PRINCIPAL.getName());
  String ktPath=getParameterValueWithContext(node,context,EHadoopParameter.KEYTAB_PATH.getName());
  Boolean isUseCustom=EHadoopDistributions.CUSTOM.getName().equals(distribution);
  if (isUseCustom) {
    Object authMode=getParameterValue(node,EHadoopParameter.AUTHENTICATION_MODE.getName());
    if ("String_Node_Str".equals(authMode)) {
      useKrb=true;
    }
  }
  if (!isMr && node != null && node.getComponent() != null && node.getComponent().getName().equals("String_Node_Str")) {
    if ("String_Node_Str".equalsIgnoreCase(useExistingConnection) || useKrb || (distribution.equals("String_Node_Str") && !useMaprTicket)) {
      userName="String_Node_Str";
    }
  }
  String customJars=(String)getParameterValue(node,EHadoopParameter.HADOOP_CUSTOM_JARS.getName());
  connectionBean.setDistribution(distribution);
  connectionBean.setUserName(userName);
  connectionBean.setEnableKerberos(useKrb != null ? useKrb : false);
  connectionBean.setPrincipal(nnPrincipal);
  connectionBean.setUseKeytab(useKeytab != null ? useKeytab : false);
  connectionBean.setKeytabPrincipal(ktPrincipal);
  connectionBean.setKeytab(ktPath);
  connectionBean.setUseCustomVersion(isUseCustom != null ? isUseCustom : false);
  if (StringUtils.isNotBlank(customJars)) {
    connectionBean.getAdditionalProperties().put(ECustomVersionGroup.COMMON.getName(),customJars);
  }
  if (process instanceof IProcess2) {
    IProcess2 pro=(IProcess2)process;
    connectionBean.setRelativeHadoopClusterId(pro.getProperty().getId());
    IElementParameter propertyParam=node.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
    if (propertyParam != null) {
      IElementParameter repositoryType=propertyParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName());
      if (repositoryType != null && EmfComponent.REPOSITORY.equals(repositoryType.getValue())) {
        IHadoopClusterService hadoopClusterService=null;
        String relativeHadoopClusterId=null;
        IElementParameter repositoryId=propertyParam.getChildParameters().get((EParameterName.REPOSITORY_PROPERTY_TYPE.getName()));
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IHadoopClusterService.class)) {
          hadoopClusterService=(IHadoopClusterService)GlobalServiceRegister.getDefault().getService(IHadoopClusterService.class);
        }
        if (hadoopClusterService != null) {
          Item item=hadoopClusterService.getHadoopClusterBySubitemId(((String)repositoryId.getValue()));
          if (item != null) {
            relativeHadoopClusterId=item.getProperty().getId();
            if (relativeHadoopClusterId != null) {
              connectionBean.setRelativeHadoopClusterId(relativeHadoopClusterId);
            }
          }
        }
      }
    }
  }
  return connectionBean;
}

Fixed version (ground truth):
protected HDFSConnectionBean getHDFSConnectionBean(){
  INode node=(INode)elem;
  IProcess process=node.getProcess();
  IContext context=null;
  IContextManager cm=process.getContextManager();
  if (cm != null) {
    context=cm.getDefaultContext();
  }
  boolean isMr=false;
  HDFSConnectionBean connectionBean=new HDFSConnectionBean();
  String useExistingConnection=ElementParameterParser.getValue(elem,"String_Node_Str");
  if ("String_Node_Str".equalsIgnoreCase(useExistingConnection)) {
    String connectionName=ElementParameterParser.getValue(node,"String_Node_Str");
    List<? extends INode> nodes=node.getProcess().getGeneratingNodes();
    for (    INode iNode : nodes) {
      if (iNode.getUniqueName().equals(connectionName)) {
        node=iNode;
        break;
      }
    }
  }
 else   if (node != null && node.getComponent() != null && node.getComponent().getPaletteType() != null && node.getComponent().getPaletteType().equals("String_Node_Str")) {
    List<? extends INode> nodes=node.getProcess().getGeneratingNodes();
    for (    INode iNode : nodes) {
      IComponent component=iNode.getComponent();
      if (component != null && component.getName() != null && component.getName().equals("String_Node_Str")) {
        isMr=true;
        node=iNode;
        if (node instanceof DataNode || node instanceof BigDataNode) {
          String versionParameter=(String)getParameterValue(node,EHadoopParameter.VERSION.getName());
          if (versionParameter != null) {
            connectionBean.setDfVersion(versionParameter);
          }
          String nameNodeParameter=getParameterValueWithContext(node,context,EHadoopParameter.NAMENODE_URI.getName());
          if (nameNodeParameter != null) {
            connectionBean.setNameNodeURI(nameNodeParameter);
          }
        }
      }
    }
  }
 else   if (node != null && node.getComponent() != null && node.getComponent().getPaletteType() != null && node.getComponent().getPaletteType().startsWith("String_Node_Str")) {
    boolean browseIsSupported=false;
    boolean defineStorageConfiguration=(Boolean)getParameterValue(node,"String_Node_Str");
    if (defineStorageConfiguration) {
      String configurationComponent=(String)getParameterValue(node,"String_Node_Str");
      if (configurationComponent.startsWith("String_Node_Str")) {
        List<? extends INode> nodes=node.getProcess().getGeneratingNodes();
        for (        INode iNode : nodes) {
          if (configurationComponent.equals(iNode.getUniqueName())) {
            browseIsSupported=true;
            isMr=true;
            node=iNode;
            String versionParameter=(String)getParameterValue(node,EHadoopParameter.VERSION.getName());
            if (versionParameter != null) {
              connectionBean.setDfVersion(versionParameter);
            }
            String nameNodeParameter=getParameterValueWithContext(node,context,EHadoopParameter.NAMENODE_URI.getName());
            if (nameNodeParameter != null) {
              connectionBean.setNameNodeURI(nameNodeParameter);
            }
          }
        }
      }
    }
    if (!browseIsSupported) {
      IRunnableWithProgress runnableWithProgress=new IRunnableWithProgress(){
        @Override public void run(        IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
          monitor.beginTask(Messages.getString("String_Node_Str"),IProgressMonitor.UNKNOWN);
          PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable(){
            @Override public void run(){
              new ErrorDialogWidthDetailArea(PlatformUI.getWorkbench().getDisplay().getActiveShell(),HDFSPlugin.PLUGIN_ID,Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"));
              return;
            }
          }
);
        }
      }
;
      ProgressMonitorDialog dialog=new ProgressMonitorDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell());
      try {
        dialog.run(true,true,runnableWithProgress);
      }
 catch (      Exception e) {
        ExceptionHandler.process(e);
      }
      return null;
    }
  }
  String distribution=(String)getParameterValue(node,EHadoopParameter.DISTRIBUTION.getName());
  if (!isMr) {
    String version=(String)getParameterValue(node,EHadoopParameter.VERSION.getName());
    String nameNodeUri=getParameterValueWithContext(node,context,EHadoopParameter.NAMENODE_URI.getName());
    connectionBean.setDfVersion(version);
    connectionBean.setNameNodeURI(nameNodeUri);
  }
  EHadoopVersion4Drivers version4Drivers=EHadoopVersion4Drivers.indexOfByVersion(connectionBean.getDfVersion());
  if (version4Drivers != null && version4Drivers.isSupportGroup()) {
    String group=getParameterValueWithContext(node,context,EHadoopParameter.GROUP.getName());
    connectionBean.setGroup(group);
  }
  String userName=getParameterValueWithContext(node,context,EHadoopParameter.USERNAME.getName());
  Boolean useKrb=(Boolean)getParameterValue(node,EHadoopParameter.USE_KRB.getName());
  Boolean useMaprTicket=(Boolean)getParameterValue(node,EHadoopParameter.USE_MAPRTICKET.getName());
  String nnPrincipal=getParameterValueWithContext(node,context,EHadoopParameter.NAMENODE_PRINCIPAL.getName());
  Boolean useKeytab=(Boolean)getParameterValue(node,EHadoopParameter.USE_KEYTAB.getName());
  String ktPrincipal=getParameterValueWithContext(node,context,EHadoopParameter.PRINCIPAL.getName());
  String ktPath=getParameterValueWithContext(node,context,EHadoopParameter.KEYTAB_PATH.getName());
  Boolean isUseCustom=EHadoopDistributions.CUSTOM.getName().equals(distribution);
  if (isUseCustom) {
    Object authMode=getParameterValue(node,EHadoopParameter.AUTHENTICATION_MODE.getName());
    if ("String_Node_Str".equals(authMode)) {
      useKrb=true;
    }
  }
  if (!isMr && node != null && node.getComponent() != null && node.getComponent().getName().equals("String_Node_Str")) {
    if ("String_Node_Str".equalsIgnoreCase(useExistingConnection) || useKrb || (distribution.equals("String_Node_Str") && !useMaprTicket)) {
      userName="String_Node_Str";
    }
  }
  String customJars=(String)getParameterValue(node,EHadoopParameter.HADOOP_CUSTOM_JARS.getName());
  connectionBean.setDistribution(distribution);
  connectionBean.setUserName(userName);
  connectionBean.setEnableKerberos(useKrb != null ? useKrb : false);
  connectionBean.setPrincipal(nnPrincipal);
  connectionBean.setUseKeytab(useKeytab != null ? useKeytab : false);
  connectionBean.setKeytabPrincipal(ktPrincipal);
  connectionBean.setKeytab(ktPath);
  connectionBean.setUseCustomVersion(isUseCustom != null ? isUseCustom : false);
  if (StringUtils.isNotBlank(customJars)) {
    connectionBean.getAdditionalProperties().put(ECustomVersionGroup.COMMON.getName(),customJars);
  }
  if (process instanceof IProcess2) {
    IProcess2 pro=(IProcess2)process;
    connectionBean.setRelativeHadoopClusterId(pro.getProperty().getId());
    IElementParameter propertyParam=node.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
    if (propertyParam != null) {
      IElementParameter repositoryType=propertyParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName());
      if (repositoryType != null && EmfComponent.REPOSITORY.equals(repositoryType.getValue())) {
        IHadoopClusterService hadoopClusterService=null;
        String relativeHadoopClusterId=null;
        IElementParameter repositoryId=propertyParam.getChildParameters().get((EParameterName.REPOSITORY_PROPERTY_TYPE.getName()));
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IHadoopClusterService.class)) {
          hadoopClusterService=(IHadoopClusterService)GlobalServiceRegister.getDefault().getService(IHadoopClusterService.class);
        }
        if (hadoopClusterService != null) {
          Item item=hadoopClusterService.getHadoopClusterBySubitemId(((String)repositoryId.getValue()));
          if (item != null) {
            relativeHadoopClusterId=item.getProperty().getId();
            if (relativeHadoopClusterId != null) {
              connectionBean.setRelativeHadoopClusterId(relativeHadoopClusterId);
            }
          }
        }
      }
    }
  }
  connectionBean.getConfigurations().putAll(getHadoopProperties(node,context));
  return connectionBean;
}