Program: 120801
Project: 120801
Buggy source:
/** 
 * Generate Code Parts for a Sub Process .
 * @param subProcess the suprocess
 * @param node the subprocess root
 * @param part the part of code to generate
 * @return the generated code
 * @throws CodeGeneratorException if an error occurs during Code Generation
 */
private StringBuffer generateComponentsCode(NodesSubTree subProcess,INode node,ECodePart part,String incomingName,ETypeGen typeGen) throws CodeGeneratorException {
  StringBuffer codeComponent=new StringBuffer();
  Boolean isMarked=subProcess.isMarkedNode(node,part);
  boolean isIterate=isSpecifyInputNode(node,incomingName,EConnectionType.ITERATE);
  if ((isMarked != null) && (!isMarked)) {
switch (part) {
case BEGIN:
      codeComponent.append(generatesTreeCode(subProcess,node,ECodePart.BEGIN,typeGen));
    codeComponent.append(generateComponentCode(subProcess,node,ECodePart.BEGIN,incomingName,typeGen));
  break;
case MAIN:
if (isIterate) {
  codeComponent.append(generateTypedComponentCode(EInternalTemplate.ITERATE_SUBPROCESS_HEADER,node,ECodePart.BEGIN,incomingName,subProcess));
  codeComponent.append(generatesTreeCode(subProcess,node,ECodePart.BEGIN,typeGen));
  codeComponent.append(generateComponentCode(subProcess,node,ECodePart.BEGIN,incomingName,typeGen));
  codeComponent.append(generateComponentCode(subProcess,node,ECodePart.MAIN,incomingName,typeGen));
  codeComponent.append(generatesTreeCode(subProcess,node,ECodePart.MAIN,typeGen));
  codeComponent.append(generateComponentCode(subProcess,node,ECodePart.END,incomingName,typeGen));
  codeComponent.append(generatesTreeCode(subProcess,node,ECodePart.END,typeGen));
  codeComponent.append(generateTypedComponentCode(EInternalTemplate.ITERATE_SUBPROCESS_FOOTER,node,ECodePart.END,incomingName,subProcess));
}
 else {
  if (ETypeGen.CAMEL == typeGen) {
    if (node.getIncomingConnections() != null && node.getIncomingConnections().size() > 0) {
      if (!(node.getIncomingConnections().get(0).getLineStyle().equals(EConnectionType.ROUTE))) {
        codeComponent.append(generateTypedComponentCode(EInternalTemplate.CAMEL_SPECIALLINKS,node));
      }
    }
  }
  codeComponent.append(generateComponentCode(subProcess,node,ECodePart.MAIN,incomingName,typeGen));
  if (ETypeGen.CAMEL == typeGen) {
    if (node.getIncomingConnections().size() < 1 && node.isStart()) {
      String label=null;
      IElementParameter parameter=node.getElementParameter("String_Node_Str");
      if (parameter != null && !"String_Node_Str".equals(parameter.getValue())) {
        label=(String)parameter.getValue();
      }
      if (label == null) {
        label=node.getUniqueName();
      }
 else {
        label+="String_Node_Str" + node.getUniqueName();
      }
      if (!"String_Node_Str".equals(node.getComponent().getName())) {
        codeComponent.append("String_Node_Str" + label + "String_Node_Str");
      }
    }
 else {
      codeComponent.append("String_Node_Str" + node.getUniqueName() + "String_Node_Str");
    }
  }
  codeComponent.append(generatesTreeCode(subProcess,node,ECodePart.MAIN,typeGen));
  boolean isNextOnRowsEnd=false;
  IConnection conn=null;
  if (node.getOutgoingConnections(EConnectionType.ON_ROWS_END).size() == 1) {
    conn=node.getOutgoingConnections(EConnectionType.ON_ROWS_END).get(0);
    isNextOnRowsEnd=isSpecifyInputNode(conn.getTarget(),conn.getName(),EConnectionType.ON_ROWS_END);
  }
  if (isNextOnRowsEnd && conn != null) {
    onRowsEndCode.increase();
    onRowsEndCode.append(generatesTreeCode(subProcess,conn.getTarget(),ECodePart.BEGIN,typeGen));
    onRowsEndCode.append(generateComponentCode(subProcess,conn.getTarget(),ECodePart.BEGIN,incomingName,typeGen));
    onRowsEndCode.append(generateComponentCode(subProcess,conn.getTarget(),ECodePart.MAIN,incomingName,typeGen));
    onRowsEndCode.append(generatesTreeCode(subProcess,conn.getTarget(),ECodePart.MAIN,typeGen));
    onRowsEndCode.append(generateComponentCode(subProcess,conn.getTarget(),ECodePart.END,incomingName,typeGen));
    onRowsEndCode.append(generatesTreeCode(subProcess,conn.getTarget(),ECodePart.END,typeGen));
  }
}
break;
case END:
boolean isOnRowsEnd=isSpecifyInputNode(node,incomingName,EConnectionType.ON_ROWS_END);
if (isOnRowsEnd) {
onRowsEndCode.decrease();
if (onRowsEndCode.getCount() == 0) {
codeComponent.append(onRowsEndCode.getContent());
onRowsEndCode.clear();
}
}
 else {
codeComponent.append(generateComponentCode(subProcess,node,ECodePart.END,incomingName,typeGen));
codeComponent.append(generatesTreeCode(subProcess,node,part,typeGen));
}
break;
default :
}
subProcess.markNode(node,part);
}
return codeComponent;
}

