Program: 14434
Project: 14434
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);
    }
    prevDataMap.put(key,new MetricPrevData(eventMs,eventMs,event.getValue()));
  }
 else {
    final MetricPrevData prevData=prevDataMap.get(key);
    usageEntity.setDurationMs(Math.max(usageEntity.getDurationMs(),overlap(report.getBeginMs(),report.getEndMs(),prevData.firstMs,eventMs)));
    if (prevData.lastVal < event.getValue()) {
      Double fractionalVal=fractionalUsage(report.getBeginMs(),report.getEndMs(),prevData.lastMs,eventMs,event.getValue());
      addMetricValueToUsageEntity(usageEntity,event.getMetric(),event.getDimension(),fractionalVal);
    }
 else {
      Double fractionalVal=fractionalUsage(report.getBeginMs(),report.getEndMs(),prevData.lastMs,eventMs,event.getValue() - prevData.lastVal);
      addMetricValueToUsageEntity(usageEntity,event.getMetric(),event.getDimension(),fractionalVal);
    }
    prevDataMap.put(key,new MetricPrevData(prevData.firstMs,eventMs,event.getValue()));
  }
  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;
  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);
    }
    prevDataMap.put(key,new MetricPrevData(eventMs,eventMs,event.getValue()));
  }
 else {
    final MetricPrevData prevData=prevDataMap.get(key);
    usageEntity.setDurationMs(Math.max(usageEntity.getDurationMs(),overlap(report.getBeginMs(),report.getEndMs(),prevData.firstMs,eventMs)));
    if (event.getValue() < prevData.lastVal) {
      Double fractionalVal=fractionalUsage(report.getBeginMs(),report.getEndMs(),prevData.lastMs,eventMs,event.getValue());
      addMetricValueToUsageEntity(usageEntity,event.getMetric(),event.getDimension(),fractionalVal);
    }
 else {
      Double fractionalVal=fractionalUsage(report.getBeginMs(),report.getEndMs(),prevData.lastMs,eventMs,event.getValue() - prevData.lastVal);
      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));
      addMetricValueToUsageEntity(usageEntity,event.getMetric(),event.getDimension(),fractionalVal);
    }
    prevDataMap.put(key,new MetricPrevData(prevData.firstMs,eventMs,event.getValue()));
  }
  return true;
}