Program: 63175
Project: 63175
Buggy source:
@Override protected ExecuteResult doWork(ExecutableContext context) throws ExecuteException {
  final CubeInstance cube=cubeManager.getCube(getCubeName());
  List<String> mergingSegmentIds=getMergingSegmentIds();
  if (mergingSegmentIds.isEmpty()) {
    return new ExecuteResult(ExecuteResult.State.FAILED,"String_Node_Str");
  }
  CubeSegment mergedSegment=cube.getSegmentById(getSegmentId());
  if (mergedSegment == null) {
    return new ExecuteResult(ExecuteResult.State.FAILED,"String_Node_Str" + getSegmentId());
  }
  String cubeSizeString=jobService.getOutput(getConvertToHfileStepId()).getExtra().get(ExecutableConstants.HDFS_BYTES_WRITTEN);
  Preconditions.checkState(StringUtils.isNotEmpty(cubeSizeString),"String_Node_Str");
  long cubeSize=Long.parseLong(cubeSizeString) / 1024;
  List<CubeSegment> toBeRemoved=Lists.newArrayListWithExpectedSize(mergingSegmentIds.size());
  for (  CubeSegment segment : cube.getSegments()) {
    if (mergingSegmentIds.contains(segment.getUuid())) {
      toBeRemoved.add(segment);
    }
  }
  long sourceCount=0L;
  long sourceSize=0L;
  for (  CubeSegment segment : toBeRemoved) {
    sourceCount+=segment.getSourceRecords();
    sourceSize+=segment.getSourceRecordsSize();
  }
  mergedSegment.setSizeKB(cubeSize);
  mergedSegment.setSourceRecords(sourceCount);
  mergedSegment.setSourceRecordsSize(sourceSize);
  cube.getSegments().removeAll(toBeRemoved);
  try {
    cubeManager.updateCube(cube);
    return new ExecuteResult(ExecuteResult.State.SUCCEED);
  }
 catch (  IOException e) {
    logger.error("String_Node_Str",e);
    return new ExecuteResult(ExecuteResult.State.ERROR,e.getLocalizedMessage());
  }
}

Fixed version (ground truth):
@Override protected ExecuteResult doWork(ExecutableContext context) throws ExecuteException {
  final CubeInstance cube=cubeManager.getCube(getCubeName());
  List<String> mergingSegmentIds=getMergingSegmentIds();
  if (mergingSegmentIds.isEmpty()) {
    return new ExecuteResult(ExecuteResult.State.FAILED,"String_Node_Str");
  }
  CubeSegment mergedSegment=cube.getSegmentById(getSegmentId());
  if (mergedSegment == null) {
    return new ExecuteResult(ExecuteResult.State.FAILED,"String_Node_Str" + getSegmentId());
  }
  String cubeSizeString=jobService.getOutput(getConvertToHfileStepId()).getExtra().get(ExecutableConstants.HDFS_BYTES_WRITTEN);
  Preconditions.checkState(StringUtils.isNotEmpty(cubeSizeString),"String_Node_Str");
  long cubeSize=Long.parseLong(cubeSizeString) / 1024;
  List<CubeSegment> toBeRemoved=Lists.newArrayListWithExpectedSize(mergingSegmentIds.size());
  for (  CubeSegment segment : cube.getSegments()) {
    if (mergingSegmentIds.contains(segment.getUuid())) {
      toBeRemoved.add(segment);
    }
  }
  long sourceCount=0L;
  long sourceSize=0L;
  for (  CubeSegment segment : toBeRemoved) {
    sourceCount+=segment.getSourceRecords();
    sourceSize+=segment.getSourceRecordsSize();
  }
  mergedSegment.setSizeKB(cubeSize);
  mergedSegment.setSourceRecords(sourceCount);
  mergedSegment.setSourceRecordsSize(sourceSize);
  mergedSegment.setLastBuildJobID(getCubingJobId());
  cube.getSegments().removeAll(toBeRemoved);
  try {
    cubeManager.updateCube(cube);
    return new ExecuteResult(ExecuteResult.State.SUCCEED);
  }
 catch (  IOException e) {
    logger.error("String_Node_Str",e);
    return new ExecuteResult(ExecuteResult.State.ERROR,e.getLocalizedMessage());
  }
}