Program: 5907
Project: 5907
Buggy source:
public void runPipeline(PipelinePhase pipelinePhase,String sourcePluginType,JavaSparkExecutionContext sec,Map<String,Integer> stagePartitions) throws Exception {
  MacroEvaluator macroEvaluator=new DefaultMacroEvaluator(sec.getWorkflowToken(),sec.getRuntimeArguments(),sec.getLogicalStartTime(),sec,sec.getNamespace());
  Map<String,SparkCollection<Object>> stageDataCollections=new HashMap<>();
  if (pipelinePhase.getDag() == null) {
    throw new IllegalStateException("String_Node_Str");
  }
  for (  String stageName : pipelinePhase.getDag().getTopologicalOrder()) {
    StageInfo stageInfo=pipelinePhase.getStage(stageName);
    String pluginType=stageInfo.getPluginType();
    SparkCollection<Object> stageData=null;
    Map<String,SparkCollection<Object>> inputDataCollections=new HashMap<>();
    for (    String inputStageName : stageInfo.getInputs()) {
      inputDataCollections.put(inputStageName,stageDataCollections.get(inputStageName));
    }
    if (!inputDataCollections.isEmpty()) {
      Iterator<SparkCollection<Object>> inputCollectionIter=inputDataCollections.values().iterator();
      stageData=inputCollectionIter.next();
      while (!BatchJoiner.PLUGIN_TYPE.equals(pluginType) && inputCollectionIter.hasNext()) {
        stageData=stageData.union(inputCollectionIter.next());
      }
    }
    PluginFunctionContext pluginFunctionContext=new PluginFunctionContext(stageName,sec,pipelinePhase);
    if (stageData == null) {
      if (sourcePluginType.equals(pluginType)) {
        stageData=getSource(stageName,pluginFunctionContext);
      }
 else {
        throw new IllegalStateException(String.format("String_Node_Str",stageName));
      }
    }
 else     if (BatchSink.PLUGIN_TYPE.equals(pluginType)) {
      stageData.store(stageName,new BatchSinkFunction(pluginFunctionContext));
    }
 else     if (Transform.PLUGIN_TYPE.equals(pluginType)) {
      stageData=stageData.flatMap(new TransformFunction(pluginFunctionContext));
    }
 else     if (SparkCompute.PLUGIN_TYPE.equals(pluginType)) {
      SparkCompute<Object,Object> sparkCompute=sec.getPluginContext().newPluginInstance(stageName,macroEvaluator);
      stageData=stageData.compute(stageName,sparkCompute);
    }
 else     if (SparkSink.PLUGIN_TYPE.equals(pluginType)) {
      SparkSink<Object> sparkSink=sec.getPluginContext().newPluginInstance(stageName,macroEvaluator);
      stageData.store(stageName,sparkSink);
    }
 else     if (BatchAggregator.PLUGIN_TYPE.equals(pluginType)) {
      PairFlatMapFunction<Object,Object,Object> groupByFunction=new AggregatorGroupByFunction(pluginFunctionContext);
      FlatMapFunction<Tuple2<Object,Iterable<Object>>,Object> aggregateFunction=new AggregatorAggregateFunction(pluginFunctionContext);
      Integer partitions=stagePartitions.get(stageName);
      SparkPairCollection<Object,Object> keyedCollection=stageData.flatMapToPair(groupByFunction);
      SparkPairCollection<Object,Iterable<Object>> groupedCollection=partitions == null ? keyedCollection.groupByKey() : keyedCollection.groupByKey(partitions);
      stageData=groupedCollection.flatMap(aggregateFunction);
    }
 else     if (BatchJoiner.PLUGIN_TYPE.equals(pluginType)) {
      BatchJoiner<Object,Object,Object> joiner=sec.getPluginContext().newPluginInstance(stageName,macroEvaluator);
      BatchJoinerRuntimeContext joinerRuntimeContext=pluginFunctionContext.createJoinerRuntimeContext();
      joiner.initialize(joinerRuntimeContext);
      Map<String,SparkPairCollection<Object,Object>> preJoinStreams=new HashMap<>();
      for (      Map.Entry<String,SparkCollection<Object>> inputStreamEntry : inputDataCollections.entrySet()) {
        String inputStage=inputStreamEntry.getKey();
        SparkCollection<Object> inputStream=inputStreamEntry.getValue();
        preJoinStreams.put(inputStage,inputStream.flatMapToPair(new JoinOnFunction(pluginFunctionContext,inputStage)));
      }
      Set<String> remainingInputs=new HashSet<>();
      remainingInputs.addAll(inputDataCollections.keySet());
      Integer numPartitions=stagePartitions.get(stageName);
      SparkPairCollection<Object,List<JoinElement<Object>>> joinedInputs=null;
      for (      final String inputStageName : joiner.getJoinConfig().getRequiredInputs()) {
        SparkPairCollection<Object,Object> preJoinCollection=preJoinStreams.get(inputStageName);
        if (joinedInputs == null) {
          joinedInputs=preJoinCollection.mapValues(new InitialJoinFunction(inputStageName));
        }
 else {
          JoinFlattenFunction joinFlattenFunction=new JoinFlattenFunction(inputStageName);
          joinedInputs=numPartitions == null ? joinedInputs.join(preJoinCollection).mapValues(joinFlattenFunction) : joinedInputs.join(preJoinCollection,numPartitions).mapValues(joinFlattenFunction);
        }
        remainingInputs.remove(inputStageName);
      }
      boolean isFullOuter=joinedInputs == null;
      for (      final String inputStageName : remainingInputs) {
        SparkPairCollection<Object,Object> preJoinStream=preJoinStreams.get(inputStageName);
        if (joinedInputs == null) {
          joinedInputs=preJoinStream.mapValues(new InitialJoinFunction(inputStageName));
        }
 else {
          if (isFullOuter) {
            OuterJoinFlattenFunction outerJoinFlattenFunction=new OuterJoinFlattenFunction(inputStageName);
            joinedInputs=numPartitions == null ? joinedInputs.fullOuterJoin(preJoinStream).mapValues(outerJoinFlattenFunction) : joinedInputs.fullOuterJoin(preJoinStream,numPartitions).mapValues(outerJoinFlattenFunction);
          }
 else {
            LeftJoinFlattenFunction joinFlattenFunction=new LeftJoinFlattenFunction(inputStageName);
            joinedInputs=numPartitions == null ? joinedInputs.leftOuterJoin(preJoinStream).mapValues(joinFlattenFunction) : joinedInputs.leftOuterJoin(preJoinStream,numPartitions).mapValues(joinFlattenFunction);
          }
        }
      }
      if (joinedInputs == null) {
        throw new IllegalStateException("String_Node_Str" + stageName);
      }
      stageData=joinedInputs.flatMap(new JoinMergeFunction(pluginFunctionContext)).cache();
    }
 else     if (Windower.PLUGIN_TYPE.equals(pluginType)) {
      Windower windower=sec.getPluginContext().newPluginInstance(stageName,macroEvaluator);
      stageData=stageData.window(windower);
    }
 else {
      throw new IllegalStateException(String.format("String_Node_Str",stageName,pluginType));
    }
    if (shouldCache(pipelinePhase,stageInfo)) {
      stageData=stageData.cache();
    }
    stageDataCollections.put(stageName,stageData);
  }
}

