Program: 88107
Project: 88107
Buggy source:
/** 
 * Adds the necessary vertexes for sampling & histogram creation etc for range partitioning
 * @param connection
 * @param outputVertex
 * @param inputVertex
 * @throws JobGraphDefinitionException 
 */
private void connectWithSamplingPartitionRangeStrategy(PactConnection connection,AbstractJobVertex outputVertex,AbstractJobVertex inputVertex) throws JobGraphDefinitionException {
  TaskConfig inputConfig=new TaskConfig(inputVertex.getConfiguration());
  TaskConfig outputConfig=new TaskConfig(outputVertex.getConfiguration());
  int sourceDOP=connection.getSourcePact().getDegreeOfParallelism();
  int sourceIPM=connection.getSourcePact().getInstancesPerMachine();
  int targetDOP=connection.getTargetPact().getDegreeOfParallelism();
  int targetIPM=connection.getTargetPact().getInstancesPerMachine();
  Class<?> sourceStub=connection.getSourcePact().getPactContract().getUserCodeClass();
  if (targetDOP == 1) {
    if (sourceDOP == 1) {
      outputVertex.connectTo(inputVertex,ChannelType.INMEMORY,CompressionLevel.NO_COMPRESSION);
    }
 else {
      outputVertex.connectTo(inputVertex,ChannelType.NETWORK,CompressionLevel.NO_COMPRESSION);
    }
    outputConfig.addOutputShipStrategy(ShipStrategy.FORWARD);
    inputConfig.addInputShipStrategy(ShipStrategy.FORWARD);
    return;
  }
  JobTaskVertex sampleVertex=new JobTaskVertex("String_Node_Str",this.jobGraph);
  auxVertices.add(sampleVertex);
  sampleVertex.setTaskClass(SampleTask.class);
  TaskConfig sampleConfig=new TaskConfig(sampleVertex.getConfiguration());
  sampleVertex.setNumberOfSubtasks(sourceDOP);
  if (sourceIPM >= 1) {
    sampleVertex.setNumberOfSubtasksPerInstance(sourceIPM);
  }
  sampleConfig.setStubClass(sourceStub);
  outputVertex.connectTo(sampleVertex,ChannelType.INMEMORY,CompressionLevel.NO_COMPRESSION);
  outputConfig.addOutputShipStrategy(ShipStrategy.FORWARD);
  sampleConfig.addInputShipStrategy(ShipStrategy.FORWARD);
  JobTaskVertex histogramVertex=new JobTaskVertex("String_Node_Str",this.jobGraph);
  auxVertices.add(histogramVertex);
  histogramVertex.setTaskClass(HistogramTask.class);
  histogramVertex.setNumberOfSubtasks(1);
  TaskConfig histogramConfig=new TaskConfig(histogramVertex.getConfiguration());
  histogramConfig.setStubClass(sourceStub);
  histogramConfig.setLocalStrategy(LocalStrategy.SORT);
  Configuration histogramStubConfig=new Configuration();
  histogramStubConfig.setInteger(HistogramTask.NUMBER_OF_BUCKETS,targetDOP);
  histogramConfig.setStubParameters(histogramStubConfig);
  assignMemory(histogramConfig,outputConfig.getStubParameters().getInteger(HistogramTask.HISTOGRAM_MEMORY,-1));
  histogramConfig.addInputShipStrategy(ShipStrategy.FORWARD);
  sampleConfig.addOutputShipStrategy(ShipStrategy.FORWARD);
  sampleVertex.connectTo(histogramVertex,ChannelType.NETWORK,CompressionLevel.NO_COMPRESSION);
  JobTaskVertex partitionVertex=new JobTaskVertex("String_Node_Str",this.jobGraph);
  auxVertices.add(partitionVertex);
  partitionVertex.setTaskClass(PartitionTask.class);
  partitionVertex.setNumberOfSubtasks(sourceDOP);
  if (sourceIPM >= 1) {
    partitionVertex.setNumberOfSubtasksPerInstance(sourceIPM);
  }
  TaskConfig partitionConfig=new TaskConfig(partitionVertex.getConfiguration());
  partitionConfig.setStubClass(sourceStub);
  Configuration partitionStubConfig=new Configuration();
  partitionStubConfig.setString(PartitionTask.GLOBAL_PARTITIONING_ORDER,connection.getTargetPact().getGlobalProperties().getKeyOrder().name());
  partitionConfig.setStubParameters(partitionStubConfig);
  JobTaskVertex tempVertex=generateTempVertex(connection.getSourcePact().getPactContract().getUserCodeClass(),sourceDOP);
  tempVertex.setVertexToShareInstancesWith(outputVertex);
  TaskConfig tempConfig=new TaskConfig(tempVertex.getConfiguration());
  outputVertex.connectTo(tempVertex,ChannelType.INMEMORY,CompressionLevel.NO_COMPRESSION);
  tempConfig.addInputShipStrategy(ShipStrategy.FORWARD);
  outputConfig.addOutputShipStrategy(ShipStrategy.FORWARD);
  tempVertex.connectTo(partitionVertex,ChannelType.INMEMORY,CompressionLevel.NO_COMPRESSION);
  partitionConfig.addInputShipStrategy(ShipStrategy.FORWARD);
  tempConfig.addOutputShipStrategy(ShipStrategy.FORWARD);
  histogramVertex.connectTo(partitionVertex,ChannelType.NETWORK,CompressionLevel.NO_COMPRESSION);
  partitionConfig.addInputShipStrategy(ShipStrategy.BROADCAST);
  histogramConfig.addOutputShipStrategy(ShipStrategy.BROADCAST);
  partitionVertex.connectTo(inputVertex,ChannelType.NETWORK,CompressionLevel.NO_COMPRESSION);
  inputConfig.addInputShipStrategy(ShipStrategy.PARTITION_RANGE);
  partitionConfig.addOutputShipStrategy(ShipStrategy.PARTITION_RANGE);
}

