Program: 121003
Project: 121003
Buggy source:
/** 
 * Generate this tree Code.
 * @param subProcess the tree
 * @param node the tree root
 * @param part the part of code to generate
 * @return the generated code
 * @throws CodeGeneratorException if an error occurs during Code Generation
 */
private StringBuffer generatesTreeCode(NodesSubTree subProcess,INode node,ECodePart part,ETypeGen typeGen) throws CodeGeneratorException {
  StringBuffer code=new StringBuffer();
  if (node != null) {
    SubTreeArgument subTreeArgument=new SubTreeArgument();
    boolean sourceHasConditionnalBranches=node.hasConditionalOutputs() && part == ECodePart.MAIN;
    subTreeArgument.setSourceComponentHasConditionnalOutputs(sourceHasConditionnalBranches);
    if (part == ECodePart.MAIN) {
      subTreeArgument.setMultiplyingOutputComponents(node.isMultiplyingOutputs());
    }
    if (ETypeGen.ETL == typeGen) {
      for (int i=0; i < node.getOutgoingConnections().size(); i++) {
        IConnection connection=null;
        if (part == ECodePart.END) {
          connection=node.getOutgoingConnections().get(node.getOutgoingConnections().size() - (i + 1));
        }
 else {
          connection=node.getOutgoingConnections().get(i);
        }
        if ((connection.getLineStyle() == EConnectionType.ITERATE) && (part != ECodePart.MAIN)) {
          continue;
        }
        if ((connection.getLineStyle() == EConnectionType.ON_ROWS_END) && (part != ECodePart.END)) {
          continue;
        }
        if (connection.getLineStyle().hasConnectionCategory(EConnectionType.DEPENDENCY)) {
          continue;
        }
        if (connection.getLineStyle().hasConnectionCategory(EConnectionType.USE_HASH)) {
          continue;
        }
        INode targetNode=connection.getTarget();
        if ((targetNode != null) && (subProcess != null)) {
          if (!connection.getLineStyle().hasConnectionCategory(IConnectionCategory.MERGE)) {
            subTreeArgument.setInputSubtreeConnection(connection);
            code.append(generateTypedComponentCode(EInternalTemplate.SUBTREE_BEGIN,subTreeArgument));
            code.append(generateComponentsCode(subProcess,targetNode,part,connection.getName(),typeGen));
            code.append(generateTypedComponentCode(EInternalTemplate.SUBTREE_END,subTreeArgument));
          }
 else           if (part == ECodePart.MAIN) {
            subTreeArgument.setInputSubtreeConnection(connection);
            code.append(generateTypedComponentCode(EInternalTemplate.SUBTREE_BEGIN,subTreeArgument));
            code.append(generateComponentsCode(subProcess,targetNode,ECodePart.MAIN,getIncomingNameForMerge(node,targetNode),typeGen));
            code.append(generateTypedComponentCode(EInternalTemplate.SUBTREE_END,subTreeArgument));
          }
        }
      }
    }
 else     if (ETypeGen.CAMEL == typeGen) {
      for (      IConnection connection : node.getOutgoingCamelSortedConnections()) {
        INode targetNode=connection.getTarget();
        if ((targetNode != null) && (subProcess != null)) {
          subTreeArgument.setInputSubtreeConnection(connection);
          code.append(generateComponentsCode(subProcess,targetNode,part,connection.getName(),typeGen));
        }
      }
    }
    if (part == ECodePart.MAIN && node.getBlocksCodeToClose() != null) {
      CloseBlocksCodeArgument closeBlocksArgument=new CloseBlocksCodeArgument();
      closeBlocksArgument.setBlocksCodeToClose(node.getBlocksCodeToClose());
      code.append(generateTypedComponentCode(EInternalTemplate.CLOSE_BLOCKS_CODE,closeBlocksArgument));
    }
  }
  return code;
}

Fixed version (ground truth):
/** 
 * Generate this tree Code.
 * @param subProcess the tree
 * @param node the tree root
 * @param part the part of code to generate
 * @return the generated code
 * @throws CodeGeneratorException if an error occurs during Code Generation
 */
private StringBuffer generatesTreeCode(NodesSubTree subProcess,INode node,ECodePart part,ETypeGen typeGen) throws CodeGeneratorException {
  StringBuffer code=new StringBuffer();
  if (node != null) {
    SubTreeArgument subTreeArgument=new SubTreeArgument();
    boolean sourceHasConditionnalBranches=node.hasConditionalOutputs() && part == ECodePart.MAIN;
    subTreeArgument.setSourceComponentHasConditionnalOutputs(sourceHasConditionnalBranches);
    if (part == ECodePart.MAIN) {
      subTreeArgument.setMultiplyingOutputComponents(node.isMultiplyingOutputs());
    }
    if (ETypeGen.ETL == typeGen) {
      for (int i=0; i < node.getOutgoingConnections().size(); i++) {
        IConnection connection=null;
        if (part == ECodePart.BEGIN) {
          connection=node.getOutgoingConnections().get(node.getOutgoingConnections().size() - (i + 1));
        }
 else {
          connection=node.getOutgoingConnections().get(i);
        }
        if ((connection.getLineStyle() == EConnectionType.ITERATE) && (part != ECodePart.MAIN)) {
          continue;
        }
        if ((connection.getLineStyle() == EConnectionType.ON_ROWS_END) && (part != ECodePart.END)) {
          continue;
        }
        if (connection.getLineStyle().hasConnectionCategory(EConnectionType.DEPENDENCY)) {
          continue;
        }
        if (connection.getLineStyle().hasConnectionCategory(EConnectionType.USE_HASH)) {
          continue;
        }
        INode targetNode=connection.getTarget();
        if ((targetNode != null) && (subProcess != null)) {
          if (!connection.getLineStyle().hasConnectionCategory(IConnectionCategory.MERGE)) {
            subTreeArgument.setInputSubtreeConnection(connection);
            code.append(generateTypedComponentCode(EInternalTemplate.SUBTREE_BEGIN,subTreeArgument));
            code.append(generateComponentsCode(subProcess,targetNode,part,connection.getName(),typeGen));
            code.append(generateTypedComponentCode(EInternalTemplate.SUBTREE_END,subTreeArgument));
          }
 else           if (part == ECodePart.MAIN) {
            subTreeArgument.setInputSubtreeConnection(connection);
            code.append(generateTypedComponentCode(EInternalTemplate.SUBTREE_BEGIN,subTreeArgument));
            code.append(generateComponentsCode(subProcess,targetNode,ECodePart.MAIN,getIncomingNameForMerge(node,targetNode),typeGen));
            code.append(generateTypedComponentCode(EInternalTemplate.SUBTREE_END,subTreeArgument));
          }
        }
      }
    }
 else     if (ETypeGen.CAMEL == typeGen) {
      for (      IConnection connection : node.getOutgoingCamelSortedConnections()) {
        INode targetNode=connection.getTarget();
        if ((targetNode != null) && (subProcess != null)) {
          subTreeArgument.setInputSubtreeConnection(connection);
          code.append(generateComponentsCode(subProcess,targetNode,part,connection.getName(),typeGen));
        }
      }
    }
    if (part == ECodePart.MAIN && node.getBlocksCodeToClose() != null) {
      CloseBlocksCodeArgument closeBlocksArgument=new CloseBlocksCodeArgument();
      closeBlocksArgument.setBlocksCodeToClose(node.getBlocksCodeToClose());
      code.append(generateTypedComponentCode(EInternalTemplate.CLOSE_BLOCKS_CODE,closeBlocksArgument));
    }
  }
  return code;
}