Program: 14423
Project: 14423
Buggy source:
@Override public boolean apply(final ReportingInstanceUsageEvent event){
  final InstanceMetricDimensionKey key=new InstanceMetricDimensionKey(event.getUuid(),event.getMetric(),event.getDimension());
  final long eventMs=event.getTimestampMs();
  if (event.getValue() == null)   return true;
  final InstanceUsageArtEntity usageEntity=usageEntities.get(event.getUuid());
  if (usageEntity == null)   return true;
  if (!prevDataMap.containsKey(key)) {
    if (instanceStartTimes.containsKey(event.getUuid())) {
      Double fractionalVal=fractionalUsage(report.getBeginMs(),report.getEndMs(),instanceStartTimes.get(event.getUuid()),eventMs,event.getValue());
      addMetricValueToUsageEntity(usageEntity,event.getMetric(),event.getDimension(),fractionalVal);
      log.debug(String.format("String_Node_Str",instanceStartTimes.get(event.getUuid()),eventMs,report.getBeginMs(),report.getEndMs(),event.getUuid(),event.getMetric(),event.getDimension(),event.getValue(),fractionalVal));
    }
    prevDataMap.put(key,new MetricPrevData(eventMs,eventMs,event.getValue(),event.getSequenceNum()));
  }
 else {
    final MetricPrevData prevData=prevDataMap.get(key);
    usageEntity.setDurationMs(Math.max(usageEntity.getDurationMs(),overlap(report.getBeginMs(),report.getEndMs(),prevData.firstMs,eventMs)));
    if (event.getSequenceNum() < prevData.lastSeq) {
      Double fractionalVal=fractionalUsage(report.getBeginMs(),report.getEndMs(),prevData.lastMs,eventMs,event.getValue());
      addMetricValueToUsageEntity(usageEntity,event.getMetric(),event.getDimension(),fractionalVal);
      log.debug(String.format("String_Node_Str",prevData.lastMs,eventMs,report.getBeginMs(),report.getEndMs(),event.getUuid(),event.getMetric(),event.getDimension(),event.getValue(),fractionalVal));
    }
 else {
      Double fractionalVal=fractionalUsage(report.getBeginMs(),report.getEndMs(),prevData.lastMs,eventMs,event.getValue() - prevData.lastVal);
      addMetricValueToUsageEntity(usageEntity,event.getMetric(),event.getDimension(),fractionalVal);
      log.debug(String.format("String_Node_Str",prevData.lastMs,eventMs,report.getBeginMs(),report.getEndMs(),event.getUuid(),event.getMetric(),event.getDimension(),event.getValue(),prevData.lastVal,fractionalVal));
    }
    prevDataMap.put(key,new MetricPrevData(prevData.firstMs,eventMs,event.getValue(),event.getSequenceNum()));
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(final ReportingInstanceUsageEvent event){
  final InstanceMetricDimensionKey key=new InstanceMetricDimensionKey(event.getUuid(),event.getMetric(),event.getDimension());
  final long eventMs=event.getTimestampMs();
  if (event.getValue() == null)   return true;
  if (!usageEntities.containsKey(event.getUuid())) {
    usageEntities.put(event.getUuid(),new InstanceUsageArtEntity());
  }
  final InstanceUsageArtEntity usageEntity=usageEntities.get(event.getUuid());
  final ReportingInstanceCreateEvent createEvent=createEvents.get(event.getUuid());
  if (createEvent == null) {
    log.error("String_Node_Str" + event.getUuid());
    return true;
  }
  if (eventMs >= report.getBeginMs() || eventMs <= report.getEndMs()) {
    addParentNodes(report,createEvent,usageEntity);
  }
  if (!prevDataMap.containsKey(key)) {
    Double fractionalVal=fractionalUsage(report.getBeginMs(),report.getEndMs(),createEvent.getTimestampMs(),eventMs,event.getValue());
    addMetricValueToUsageEntity(usageEntity,event.getMetric(),event.getDimension(),fractionalVal);
    log.debug(String.format("String_Node_Str",createEvent.getTimestampMs(),eventMs,report.getBeginMs(),report.getEndMs(),event.getUuid(),event.getMetric(),event.getDimension(),event.getValue(),fractionalVal));
    prevDataMap.put(key,new MetricPrevData(eventMs,eventMs,event.getValue(),event.getSequenceNum()));
  }
 else {
    final MetricPrevData prevData=prevDataMap.get(key);
    usageEntity.setDurationMs(Math.max(usageEntity.getDurationMs(),overlap(report.getBeginMs(),report.getEndMs(),prevData.firstMs,eventMs)));
    if (event.getSequenceNum() < prevData.lastSeq) {
      Double fractionalVal=fractionalUsage(report.getBeginMs(),report.getEndMs(),prevData.lastMs,eventMs,event.getValue());
      addMetricValueToUsageEntity(usageEntity,event.getMetric(),event.getDimension(),fractionalVal);
      log.debug(String.format("String_Node_Str",prevData.lastMs,eventMs,report.getBeginMs(),report.getEndMs(),event.getUuid(),event.getMetric(),event.getDimension(),event.getValue(),fractionalVal));
    }
 else {
      Double fractionalVal=fractionalUsage(report.getBeginMs(),report.getEndMs(),prevData.lastMs,eventMs,event.getValue() - prevData.lastVal);
      addMetricValueToUsageEntity(usageEntity,event.getMetric(),event.getDimension(),fractionalVal);
      log.debug(String.format("String_Node_Str",prevData.lastMs,eventMs,report.getBeginMs(),report.getEndMs(),event.getUuid(),event.getMetric(),event.getDimension(),event.getValue(),prevData.lastVal,fractionalVal));
    }
    prevDataMap.put(key,new MetricPrevData(prevData.firstMs,eventMs,event.getValue(),event.getSequenceNum()));
  }
  return true;
}