Fixed version (ground truth):
/** 
 * Adds the necessary vertexes for sampling & histogram creation etc for range partitioning
 * @param connection
 * @param outputVertex
 * @param inputVertex
 * @throws JobGraphDefinitionException 
 */
private void connectWithSamplingPartitionRangeStrategy(PactConnection connection,AbstractJobVertex outputVertex,AbstractJobVertex inputVertex) throws JobGraphDefinitionException {
  TaskConfig inputConfig=new TaskConfig(inputVertex.getConfiguration());
  TaskConfig outputConfig=new TaskConfig(outputVertex.getConfiguration());
  int sourceDOP=connection.getSourcePact().getDegreeOfParallelism();
  int sourceIPM=connection.getSourcePact().getInstancesPerMachine();
  int targetDOP=connection.getTargetPact().getDegreeOfParallelism();
  int targetIPM=connection.getTargetPact().getInstancesPerMachine();
  Class<?> sourceStub=connection.getSourcePact().getPactContract().getUserCodeClass();
  if (targetDOP == 1) {
    if (sourceDOP == 1) {
      outputVertex.connectTo(inputVertex,ChannelType.INMEMORY,CompressionLevel.NO_COMPRESSION);
    }
 else {
      outputVertex.connectTo(inputVertex,ChannelType.NETWORK,CompressionLevel.NO_COMPRESSION);
    }
    outputConfig.addOutputShipStrategy(ShipStrategy.FORWARD);
    inputConfig.addInputShipStrategy(ShipStrategy.FORWARD);
    return;
  }
  JobTaskVertex sampleVertex=new JobTaskVertex("String_Node_Str",this.jobGraph);
  auxVertices.add(sampleVertex);
  sampleVertex.setTaskClass(SampleTask.class);
  TaskConfig sampleConfig=new TaskConfig(sampleVertex.getConfiguration());
  sampleVertex.setNumberOfSubtasks(sourceDOP);
  if (sourceIPM >= 1) {
    sampleVertex.setNumberOfSubtasksPerInstance(sourceIPM);
  }
  sampleConfig.setStubClass(sourceStub);
  outputVertex.connectTo(sampleVertex,ChannelType.INMEMORY,CompressionLevel.NO_COMPRESSION);
  outputConfig.addOutputShipStrategy(ShipStrategy.FORWARD);
  sampleConfig.addInputShipStrategy(ShipStrategy.FORWARD);
  JobTaskVertex histogramVertex=new JobTaskVertex("String_Node_Str",this.jobGraph);
  auxVertices.add(histogramVertex);
  histogramVertex.setTaskClass(HistogramTask.class);
  histogramVertex.setNumberOfSubtasks(1);
  TaskConfig histogramConfig=new TaskConfig(histogramVertex.getConfiguration());
  histogramConfig.setStubClass(sourceStub);
  histogramConfig.setLocalStrategy(LocalStrategy.SORT);
  Configuration histogramStubConfig=new Configuration();
  histogramStubConfig.setInteger(HistogramTask.NUMBER_OF_BUCKETS,targetDOP);
  histogramConfig.setStubParameters(histogramStubConfig);
  assignMemory(histogramConfig,outputConfig.getStubParameters().getInteger(HistogramTask.HISTOGRAM_MEMORY,-1));
  histogramConfig.addInputShipStrategy(ShipStrategy.FORWARD);
  sampleConfig.addOutputShipStrategy(ShipStrategy.FORWARD);
  sampleVertex.connectTo(histogramVertex,ChannelType.NETWORK,CompressionLevel.NO_COMPRESSION);
  JobTaskVertex partitionVertex=new JobTaskVertex("String_Node_Str",this.jobGraph);
  auxVertices.add(partitionVertex);
  partitionVertex.setTaskClass(PartitionTask.class);
  partitionVertex.setNumberOfSubtasks(sourceDOP);
  if (sourceIPM >= 1) {
    partitionVertex.setNumberOfSubtasksPerInstance(sourceIPM);
  }
  TaskConfig partitionConfig=new TaskConfig(partitionVertex.getConfiguration());
  partitionConfig.setStubClass(sourceStub);
  Configuration partitionStubConfig=new Configuration();
  partitionStubConfig.setString(PartitionTask.GLOBAL_PARTITIONING_ORDER,connection.getTargetPact().getGlobalProperties().getKeyOrder().name());
  partitionConfig.setStubParameters(partitionStubConfig);
  JobTaskVertex tempVertex=generateTempVertex(connection.getSourcePact().getPactContract().getUserCodeClass(),sourceDOP,sourceIPM);
  tempVertex.setVertexToShareInstancesWith(outputVertex);
  TaskConfig tempConfig=new TaskConfig(tempVertex.getConfiguration());
  outputVertex.connectTo(tempVertex,ChannelType.INMEMORY,CompressionLevel.NO_COMPRESSION);
  tempConfig.addInputShipStrategy(ShipStrategy.FORWARD);
  outputConfig.addOutputShipStrategy(ShipStrategy.FORWARD);
  tempVertex.connectTo(partitionVertex,ChannelType.INMEMORY,CompressionLevel.NO_COMPRESSION);
  partitionConfig.addInputShipStrategy(ShipStrategy.FORWARD);
  tempConfig.addOutputShipStrategy(ShipStrategy.FORWARD);
  histogramVertex.connectTo(partitionVertex,ChannelType.NETWORK,CompressionLevel.NO_COMPRESSION);
  partitionConfig.addInputShipStrategy(ShipStrategy.BROADCAST);
  histogramConfig.addOutputShipStrategy(ShipStrategy.BROADCAST);
  partitionVertex.connectTo(inputVertex,ChannelType.NETWORK,CompressionLevel.NO_COMPRESSION);
  inputConfig.addInputShipStrategy(ShipStrategy.PARTITION_RANGE);
  partitionConfig.addOutputShipStrategy(ShipStrategy.PARTITION_RANGE);
}