Program: 63281
Project: 63281
Buggy source:
public void updateSegmentOnJobSucceed(CubeInstance cubeInstance,CubeBuildTypeEnum buildType,String segmentName,String jobUuid,long lastBuildTime,long sizeKB,long sourceRecordCount,long sourceRecordsSize) throws IOException, CubeIntegrityException {
  List<CubeSegment> segmentsInNewStatus=cubeInstance.getSegments(CubeSegmentStatusEnum.NEW);
  CubeSegment cubeSegment=cubeInstance.getSegmentById(jobUuid);
  if (cubeSegment == null) {
    cubeSegment=cubeInstance.getSegment(segmentName,CubeSegmentStatusEnum.NEW);
  }
  Preconditions.checkNotNull(cubeSegment);
  Preconditions.checkArgument(cubeSegment.getStatus() == CubeSegmentStatusEnum.NEW,"String_Node_Str" + cubeSegment);
switch (buildType) {
case BUILD:
    if (cubeInstance.needMergeImmediately(cubeSegment)) {
      cubeInstance.getSegments().removeAll(cubeInstance.getSegment(CubeSegmentStatusEnum.READY));
    }
 else {
      if (segmentsInNewStatus.size() == 1) {
        cubeInstance.getSegments().removeAll(cubeInstance.getRebuildingSegments());
      }
    }
  break;
case MERGE:
cubeInstance.getSegments().removeAll(cubeInstance.getMergingSegments());
break;
}
cubeSegment.setLastBuildJobID(jobUuid);
cubeSegment.setLastBuildTime(lastBuildTime);
cubeSegment.setSizeKB(sizeKB);
cubeSegment.setSourceRecords(sourceRecordCount);
cubeSegment.setSourceRecordsSize(sourceRecordsSize);
if (segmentsInNewStatus.size() == 1) {
cubeSegment.setStatus(CubeSegmentStatusEnum.READY);
cubeInstance.setStatus(CubeStatusEnum.READY);
for (CubeSegment seg : cubeInstance.getSegments(CubeSegmentStatusEnum.READY_PENDING)) {
seg.setStatus(CubeSegmentStatusEnum.READY);
}
}
 else {
cubeSegment.setStatus(CubeSegmentStatusEnum.READY_PENDING);
}
this.updateCube(cubeInstance);
}

Fixed version (ground truth):
public void updateSegmentOnJobSucceed(CubeInstance cubeInstance,CubeBuildTypeEnum buildType,String segmentName,String lastBuildJobUuid,long lastBuildTime,long sizeKB,long sourceRecordCount,long sourceRecordsSize) throws IOException, CubeIntegrityException {
  List<CubeSegment> segmentsInNewStatus=cubeInstance.getSegments(CubeSegmentStatusEnum.NEW);
  CubeSegment cubeSegment=cubeInstance.getSegment(segmentName,CubeSegmentStatusEnum.NEW);
switch (buildType) {
case BUILD:
    if (cubeInstance.incrementalBuildOnHll()) {
      cubeInstance.getSegments().removeAll(cubeInstance.getMergingSegments());
    }
 else {
      if (segmentsInNewStatus.size() == 1) {
        cubeInstance.getSegments().removeAll(cubeInstance.getRebuildingSegments());
      }
    }
  break;
case MERGE:
cubeInstance.getSegments().removeAll(cubeInstance.getMergingSegments());
break;
}
cubeSegment.setLastBuildJobID(lastBuildJobUuid);
cubeSegment.setLastBuildTime(lastBuildTime);
cubeSegment.setSizeKB(sizeKB);
cubeSegment.setSourceRecords(sourceRecordCount);
cubeSegment.setSourceRecordsSize(sourceRecordsSize);
if (segmentsInNewStatus.size() == 1) {
cubeSegment.setStatus(CubeSegmentStatusEnum.READY);
cubeInstance.setStatus(CubeStatusEnum.READY);
for (CubeSegment seg : cubeInstance.getSegments(CubeSegmentStatusEnum.READY_PENDING)) {
seg.setStatus(CubeSegmentStatusEnum.READY);
}
}
 else {
cubeSegment.setStatus(CubeSegmentStatusEnum.READY_PENDING);
}
this.updateCube(cubeInstance);
}