Program: 63296
Project: 63296
Buggy source:
public List<CubeSegment> allocateSegments(CubeInstance cubeInstance,CubeBuildTypeEnum buildType,long startDate,long endDate) throws IOException, CubeIntegrityException {
  if (cubeInstance.getBuildingSegments().size() > 0) {
    throw new RuntimeException("String_Node_Str");
  }
  List<CubeSegment> segments=new ArrayList<CubeSegment>();
  if (null != cubeInstance.getDescriptor().getCubePartitionDesc().getPartitionDateColumn()) {
    if (cubeInstance.incrementalBuildOnHll()) {
      long[] dateRange=cubeInstance.getDateRange();
      segments.add(buildSegment(cubeInstance,dateRange[0],endDate));
    }
 else {
      if (startDate == 0 && cubeInstance.getSegments().size() == 0) {
        startDate=cubeInstance.getDescriptor().getCubePartitionDesc().getPartitionDateStart();
      }
      CubeSegment lastSegment=null;
      for (      CubeSegment segment : cubeInstance.getSegments()) {
        if (segment.getDateRangeStart() == startDate) {
          segments.add(buildSegment(cubeInstance,startDate,endDate));
        }
        if (segment.getDateRangeStart() < startDate && startDate < segment.getDateRangeEnd()) {
          segments.add(buildSegment(cubeInstance,segment.getDateRangeStart(),startDate));
          segments.add(buildSegment(cubeInstance,startDate,endDate));
        }
        lastSegment=segment;
      }
      if (null == lastSegment || (lastSegment.getDateRangeEnd() == startDate)) {
        segments.add(buildSegment(cubeInstance,startDate,endDate));
      }
    }
  }
 else {
    segments.add(buildSegment(cubeInstance,0,0));
  }
  validateNewSegments(cubeInstance,buildType,segments);
  if (buildType == CubeBuildTypeEnum.MERGE || cubeInstance.incrementalBuildOnHll()) {
    this.makeDictForNewSegment(cubeInstance,segments.get(0));
    this.makeSnapshotForNewSegment(cubeInstance,segments.get(0));
  }
  cubeInstance.getSegments().addAll(segments);
  Collections.sort(cubeInstance.getSegments());
  this.updateCube(cubeInstance);
  return segments;
}

Fixed version (ground truth):
public List<CubeSegment> allocateSegments(CubeInstance cubeInstance,CubeBuildTypeEnum buildType,long startDate,long endDate) throws IOException, CubeIntegrityException {
  if (cubeInstance.getBuildingSegments().size() > 0) {
    throw new RuntimeException("String_Node_Str");
  }
  List<CubeSegment> segments=new ArrayList<CubeSegment>();
  boolean needMergeImmediately=cubeInstance.needMergeImmediately(startDate,endDate);
  if (null != cubeInstance.getDescriptor().getCubePartitionDesc().getPartitionDateColumn()) {
    if (needMergeImmediately) {
      segments.add(buildSegment(cubeInstance,startDate,endDate));
    }
 else {
      if (startDate == 0 && cubeInstance.getSegments().size() == 0) {
        startDate=cubeInstance.getDescriptor().getCubePartitionDesc().getPartitionDateStart();
      }
      CubeSegment lastSegment=null;
      for (      CubeSegment segment : cubeInstance.getSegments()) {
        if (segment.getDateRangeStart() == startDate) {
          segments.add(buildSegment(cubeInstance,startDate,endDate));
        }
        if (segment.getDateRangeStart() < startDate && startDate < segment.getDateRangeEnd()) {
          segments.add(buildSegment(cubeInstance,segment.getDateRangeStart(),startDate));
          segments.add(buildSegment(cubeInstance,startDate,endDate));
        }
        lastSegment=segment;
      }
      if (null == lastSegment || (lastSegment.getDateRangeEnd() == startDate)) {
        segments.add(buildSegment(cubeInstance,startDate,endDate));
      }
    }
  }
 else {
    segments.add(buildSegment(cubeInstance,0,0));
  }
  validateNewSegments(cubeInstance,buildType,segments);
  if (buildType == CubeBuildTypeEnum.MERGE || needMergeImmediately) {
    this.makeDictForNewSegment(cubeInstance,segments.get(0));
    this.makeSnapshotForNewSegment(cubeInstance,segments.get(0));
  }
  cubeInstance.getSegments().addAll(segments);
  Collections.sort(cubeInstance.getSegments());
  this.updateCube(cubeInstance);
  return segments;
}