Fixed version (ground truth):
/** 
 * Generate Code Parts for a Sub Process .
 * @param subProcess the suprocess
 * @param node the subprocess root
 * @param part the part of code to generate
 * @return the generated code
 * @throws CodeGeneratorException if an error occurs during Code Generation
 */
private StringBuffer generateComponentsCode(NodesSubTree subProcess,INode node,ECodePart part,String incomingName,ETypeGen typeGen) throws CodeGeneratorException {
  StringBuffer codeComponent=new StringBuffer();
  Boolean isMarked=subProcess.isMarkedNode(node,part);
  boolean isIterate=isSpecifyInputNode(node,incomingName,EConnectionType.ITERATE);
  if ((isMarked != null) && (!isMarked)) {
switch (part) {
case BEGIN:
      codeComponent.append(generatesTreeCode(subProcess,node,ECodePart.BEGIN,typeGen));
    codeComponent.append(generateComponentCode(subProcess,node,ECodePart.BEGIN,incomingName,typeGen));
  break;
case MAIN:
if (isIterate) {
  codeComponent.append(generateTypedComponentCode(EInternalTemplate.ITERATE_SUBPROCESS_HEADER,node,ECodePart.BEGIN,incomingName,subProcess));
  codeComponent.append(generatesTreeCode(subProcess,node,ECodePart.BEGIN,typeGen));
  codeComponent.append(generateComponentCode(subProcess,node,ECodePart.BEGIN,incomingName,typeGen));
  codeComponent.append(generateComponentCode(subProcess,node,ECodePart.MAIN,incomingName,typeGen));
  codeComponent.append(generatesTreeCode(subProcess,node,ECodePart.MAIN,typeGen));
  codeComponent.append(generateComponentCode(subProcess,node,ECodePart.END,incomingName,typeGen));
  codeComponent.append(generatesTreeCode(subProcess,node,ECodePart.END,typeGen));
  codeComponent.append(generateTypedComponentCode(EInternalTemplate.ITERATE_SUBPROCESS_FOOTER,node,ECodePart.END,incomingName,subProcess));
}
 else {
  if (ETypeGen.CAMEL == typeGen) {
    if (node.getIncomingConnections() != null && node.getIncomingConnections().size() > 0) {
      if (!(node.getIncomingConnections().get(0).getLineStyle().equals(EConnectionType.ROUTE))) {
        codeComponent.append(generateTypedComponentCode(EInternalTemplate.CAMEL_SPECIALLINKS,node));
      }
    }
  }
  codeComponent.append(generateComponentCode(subProcess,node,ECodePart.MAIN,incomingName,typeGen));
  if (ETypeGen.CAMEL == typeGen) {
    if (node.getIncomingConnections().size() < 1 && node.isStart()) {
      String label=null;
      IElementParameter parameter=node.getElementParameter("String_Node_Str");
      if (parameter != null && !"String_Node_Str".equals(parameter.getValue())) {
        label=(String)parameter.getValue();
      }
      if (label == null) {
        label=node.getUniqueName();
      }
 else {
        label+="String_Node_Str" + node.getUniqueName();
      }
      if (!"String_Node_Str".equals(node.getComponent().getName())) {
        codeComponent.append("String_Node_Str" + label + "String_Node_Str");
      }
    }
 else {
      codeComponent.append("String_Node_Str" + node.getUniqueName() + "String_Node_Str");
    }
  }
  boolean isNextOnRowsEnd=false;
  IConnection conn=null;
  if (node.getOutgoingConnections(EConnectionType.ON_ROWS_END).size() == 1) {
    conn=node.getOutgoingConnections(EConnectionType.ON_ROWS_END).get(0);
    isNextOnRowsEnd=isSpecifyInputNode(conn.getTarget(),conn.getName(),EConnectionType.ON_ROWS_END);
  }
  if (isNextOnRowsEnd && conn != null) {
    StringBuffer buffer=new StringBuffer();
    onRowsEndCode.add(buffer);
    onRowsEndCode.increase();
    buffer.append(generatesTreeCode(subProcess,conn.getTarget(),ECodePart.BEGIN,typeGen));
    buffer.append(generateComponentCode(subProcess,conn.getTarget(),ECodePart.BEGIN,incomingName,typeGen));
    buffer.append(generateComponentCode(subProcess,conn.getTarget(),ECodePart.MAIN,incomingName,typeGen));
    buffer.append(generatesTreeCode(subProcess,conn.getTarget(),ECodePart.MAIN,typeGen));
    buffer.append(generateComponentCode(subProcess,conn.getTarget(),ECodePart.END,incomingName,typeGen));
    buffer.append(generatesTreeCode(subProcess,conn.getTarget(),ECodePart.END,typeGen));
  }
  codeComponent.append(generatesTreeCode(subProcess,node,ECodePart.MAIN,typeGen));
}
break;
case END:
boolean isOnRowsEnd=isSpecifyInputNode(node,incomingName,EConnectionType.ON_ROWS_END);
if (isOnRowsEnd) {
onRowsEndCode.decrease();
if (onRowsEndCode.getCount() == 0) {
for (int i=0; i < onRowsEndCode.getBuffers().size(); i++) {
codeComponent.append(onRowsEndCode.getBuffers().get(i));
}
onRowsEndCode.clear();
}
}
 else {
codeComponent.append(generateComponentCode(subProcess,node,ECodePart.END,incomingName,typeGen));
codeComponent.append(generatesTreeCode(subProcess,node,part,typeGen));
}
break;
default :
}
subProcess.markNode(node,part);
}
return codeComponent;
}