Fixed version (ground truth):
public void runPipeline(PipelinePhase pipelinePhase,String sourcePluginType,JavaSparkExecutionContext sec,Map<String,Integer> stagePartitions) throws Exception {
  MacroEvaluator macroEvaluator=new DefaultMacroEvaluator(sec.getWorkflowToken(),sec.getRuntimeArguments(),sec.getLogicalStartTime(),sec,sec.getNamespace());
  Map<String,SparkCollection<Object>> stageDataCollections=new HashMap<>();
  if (pipelinePhase.getDag() == null) {
    throw new IllegalStateException("String_Node_Str");
  }
  for (  String stageName : pipelinePhase.getDag().getTopologicalOrder()) {
    StageInfo stageInfo=pipelinePhase.getStage(stageName);
    String pluginType=stageInfo.getPluginType();
    SparkCollection<Object> stageData=null;
    Map<String,SparkCollection<Object>> inputDataCollections=new HashMap<>();
    for (    String inputStageName : stageInfo.getInputs()) {
      inputDataCollections.put(inputStageName,stageDataCollections.get(inputStageName));
    }
    if (!inputDataCollections.isEmpty()) {
      Iterator<SparkCollection<Object>> inputCollectionIter=inputDataCollections.values().iterator();
      stageData=inputCollectionIter.next();
      while (!BatchJoiner.PLUGIN_TYPE.equals(pluginType) && inputCollectionIter.hasNext()) {
        stageData=stageData.union(inputCollectionIter.next());
      }
    }
    PluginFunctionContext pluginFunctionContext=new PluginFunctionContext(stageName,sec,pipelinePhase);
    if (stageData == null) {
      if (sourcePluginType.equals(pluginType)) {
        stageData=getSource(stageName,pluginFunctionContext);
      }
 else {
        throw new IllegalStateException(String.format("String_Node_Str",stageName));
      }
    }
 else     if (BatchSink.PLUGIN_TYPE.equals(pluginType)) {
      stageData.store(stageName,new BatchSinkFunction(pluginFunctionContext));
    }
 else     if (Transform.PLUGIN_TYPE.equals(pluginType)) {
      stageData=stageData.flatMap(new TransformFunction(pluginFunctionContext));
    }
 else     if (SparkCompute.PLUGIN_TYPE.equals(pluginType)) {
      SparkCompute<Object,Object> sparkCompute=sec.getPluginContext().newPluginInstance(stageName,macroEvaluator);
      stageData=stageData.compute(stageName,sparkCompute);
    }
 else     if (SparkSink.PLUGIN_TYPE.equals(pluginType)) {
      SparkSink<Object> sparkSink=sec.getPluginContext().newPluginInstance(stageName,macroEvaluator);
      stageData.store(stageName,sparkSink);
    }
 else     if (BatchAggregator.PLUGIN_TYPE.equals(pluginType)) {
      PairFlatMapFunction<Object,Object,Object> groupByFunction=new AggregatorGroupByFunction(pluginFunctionContext);
      FlatMapFunction<Tuple2<Object,Iterable<Object>>,Object> aggregateFunction=new AggregatorAggregateFunction(pluginFunctionContext);
      Integer partitions=stagePartitions.get(stageName);
      SparkPairCollection<Object,Object> keyedCollection=stageData.flatMapToPair(groupByFunction);
      SparkPairCollection<Object,Iterable<Object>> groupedCollection=partitions == null ? keyedCollection.groupByKey() : keyedCollection.groupByKey(partitions);
      stageData=groupedCollection.flatMap(aggregateFunction);
    }
 else     if (BatchJoiner.PLUGIN_TYPE.equals(pluginType)) {
      BatchJoiner<Object,Object,Object> joiner=sec.getPluginContext().newPluginInstance(stageName,macroEvaluator);
      BatchJoinerRuntimeContext joinerRuntimeContext=pluginFunctionContext.createJoinerRuntimeContext();
      joiner.initialize(joinerRuntimeContext);
      Map<String,SparkPairCollection<Object,Object>> preJoinStreams=new HashMap<>();
      for (      Map.Entry<String,SparkCollection<Object>> inputStreamEntry : inputDataCollections.entrySet()) {
        String inputStage=inputStreamEntry.getKey();
        SparkCollection<Object> inputStream=inputStreamEntry.getValue();
        preJoinStreams.put(inputStage,inputStream.flatMapToPair(new JoinOnFunction(pluginFunctionContext,inputStage)));
      }
      Set<String> remainingInputs=new HashSet<>();
      remainingInputs.addAll(inputDataCollections.keySet());
      Integer numPartitions=stagePartitions.get(stageName);
      SparkPairCollection<Object,List<JoinElement<Object>>> joinedInputs=null;
      for (      final String inputStageName : joiner.getJoinConfig().getRequiredInputs()) {
        SparkPairCollection<Object,Object> preJoinCollection=preJoinStreams.get(inputStageName);
        if (joinedInputs == null) {
          joinedInputs=preJoinCollection.mapValues(new InitialJoinFunction(inputStageName));
        }
 else {
          JoinFlattenFunction joinFlattenFunction=new JoinFlattenFunction(inputStageName);
          joinedInputs=numPartitions == null ? joinedInputs.join(preJoinCollection).mapValues(joinFlattenFunction) : joinedInputs.join(preJoinCollection,numPartitions).mapValues(joinFlattenFunction);
        }
        remainingInputs.remove(inputStageName);
      }
      boolean isFullOuter=joinedInputs == null;
      for (      final String inputStageName : remainingInputs) {
        SparkPairCollection<Object,Object> preJoinStream=preJoinStreams.get(inputStageName);
        if (joinedInputs == null) {
          joinedInputs=preJoinStream.mapValues(new InitialJoinFunction(inputStageName));
        }
 else {
          if (isFullOuter) {
            OuterJoinFlattenFunction outerJoinFlattenFunction=new OuterJoinFlattenFunction(inputStageName);
            joinedInputs=numPartitions == null ? joinedInputs.fullOuterJoin(preJoinStream).mapValues(outerJoinFlattenFunction) : joinedInputs.fullOuterJoin(preJoinStream,numPartitions).mapValues(outerJoinFlattenFunction);
          }
 else {
            LeftJoinFlattenFunction joinFlattenFunction=new LeftJoinFlattenFunction(inputStageName);
            joinedInputs=numPartitions == null ? joinedInputs.leftOuterJoin(preJoinStream).mapValues(joinFlattenFunction) : joinedInputs.leftOuterJoin(preJoinStream,numPartitions).mapValues(joinFlattenFunction);
          }
        }
      }
      if (joinedInputs == null) {
        throw new IllegalStateException("String_Node_Str" + stageName);
      }
      stageData=joinedInputs.flatMap(new JoinMergeFunction(pluginFunctionContext)).cache();
    }
 else     if (Windower.PLUGIN_TYPE.equals(pluginType)) {
      Windower windower=sec.getPluginContext().newPluginInstance(stageName,macroEvaluator);
      stageData=stageData.window(stageName,windower);
    }
 else {
      throw new IllegalStateException(String.format("String_Node_Str",stageName,pluginType));
    }
    if (shouldCache(pipelinePhase,stageInfo)) {
      stageData=stageData.cache();
    }
    stageDataCollections.put(stageName,stageData);
  }
}