Program: 17759
Project: 17759
Buggy source:
public Enumerator createEnumerator() throws IOException {
  PlatformBroker platformBroker=getPlatformBroker();
  Branch branch=getBranch();
  Properties properties=platformBroker.getProperties();
  for (  Ref head : branch.heads.keySet()) {
    if (head.tuples != null)     writeValuesTuple(platformBroker,head);
  }
  LingualFlowFactory flowFactory=platformBroker.getFlowFactory(branch);
  Optiq.writeSQLPlan(properties,flowFactory.getName(),getVolcanoPlanner());
  for (  Ref head : branch.heads.keySet()) {
    TableDef tableDefFor=getTableDefFor(platformBroker,head);
    String[] jarPath=getJarPaths(tableDefFor);
    flowFactory.addSource(head.name,tableDefFor,jarPath);
  }
  FlowListener flowListener=null;
  if (branch.tailTableDef != null) {
    TableDef tableDef=branch.tailTableDef;
    String[] jarPath=getJarPaths(tableDef);
    flowFactory.addSink(tableDef.getName(),tableDef,jarPath);
  }
 else {
    Resource<Protocol,Format,SinkMode> resource=createResultResource(platformBroker,flowFactory);
    flowFactory.addSink(branch.current.getName(),resource);
    if (platformBroker.hasResultSchemaDef())     flowListener=new AddResultTableListener(platformBroker,flowFactory.getLingualConnection());
  }
  String flowPlanPath=setFlowPlanPath(properties,flowFactory.getName());
  ClassLoader jarLoader=getJarClassLoader(platformBroker,flowFactory);
  Flow flow;
  try {
    flow=flowFactory.create();
  }
 catch (  PlannerException exception) {
    LOG.error("String_Node_Str",exception);
    if (flowPlanPath != null) {
      LOG.info("String_Node_Str",flowPlanPath);
      exception.writeDOT(flowPlanPath);
    }
    throw exception;
  }
  if (flowPlanPath != null) {
    LOG.info("String_Node_Str",flowPlanPath);
    flow.writeDOT(flowPlanPath);
  }
  if (flowListener != null)   flow.addListener(flowListener);
  try {
    LOG.debug("String_Node_Str",flow.getName());
    if (jarLoader != null)     Thread.currentThread().setContextClassLoader(jarLoader);
    flow.complete();
    LOG.debug("String_Node_Str",flow.getName());
  }
 catch (  Exception exception) {
    LOG.error("String_Node_Str",exception);
    Throwable rootCause=Throwables.getRootCause(exception);
    if (rootCause != null && exception != rootCause)     LOG.error("String_Node_Str",rootCause);
    throw new RuntimeException("String_Node_Str",exception);
  }
 finally {
    if (jarLoader != null)     Thread.currentThread().setContextClassLoader(jarLoader.getParent());
  }
  LOG.debug("String_Node_Str",flow.getSink().getSinkFields().printVerbose());
  if (branch.isModification) {
    FlowStep flowStep=(FlowStep)flow.getFlowSteps().get(flow.getFlowSteps().size() - 1);
    long rowCount=flowStep.getFlowStepStats().getCounterValue(StepCounters.Tuples_Written);
    return new Linq4j().singletonEnumerable(rowCount).enumerator();
  }
  int size=flow.getSink().getSinkFields().size();
  Type[] types=new Type[size];
  for (int i=0; i < size; i++)   types[i]=flowHolder.physType.fieldClass(i);
  int maxRows=getMaxRows(properties);
  if (size == 1)   return new TapObjectEnumerator(maxRows,types,flow.getFlowProcess(),flow.getSink());
 else   return new TapArrayEnumerator(maxRows,types,flow.getFlowProcess(),flow.getSink());
}

Fixed version (ground truth):
public Enumerator createEnumerator() throws IOException {
  PlatformBroker platformBroker=getPlatformBroker();
  Branch branch=getBranch();
  Properties properties=platformBroker.getProperties();
  for (  Ref head : branch.heads.keySet()) {
    if (head.tuples != null)     writeValuesTuple(platformBroker,head);
  }
  LingualFlowFactory flowFactory=platformBroker.getFlowFactory(branch);
  Optiq.writeSQLPlan(properties,flowFactory.getName(),getVolcanoPlanner());
  for (  Ref head : branch.heads.keySet()) {
    TableDef tableDefFor=getTableDefFor(platformBroker,head);
    String[] jarPath=getJarPaths(tableDefFor);
    flowFactory.addSource(head.name,tableDefFor,jarPath);
  }
  FlowListener flowListener=null;
  if (branch.tailTableDef != null) {
    TableDef tableDef=branch.tailTableDef;
    String[] jarPath=getJarPaths(tableDef);
    flowFactory.addSink(tableDef.getName(),tableDef,jarPath);
  }
 else {
    Resource<Protocol,Format,SinkMode> resource=createResultResource(platformBroker,flowFactory);
    flowFactory.addSink(branch.current.getName(),resource);
    if (platformBroker.hasResultSchemaDef())     flowListener=new AddResultTableListener(platformBroker,flowFactory.getLingualConnection());
  }
  String flowPlanPath=setFlowPlanPath(properties,flowFactory.getName());
  ClassLoader jarLoader=getJarClassLoader(platformBroker,flowFactory);
  if (jarLoader != null)   Thread.currentThread().setContextClassLoader(jarLoader);
  Flow flow;
  try {
    flow=flowFactory.create();
  }
 catch (  PlannerException exception) {
    LOG.error("String_Node_Str",exception);
    if (flowPlanPath != null) {
      LOG.info("String_Node_Str",flowPlanPath);
      exception.writeDOT(flowPlanPath);
    }
    throw exception;
  }
  if (flowPlanPath != null) {
    LOG.info("String_Node_Str",flowPlanPath);
    flow.writeDOT(flowPlanPath);
  }
  if (flowListener != null)   flow.addListener(flowListener);
  try {
    LOG.debug("String_Node_Str",flow.getName());
    flow.complete();
    LOG.debug("String_Node_Str",flow.getName());
  }
 catch (  Exception exception) {
    LOG.error("String_Node_Str",exception);
    Throwable rootCause=Throwables.getRootCause(exception);
    if (rootCause != null && exception != rootCause)     LOG.error("String_Node_Str",rootCause);
    throw new RuntimeException("String_Node_Str",exception);
  }
 finally {
    if (jarLoader != null)     Thread.currentThread().setContextClassLoader(jarLoader.getParent());
  }
  LOG.debug("String_Node_Str",flow.getSink().getSinkFields().printVerbose());
  if (branch.isModification) {
    FlowStep flowStep=(FlowStep)flow.getFlowSteps().get(flow.getFlowSteps().size() - 1);
    long rowCount=flowStep.getFlowStepStats().getCounterValue(StepCounters.Tuples_Written);
    return new Linq4j().singletonEnumerable(rowCount).enumerator();
  }
  int size=flow.getSink().getSinkFields().size();
  Type[] types=new Type[size];
  for (int i=0; i < size; i++)   types[i]=flowHolder.physType.fieldClass(i);
  int maxRows=getMaxRows(properties);
  if (size == 1)   return new TapObjectEnumerator(maxRows,types,flow.getFlowProcess(),flow.getSink());
 else   return new TapArrayEnumerator(maxRows,types,flow.getFlowProcess(),flow.getSink());
}