nus-yam/ex-repair huggingface dataset:
Program: 14444
Project: 14444
Buggy source:
public void addCpuUtilizationMs(Long cpuUtilizationMs){
  if (cpuUtilizationMs != null) {
    this.cpuUtilizationMs=this.cpuUtilizationMs + cpuUtilizationMs;
  }
}

Fixed version (ground truth):
public void addCpuUtilizationMs(Long cpuUtilizationMs){
  this.cpuUtilizationMs=plus(this.cpuUtilizationMs,cpuUtilizationMs);
}
Program: 14445
Project: 14445
Buggy source:
public void addDiskOutMegs(Long diskOutMegs){
  if (diskOutMegs != null) {
    this.diskOutMegs=this.diskOutMegs + diskOutMegs;
  }
}

Fixed version (ground truth):
public void addDiskOutMegs(Long diskOutMegs){
  this.diskOutMegs=plus(this.diskOutMegs,diskOutMegs);
}
Program: 14446
Project: 14446
Buggy source:
public void addNetInternalInMegs(Long netInternalInMegs){
  if (netInternalInMegs != null) {
    this.netInternalInMegs=this.netInternalInMegs + netInternalInMegs;
  }
}

Fixed version (ground truth):
public void addNetInternalInMegs(Long netInternalInMegs){
  this.netInternalInMegs=plus(this.netInternalInMegs,netInternalInMegs);
}
Program: 14447
Project: 14447
Buggy source:
public void addNetInternalOutMegs(Long netInternalOutMegs){
  if (netInternalOutMegs != null) {
    this.netInternalOutMegs=this.netInternalOutMegs + netInternalOutMegs;
  }
}

Fixed version (ground truth):
public void addNetInternalOutMegs(Long netInternalOutMegs){
  this.netInternalOutMegs=plus(this.netInternalOutMegs,netInternalOutMegs);
}
Program: 14448
Project: 14448
Buggy source:
public void addNetTotalOutMegs(Long netExternalOutMegs){
  if (netExternalOutMegs != null) {
    this.netExternalOutMegs=this.netExternalOutMegs + netExternalOutMegs;
  }
}

Fixed version (ground truth):
public void addNetTotalOutMegs(Long netExternalOutMegs){
  this.netTotalOutMegs=plus(this.netTotalOutMegs,netTotalOutMegs);
}
Program: 14449
Project: 14449
Buggy source:
public Long getNetTotalInMegs(){
  return netExternalInMegs;
}

Fixed version (ground truth):
public Long getNetTotalInMegs(){
  return netTotalInMegs;
}
Program: 14450
Project: 14450
Buggy source:
public void addNetTotalInMegs(Long netExternalInMegs){
  if (netExternalInMegs != null) {
    this.netExternalInMegs=this.netExternalInMegs + netExternalInMegs;
  }
}

Fixed version (ground truth):
public void addNetTotalInMegs(Long netTotalInMegs){
  this.netTotalInMegs=plus(this.netTotalInMegs,netTotalInMegs);
}
Program: 14451
Project: 14451
Buggy source:
public void addDiskInMegs(Long diskInMegs){
  if (diskInMegs != null) {
    this.diskInMegs=this.diskInMegs + diskInMegs;
  }
}

Fixed version (ground truth):
public void addDiskInMegs(Long diskInMegs){
  this.diskInMegs=plus(this.diskInMegs,diskInMegs);
}
Program: 14452
Project: 14452
Buggy source:
public Long getNetTotalOutMegs(){
  return netExternalOutMegs;
}

Fixed version (ground truth):
public Long getNetTotalOutMegs(){
  return netTotalOutMegs;
}
Program: 14453
Project: 14453
Buggy source:
public static Document addUsageCols(Document doc,InstanceUsageArtEntity entity,Units units) throws IOException {
  doc.addValCol((long)entity.getInstanceCnt());
  doc.addValCol(UnitUtil.convertTime(entity.getDurationMs(),TimeUnit.MS,units.getTimeUnit()));
  doc.addValCol(entity.getCpuUtilizationMs() / entity.getDurationMs());
  doc.addValCol(UnitUtil.convertSize(entity.getNetInternalInMegs(),SizeUnit.MB,units.getSizeUnit()));
  doc.addValCol(UnitUtil.convertSize(entity.getNetInternalOutMegs(),SizeUnit.MB,units.getSizeUnit()));
  doc.addValCol(UnitUtil.convertSize(entity.getNetTotalInMegs(),SizeUnit.MB,units.getSizeUnit()));
  doc.addValCol(UnitUtil.convertSize(entity.getNetTotalOutMegs(),SizeUnit.MB,units.getSizeUnit()));
  doc.addValCol(UnitUtil.convertSize(entity.getDiskInMegs(),SizeUnit.MB,units.getSizeUnit()));
  doc.addValCol(UnitUtil.convertSize(entity.getDiskOutMegs(),SizeUnit.MB,units.getSizeUnit()));
  return doc;
}

Fixed version (ground truth):
public static Document addUsageCols(Document doc,InstanceUsageArtEntity entity,Units units) throws IOException {
  doc.addValCol((long)entity.getInstanceCnt());
  doc.addValCol(UnitUtil.convertTime(entity.getDurationMs(),TimeUnit.MS,units.getTimeUnit()));
  doc.addValCol((entity.getCpuUtilizationMs() == null) ? null : (entity.getCpuUtilizationMs() / entity.getDurationMs()));
  doc.addValCol(UnitUtil.convertSize(entity.getNetInternalInMegs(),SizeUnit.MB,units.getSizeUnit()));
  doc.addValCol(UnitUtil.convertSize(entity.getNetInternalOutMegs(),SizeUnit.MB,units.getSizeUnit()));
  doc.addValCol(UnitUtil.convertSize(entity.getNetTotalInMegs(),SizeUnit.MB,units.getSizeUnit()));
  doc.addValCol(UnitUtil.convertSize(entity.getNetTotalOutMegs(),SizeUnit.MB,units.getSizeUnit()));
  doc.addValCol(UnitUtil.convertSize(entity.getDiskInMegs(),SizeUnit.MB,units.getSizeUnit()));
  doc.addValCol(UnitUtil.convertSize(entity.getDiskOutMegs(),SizeUnit.MB,units.getSizeUnit()));
  return doc;
}
Program: 14456
Project: 14456
Buggy source:
private S3ObjectData(long defaultDurationMs,long sizeGB){
  this.defaultDurationMs=defaultDurationMs;
  this.durationMs=0l;
  this.sizeGB=sizeGB;
}

Fixed version (ground truth):
private S3ObjectData(long sizeGB){
  this.durationMs=0l;
  this.sizeGB=sizeGB;
}
Program: 14458
Project: 14458
Buggy source:
public long getDurationMs(){
  return (durationMs == 0l) ? defaultDurationMs : durationMs;
}

Fixed version (ground truth):
public long getDurationMs(){
  return durationMs;
}
Program: 14459
Project: 14459
Buggy source:
public void addStart(T key,long timestampMs){
  if (!startTimesMs.containsKey(key)) {
    startTimesMs.put(key,new TreeSet<Long>());
  }
  startTimesMs.get(key).add(timestampMs);
}

Fixed version (ground truth):
public void addStart(T key,long timestampMs){
  if (!startTimesMs.containsKey(key)) {
    startTimesMs.put(key,new TreeSet<Long>());
  }
  if (!endTimesMs.containsKey(key)) {
    endTimesMs.put(key,new TreeSet<Long>());
  }
  startTimesMs.get(key).add(timestampMs);
}
Program: 14460
Project: 14460
Buggy source:
public DurationCalculator(){
  startTimesMs=new HashMap<T,TreeSet<Long>>();
}

Fixed version (ground truth):
/** 
 * @param defaultEndMs A default end time for objects with start timesbut no end times (i.e. created but not yet deleted). For example, report end time.
 */
public DurationCalculator(long defaultEndMs){
  startTimesMs=new HashMap<T,TreeSet<Long>>();
  endTimesMs=new HashMap<T,TreeSet<Long>>();
  this.defaultEndMs=defaultEndMs;
}
Program: 14462
Project: 14462
Buggy source:
@Override public Document addLabelCol(int indent,String val) throws IOException {
  addEmptyLabelCols(indent);
  addCol(val,LABEL_WIDTH,3,"String_Node_Str");
  addEmptyLabelCols(3 - indent);
  rowHasLabel=true;
  return this;
}

Fixed version (ground truth):
@Override public Document addLabelCol(int indent,String val) throws IOException {
  addEmptyLabelCols(indent);
  rowSb.append(String.format("String_Node_Str",LABEL_WIDTH,3,val));
  addEmptyLabelCols(3 - indent);
  rowHasLabel=true;
  return this;
}
Program: 14467
Project: 14467
Buggy source:
public static void triggerFault(int id,Properties varProps){
  for (  ComponentId componentId : ComponentIds.list()) {
    try {
      FaultLogger faultLogger=FaultSubsystem.getFaultLogger(componentId);
      LOG.debug("String_Node_Str" + componentId.getName() + "String_Node_Str"+ id+ "String_Node_Str"+ varProps);
      Fault fault=FaultSubsystem.fault(id);
      if (fault == null) {
        LOG.error("String_Node_Str" + id + "String_Node_Str");
      }
      if (varProps != null) {
        Enumeration e=varProps.propertyNames();
        while (e.hasMoreElements()) {
          String name=(String)e.nextElement();
          String value=varProps.getProperty(name);
          if (value == null)           continue;
          fault=fault.withVar(name,value);
        }
      }
      faultLogger.log(fault);
    }
 catch (    Exception ex) {
      LOG.error("String_Node_Str" + ex);
      ex.printStackTrace();
    }
  }
}

Fixed version (ground truth):
public static void triggerFault(int id,Properties varProps){
  for (  ComponentId componentId : ComponentIds.list()) {
    try {
      FaultLogger faultLogger=FaultSubsystem.getFaultLogger(componentId);
      LOG.debug("String_Node_Str" + componentId.getName() + "String_Node_Str"+ id+ "String_Node_Str"+ varProps);
      Fault fault=FaultSubsystem.fault(id);
      if (fault == null) {
        LOG.error("String_Node_Str" + id + "String_Node_Str");
      }
      if (varProps != null) {
        Enumeration e=varProps.propertyNames();
        while (e.hasMoreElements()) {
          String name=(String)e.nextElement();
          String value=varProps.getProperty(name);
          if (value == null)           continue;
          fault=fault.withVar(name,value);
        }
      }
      LOG.info("String_Node_Str" + fault.toString());
      faultLogger.log(fault);
    }
 catch (    Exception ex) {
      LOG.error("String_Node_Str" + ex);
      ex.printStackTrace();
    }
  }
}
Program: 14468
Project: 14468
Buggy source:
@Override public synchronized FaultLogger getFaultLogger(ComponentId componentId){
  if (componentId == null)   throw new IllegalArgumentException("String_Node_Str");
  FaultLogger logger=loggerMap.get(componentId);
  if (logger == null) {
    logger=initLogger(componentId);
  }
  return logger;
}

Fixed version (ground truth):
@Override public synchronized FaultLogger getFaultLogger(ComponentId componentId){
  if (componentId == null)   throw new IllegalArgumentException("String_Node_Str");
  FaultLogger logger=loggerMap.get(componentId);
  if (logger == null) {
    logger=initLogger(componentId);
    loggerMap.put(componentId,logger);
  }
  return logger;
}
Program: 14470
Project: 14470
Buggy source:
@Override public void log(Fault fault){
  LOG.fatal(fault.toString());
}

Fixed version (ground truth):
@Override public void log(Fault fault){
  Logger tmpLogger=Logger.getLogger(XMLFaultLogger.class);
  tmpLogger.info("String_Node_Str" + LOG.getName());
  Enumeration appenderEnum=LOG.getAllAppenders();
  while (appenderEnum.hasMoreElements()) {
    tmpLogger.info("String_Node_Str" + ((Appender)appenderEnum.nextElement()).getName());
  }
  LOG.fatal(fault.toString());
}
Program: 14471
Project: 14471
Buggy source:
/** 
 * <p>Do not instantiate this class directly; use the ReportingElasticIpCrud class.
 */
ReportingElasticIpCreateEvent(String uuid,Long timestampMs,String ip,String userId){
  this.uuid=null;
  this.timestampMs=timestampMs;
  this.ip=ip;
  this.userId=userId;
}

Fixed version (ground truth):
/** 
 * <p>Do not instantiate this class directly; use the ReportingElasticIpCrud class.
 */
ReportingElasticIpCreateEvent(String uuid,Long timestampMs,String ip,String userId){
  this.uuid=uuid;
  this.timestampMs=timestampMs;
  this.ip=ip;
  this.userId=userId;
}
Program: 14472
Project: 14472
Buggy source:
private ReportingElasticIpEventStore(){
}

Fixed version (ground truth):
protected ReportingElasticIpEventStore(){
}
Program: 14473
Project: 14473
Buggy source:
public void insertCreateEvent(@Nonnull final String uuid,final long timestampMs,@Nonnull final String userId,@Nonnull final String ip){
  Preconditions.checkNotNull(uuid,"String_Node_Str");
  Preconditions.checkNotNull(userId,"String_Node_Str");
  Preconditions.checkNotNull(ip,"String_Node_Str");
  persist(new ReportingElasticIpCreateEvent(uuid,timestampMs,userId,ip));
}

Fixed version (ground truth):
public void insertCreateEvent(@Nonnull final String uuid,final long timestampMs,@Nonnull final String userId,@Nonnull final String ip){
  Preconditions.checkNotNull(uuid,"String_Node_Str");
  Preconditions.checkNotNull(userId,"String_Node_Str");
  Preconditions.checkNotNull(ip,"String_Node_Str");
  persist(new ReportingElasticIpCreateEvent(uuid,timestampMs,ip,userId));
}
Program: 14474
Project: 14474
Buggy source:
private void persist(final Object event){
  Entities.persist(event);
}

Fixed version (ground truth):
protected void persist(final Object event){
  Entities.persist(event);
}
Program: 14475
Project: 14475
Buggy source:
@Override public void fireEvent(@Nonnull final AddressEvent event){
  Preconditions.checkNotNull(event,"String_Node_Str");
  ReportingAccountDao.getInstance().addUpdateAccount(event.getAccountId(),event.getAccountName());
  ReportingUserDao.getInstance().addUpdateUser(event.getUserId(),event.getUserName());
  final ReportingElasticIpEventStore eventStore=ReportingElasticIpEventStore.getInstance();
switch (event.getActionInfo().getAction()) {
case ALLOCATE:
    eventStore.insertCreateEvent(event.getUuid(),System.currentTimeMillis(),event.getUserId(),event.getAddress());
  break;
case RELEASE:
eventStore.insertDeleteEvent(event.getUuid(),System.currentTimeMillis());
break;
case ASSOCIATE:
eventStore.insertAttachEvent(event.getUuid(),((InstanceActionInfo)event.getActionInfo()).getInstanceUuid(),System.currentTimeMillis());
break;
case DISASSOCIATE:
eventStore.insertDetachEvent(event.getUuid(),((InstanceActionInfo)event.getActionInfo()).getInstanceUuid(),System.currentTimeMillis());
break;
}
}

Fixed version (ground truth):
@Override public void fireEvent(@Nonnull final AddressEvent event){
  Preconditions.checkNotNull(event,"String_Node_Str");
  final long timestamp=getCurrentTimeMillis();
  getReportingAccountDao().addUpdateAccount(event.getAccountId(),event.getAccountName());
  getReportingUserDao().addUpdateUser(event.getUserId(),event.getUserName());
  final ReportingElasticIpEventStore eventStore=getReportingElasticIpEventStore();
switch (event.getActionInfo().getAction()) {
case ALLOCATE:
    eventStore.insertCreateEvent(event.getUuid(),timestamp,event.getUserId(),event.getAddress());
  break;
case RELEASE:
eventStore.insertDeleteEvent(event.getUuid(),timestamp);
break;
case ASSOCIATE:
eventStore.insertAttachEvent(event.getUuid(),((InstanceActionInfo)event.getActionInfo()).getInstanceUuid(),timestamp);
break;
case DISASSOCIATE:
eventStore.insertDetachEvent(event.getUuid(),((InstanceActionInfo)event.getActionInfo()).getInstanceUuid(),timestamp);
break;
}
}
Program: 14476
Project: 14476
Buggy source:
private ReportingAccountDao(){
}

Fixed version (ground truth):
protected ReportingAccountDao(){
}
Program: 14477
Project: 14477
Buggy source:
private ReportingUserDao(){
}

Fixed version (ground truth):
protected ReportingUserDao(){
}
Program: 14478
Project: 14478
Buggy source:
public void update(InstanceUsageSnapshot snapshot){
  this.lastSnapshot=snapshot;
  accumulateDiskIoMegs(snapshot);
  accumulateNetIoMegs(snapshot);
  this.priorSnapshot=snapshot;
}

Fixed version (ground truth):
public void update(InstanceUsageSnapshot snapshot){
  if (firstSnapshot == null && (priorSnapshot.getTimestampMs() >= period.getBeginningMs() || snapshot.getTimestampMs() >= period.getBeginningMs())) {
    firstSnapshot=priorSnapshot;
    log.debug("String_Node_Str" + firstSnapshot.getTimestampMs());
  }
  if (lastSnapshot == null && (priorSnapshot.getTimestampMs() > period.getEndingMs())) {
    lastSnapshot=priorSnapshot;
    log.debug("String_Node_Str" + lastSnapshot.getTimestampMs());
    accumulateDiskIoMegs(snapshot);
    accumulateNetIoMegs(snapshot);
  }
  if (firstSnapshot != null && lastSnapshot == null) {
    accumulateDiskIoMegs(snapshot);
    accumulateNetIoMegs(snapshot);
  }
  this.priorSnapshot=snapshot;
}
Program: 14479
Project: 14479
Buggy source:
public InstanceDataAccumulator(InstanceAttributes insAttrs,InstanceUsageSnapshot snapshot,Period period){
  super();
  this.insAttrs=insAttrs;
  this.firstSnapshot=snapshot;
  this.priorSnapshot=snapshot;
  this.lastSnapshot=snapshot;
  this.period=period;
}

Fixed version (ground truth):
public InstanceDataAccumulator(InstanceAttributes insAttrs,InstanceUsageSnapshot snapshot,Period period){
  super();
  this.insAttrs=insAttrs;
  this.lastSnapshot=null;
  this.priorSnapshot=snapshot;
  this.firstSnapshot=null;
  this.period=period;
}
Program: 14480
Project: 14480
Buggy source:
public long getDurationSecs(){
  if (period.getBeginningMs() >= lastSnapshot.getTimestampMs() || period.getEndingMs() <= firstSnapshot.getTimestampMs()) {
    return 0l;
  }
 else {
    long truncatedBeginMs=Math.max(period.getBeginningMs(),firstSnapshot.getTimestampMs());
    long truncatedEndMs=Math.min(period.getEndingMs(),lastSnapshot.getTimestampMs());
    return (truncatedEndMs - truncatedBeginMs) / 1000;
  }
}

Fixed version (ground truth):
public long getDurationSecs(){
  if (period.getBeginningMs() >= lastSnapshot.getTimestampMs() || period.getEndingMs() <= firstSnapshot.getTimestampMs()) {
    log.debug("String_Node_Str" + period.getBeginningMs() + "String_Node_Str"+ period.getEndingMs()+ "String_Node_Str"+ firstSnapshot.getTimestampMs()+ "String_Node_Str"+ lastSnapshot.getTimestampMs());
    return 0l;
  }
 else {
    long truncatedBeginMs=Math.max(period.getBeginningMs(),firstSnapshot.getTimestampMs());
    long truncatedEndMs=Math.min(period.getEndingMs(),lastSnapshot.getTimestampMs());
    log.debug("String_Node_Str" + truncatedBeginMs + "String_Node_Str"+ truncatedEndMs);
    return (truncatedEndMs - truncatedBeginMs) / 1000;
  }
}
Program: 14482
Project: 14482
Buggy source:
public long getDurationSecs(){
  long truncatedBeginMs=Math.max(period.getBeginningMs(),firstSnapshot.getTimestampMs());
  long truncatedEndMs=Math.min(period.getEndingMs(),lastSnapshot.getTimestampMs());
  return (truncatedEndMs - truncatedBeginMs) / 1000;
}

Fixed version (ground truth):
public long getDurationSecs(){
  if (period.getBeginningMs() >= lastSnapshot.getTimestampMs() || period.getEndingMs() <= firstSnapshot.getTimestampMs()) {
    return 0l;
  }
 else {
    long truncatedBeginMs=Math.max(period.getBeginningMs(),firstSnapshot.getTimestampMs());
    long truncatedEndMs=Math.min(period.getEndingMs(),lastSnapshot.getTimestampMs());
    return (truncatedEndMs - truncatedBeginMs) / 1000;
  }
}
Program: 14484
Project: 14484
Buggy source:
public long getDurationSecs(){
  long truncatedBeginMs=Math.max(period.getBeginningMs(),firstSnapshot.getTimestampMs());
  long truncatedEndMs=Math.min(period.getEndingMs(),lastSnapshot.getTimestampMs());
  return (truncatedEndMs - truncatedBeginMs) / 1000;
}

Fixed version (ground truth):
public long getDurationSecs(){
  if (period.getBeginningMs() >= lastSnapshot.getTimestampMs() || period.getEndingMs() <= firstSnapshot.getTimestampMs()) {
    return 0l;
  }
 else {
    long truncatedBeginMs=Math.max(period.getBeginningMs(),firstSnapshot.getTimestampMs());
    long truncatedEndMs=Math.min(period.getEndingMs(),lastSnapshot.getTimestampMs());
    return (truncatedEndMs - truncatedBeginMs) / 1000;
  }
}
Program: 14489
Project: 14489
Buggy source:
public static void cleanUp(final VmInstance vm){
  Logs.extreme().info("String_Node_Str" + vm.getInstanceId(),new RuntimeException());
  try {
    Address address=null;
    if (NetworkGroups.networkingConfiguration().hasNetworking()) {
      try {
        address=Addresses.getInstance().lookup(vm.getPublicAddress());
        if (address.isAssigned()) {
          AsyncRequests.newRequest(address.unassign().getCallback()).dispatch(vm.getPartition());
        }
        if (address.isSystemOwned()) {
          EventRecord.caller(VmInstances.class,EventType.VM_TERMINATING,"String_Node_Str",address.toString()).debug();
        }
 else {
          EventRecord.caller(VmInstances.class,EventType.VM_TERMINATING,"String_Node_Str",address.toString()).debug();
        }
      }
 catch (      final NoSuchElementException e) {
      }
catch (      final Exception e1) {
        LOG.debug(e1,e1);
      }
    }
  }
 catch (  final Exception e) {
    LOG.error(e);
    Logs.extreme().error(e,e);
  }
  try {
    VmInstances.cleanUpAttachedVolumes(vm);
  }
 catch (  Exception ex) {
    LOG.error(ex);
    Logs.extreme().error(ex,ex);
  }
  try {
    AsyncRequests.newRequest(new TerminateCallback(vm.getInstanceId())).dispatch(vm.getPartition());
  }
 catch (  Exception ex) {
    LOG.error(ex);
    Logs.extreme().error(ex,ex);
  }
}

Fixed version (ground truth):
public static void cleanUp(final VmInstance vm){
  Logs.extreme().info("String_Node_Str" + vm.getInstanceId(),new RuntimeException());
  try {
    Address address=null;
    if (NetworkGroups.networkingConfiguration().hasNetworking()) {
      try {
        address=Addresses.getInstance().lookup(vm.getPublicAddress());
        if (address.isAssigned()) {
          AsyncRequests.newRequest(address.unassign().getCallback()).dispatch(vm.getPartition());
          if (address.isSystemOwned()) {
            EventRecord.caller(VmInstances.class,EventType.VM_TERMINATING,"String_Node_Str",address.toString()).debug();
          }
 else {
            EventRecord.caller(VmInstances.class,EventType.VM_TERMINATING,"String_Node_Str",address.toString()).debug();
          }
        }
      }
 catch (      final NoSuchElementException e) {
      }
catch (      final Exception e1) {
        LOG.debug(e1,e1);
      }
    }
  }
 catch (  final Exception e) {
    LOG.error(e);
    Logs.extreme().error(e,e);
  }
  try {
    VmInstances.cleanUpAttachedVolumes(vm);
  }
 catch (  Exception ex) {
    LOG.error(ex);
    Logs.extreme().error(ex,ex);
  }
  try {
    AsyncRequests.newRequest(new TerminateCallback(vm.getInstanceId())).dispatch(vm.getPartition());
  }
 catch (  Exception ex) {
    LOG.error(ex);
    Logs.extreme().error(ex,ex);
  }
}
Program: 14490
Project: 14490
Buggy source:
public static VmInstance lookupByPublicIp(final String ip) throws NoSuchElementException {
  EntityTransaction db=Entities.get(VmInstance.class);
  try {
    VmInstance vmExample=VmInstance.exampleWithPublicIp(ip);
    VmInstance vm=(VmInstance)Entities.createCriteriaUnique(VmInstance.class).add(Example.create(vmExample).enableLike(MatchMode.EXACT)).uniqueResult();
    if (vm == null) {
      throw new NoSuchElementException("String_Node_Str" + ip);
    }
    db.commit();
    return vm;
  }
 catch (  Exception ex) {
    Logs.exhaust().error(ex,ex);
    db.rollback();
    throw new NoSuchElementException(ex.getMessage());
  }
}

Fixed version (ground truth):
public static VmInstance lookupByPublicIp(final String ip) throws NoSuchElementException {
  EntityTransaction db=Entities.get(VmInstance.class);
  try {
    VmInstance vmExample=VmInstance.exampleWithPublicIp(ip);
    VmInstance vm=(VmInstance)Entities.createCriteriaUnique(VmInstance.class).add(Example.create(vmExample).enableLike(MatchMode.EXACT)).add(Restrictions.in("String_Node_Str",new VmState[]{VmState.RUNNING,VmState.PENDING})).uniqueResult();
    if (vm == null) {
      throw new NoSuchElementException("String_Node_Str" + ip);
    }
    db.commit();
    return vm;
  }
 catch (  Exception ex) {
    Logs.exhaust().error(ex,ex);
    db.rollback();
    throw new NoSuchElementException(ex.getMessage());
  }
}
Program: 14491
Project: 14491
Buggy source:
public static VmInstance lookupByPrivateIp(final String ip) throws NoSuchElementException {
  EntityTransaction db=Entities.get(VmInstance.class);
  try {
    VmInstance vmExample=VmInstance.exampleWithPrivateIp(ip);
    VmInstance vm=(VmInstance)Entities.createCriteriaUnique(VmInstance.class).add(Example.create(vmExample).enableLike(MatchMode.EXACT)).uniqueResult();
    if (vm == null) {
      throw new NoSuchElementException("String_Node_Str" + ip);
    }
    db.commit();
    return vm;
  }
 catch (  Exception ex) {
    Logs.exhaust().error(ex,ex);
    db.rollback();
    throw new NoSuchElementException(ex.getMessage());
  }
}

Fixed version (ground truth):
public static VmInstance lookupByPrivateIp(final String ip) throws NoSuchElementException {
  EntityTransaction db=Entities.get(VmInstance.class);
  try {
    VmInstance vmExample=VmInstance.exampleWithPrivateIp(ip);
    VmInstance vm=(VmInstance)Entities.createCriteriaUnique(VmInstance.class).add(Example.create(vmExample).enableLike(MatchMode.EXACT)).add(Restrictions.in("String_Node_Str",new VmState[]{VmState.RUNNING,VmState.PENDING})).uniqueResult();
    if (vm == null) {
      throw new NoSuchElementException("String_Node_Str" + ip);
    }
    db.commit();
    return vm;
  }
 catch (  Exception ex) {
    Logs.exhaust().error(ex,ex);
    db.rollback();
    throw new NoSuchElementException(ex.getMessage());
  }
}
Program: 14492
Project: 14492
Buggy source:
public static Function<VmVolumeAttachment,AttachedVolume> asAttachedVolume(final VmInstance vm){
  return new Function<VmVolumeAttachment,AttachedVolume>(){
    @Override public AttachedVolume apply(    VmVolumeAttachment vol){
      AttachedVolume attachment=null;
      if (vm == null && vol.getVmInstance() == null) {
        throw new NoSuchElementException("String_Node_Str" + vol);
      }
 else       if (vm == null) {
        attachment=new AttachedVolume(vol.getVolumeId(),vol.getVmInstance().getInstanceId(),vol.getDevice(),vol.getRemoteDevice());
      }
 else {
        attachment=new AttachedVolume(vol.getVolumeId(),vm.getInstanceId(),vol.getDevice(),vol.getRemoteDevice());
      }
      attachment.setAttachTime(vol.getAttachTime());
      attachment.setStatus(vol.getStatus());
      if (!attachment.getDevice().startsWith("String_Node_Str")) {
        attachment.setDevice("String_Node_Str" + attachment.getDevice());
      }
      return attachment;
    }
  }
;
}

Fixed version (ground truth):
public static Function<VmVolumeAttachment,AttachedVolume> asAttachedVolume(final VmInstance vm){
  return new Function<VmVolumeAttachment,AttachedVolume>(){
    @Override public AttachedVolume apply(    VmVolumeAttachment vol){
      AttachedVolume attachment=null;
      if (vm == null && vol.getVmInstance() == null) {
        throw new NoSuchElementException("String_Node_Str" + vol);
      }
 else       if (vm == null) {
        attachment=new AttachedVolume(vol.getVolumeId(),vol.getVmInstance().getInstanceId(),vol.getDevice(),vol.getRemoteDevice());
      }
 else {
        attachment=new AttachedVolume(vol.getVolumeId(),vm.getInstanceId(),vol.getDevice(),vol.getRemoteDevice());
      }
      attachment.setAttachTime(vol.getAttachTime());
      attachment.setStatus(vol.getStatus());
      if (!attachment.getDevice().replaceAll("String_Node_Str","String_Node_Str").startsWith("String_Node_Str")) {
        attachment.setDevice("String_Node_Str" + attachment.getDevice().replaceAll("String_Node_Str","String_Node_Str"));
      }
      return attachment;
    }
  }
;
}
Program: 14493
Project: 14493
Buggy source:
private static CascadingTx createTransaction(final Object obj) throws RecoverablePersistenceException, RuntimeException {
  final String ctx=lookatPersistenceContext(obj);
  final CascadingTx ret=new CascadingTx(ctx);
  ret.begin();
  if (txRootThreadLocal.get() == null) {
    final String txId=makeTxRootName(ret);
    LOG.trace("String_Node_Str" + txId + "String_Node_Str"+ Threads.currentStackString());
    txRootThreadLocal.set(txId);
  }
  txStateThreadLocal.get().put(ctx,ret);
  return ret;
}

Fixed version (ground truth):
private static CascadingTx createTransaction(final Object obj) throws RecoverablePersistenceException, RuntimeException {
  final String ctx=lookatPersistenceContext(obj);
  final CascadingTx ret=new CascadingTx(ctx);
  try {
    ret.begin();
    if (txRootThreadLocal.get() == null) {
      final String txId=makeTxRootName(ret);
      LOG.trace("String_Node_Str" + txId + "String_Node_Str"+ Threads.currentStackString());
      txRootThreadLocal.set(txId);
    }
    txStateThreadLocal.get().put(ctx,ret);
    return ret;
  }
 catch (  RuntimeException ex) {
    try {
      ret.rollback();
    }
 catch (    RuntimeException ex1) {
      throw ex1;
    }
    throw ex;
  }
}
Program: 14494
Project: 14494
Buggy source:
private static CascadingTx createTransaction(final Object obj) throws RecoverablePersistenceException, RuntimeException {
  final String ctx=lookatPersistenceContext(obj);
  final CascadingTx ret=new CascadingTx(ctx);
  ret.begin();
  if (txRootThreadLocal.get() == null) {
    final String txId=makeTxRootName(ret);
    LOG.trace("String_Node_Str" + txId + "String_Node_Str"+ Threads.currentStackString());
    txRootThreadLocal.set(txId);
  }
  txStateThreadLocal.get().put(ctx,ret);
  return ret;
}

Fixed version (ground truth):
private static CascadingTx createTransaction(final Object obj) throws RecoverablePersistenceException, RuntimeException {
  final String ctx=lookatPersistenceContext(obj);
  final CascadingTx ret=new CascadingTx(ctx);
  try {
    ret.begin();
    if (txRootThreadLocal.get() == null) {
      final String txId=makeTxRootName(ret);
      LOG.trace("String_Node_Str" + txId + "String_Node_Str"+ Threads.currentStackString());
      txRootThreadLocal.set(txId);
    }
    txStateThreadLocal.get().put(ctx,ret);
    return ret;
  }
 catch (  RuntimeException ex) {
    try {
      ret.rollback();
    }
 catch (    RuntimeException ex1) {
      throw ex1;
    }
    throw ex;
  }
}
Program: 14495
Project: 14495
Buggy source:
private Allocation(final String reservationId,final Integer launchIndex,final String instanceId,final byte[] userData,final Date expiration,final Partition partition,final SshKeyPair sshKeyPair,final BootableSet bootSet,final VmType vmType,final Set<NetworkGroup> networkGroups){
  super();
  this.context=Contexts.lookup();
  this.minCount=1;
  this.maxCount=1;
  this.ownerFullName=this.context.getUserFullName();
  this.reservationId=reservationId;
  this.reservationIndex=UniqueIds.nextIndex(VmInstance.class,(long)this.maxCount);
  this.instanceIds=Maps.newHashMap();
  this.instanceIds.put(launchIndex,instanceId);
  this.userData=userData;
  this.partition=partition;
  this.sshKeyPair=(sshKeyPair != null ? sshKeyPair : KeyPairs.noKey());
  this.bootSet=bootSet;
  this.expiration=expiration;
  this.vmType=vmType;
  this.networkGroups=new HashMap<String,NetworkGroup>(){
{
      for (      NetworkGroup g : networkGroups) {
        if (Allocation.this.primaryNetwork == null) {
          Allocation.this.primaryNetwork=g;
        }
        put(g.getDisplayName(),g);
      }
    }
  }
;
  this.request=new RunInstancesType(){
{
      this.setMinCount(1);
      this.setMaxCount(1);
      this.setImageId(bootSet.getMachine().getDisplayName());
      this.setAvailabilityZone(partition.getName());
      this.getGroupSet().addAll(Allocation.this.networkGroups.keySet());
      this.setInstanceType(vmType.getName());
    }
  }
;
}

Fixed version (ground truth):
private Allocation(final String reservationId,final String instanceId,final byte[] userData,final Date expiration,final Partition partition,final SshKeyPair sshKeyPair,final BootableSet bootSet,final VmType vmType,final Set<NetworkGroup> networkGroups){
  super();
  this.context=Contexts.lookup();
  this.minCount=1;
  this.maxCount=1;
  this.ownerFullName=this.context.getUserFullName();
  this.reservationId=reservationId;
  this.reservationIndex=UniqueIds.nextIndex(VmInstance.class,(long)this.maxCount);
  this.instanceIds=Maps.newHashMap();
  this.instanceIds.put(0,instanceId);
  this.userData=userData;
  this.partition=partition;
  this.sshKeyPair=(sshKeyPair != null ? sshKeyPair : KeyPairs.noKey());
  this.bootSet=bootSet;
  this.expiration=expiration;
  this.vmType=vmType;
  this.networkGroups=new HashMap<String,NetworkGroup>(){
{
      for (      NetworkGroup g : networkGroups) {
        if (Allocation.this.primaryNetwork == null) {
          Allocation.this.primaryNetwork=g;
        }
        put(g.getDisplayName(),g);
      }
    }
  }
;
  this.request=new RunInstancesType(){
{
      this.setMinCount(1);
      this.setMaxCount(1);
      this.setImageId(bootSet.getMachine().getDisplayName());
      this.setAvailabilityZone(partition.getName());
      this.getGroupSet().addAll(Allocation.this.networkGroups.keySet());
      this.setInstanceType(vmType.getName());
    }
  }
;
}
Program: 14496
Project: 14496
Buggy source:
public static Allocation start(final VmInstance vm){
  BootableSet bootSet=Emis.recreateBootableSet(vm);
  return new Allocation(vm.getReservationId(),vm.getLaunchIndex(),vm.getInstanceId(),vm.getUserData(),vm.getExpiration(),vm.lookupPartition(),vm.getKeyPair(),bootSet,vm.getVmType(),vm.getNetworkGroups());
}

Fixed version (ground truth):
public static Allocation start(final VmInstance vm){
  BootableSet bootSet=Emis.recreateBootableSet(vm);
  return new Allocation(vm.getReservationId(),vm.getInstanceId(),vm.getUserData(),vm.getExpiration(),vm.lookupPartition(),vm.getKeyPair(),bootSet,vm.getVmType(),vm.getNetworkGroups());
}
Program: 14497
Project: 14497
Buggy source:
public DescribeImagesResponseType describe(final DescribeImagesType request) throws EucalyptusCloudException, TransactionException {
  DescribeImagesResponseType reply=request.getReply();
  final Context ctx=Contexts.lookup();
  final String requestAccountId=ctx.getUserFullName().getAccountNumber();
  final List<String> ownersSet=request.getOwnersSet();
  if (ownersSet.remove(Images.SELF)) {
    ownersSet.add(requestAccountId);
  }
  Predicate<ImageInfo> rangeFilter=Predicates.and(CloudMetadatas.filterById(request.getImagesSet()),CloudMetadatas.filterByOwningAccount(request.getOwnersSet()),Images.filterExecutableBy(ownersSet));
  Predicate<ImageInfo> privilegesFilter=Predicates.and(Images.FilterPermissions.INSTANCE,RestrictedTypes.filterPrivilegedWithoutOwner());
  Predicate<ImageInfo> filter=Predicates.and(privilegesFilter,rangeFilter);
  List<ImageDetails> imageDetailsList=Transactions.filteredTransform(new ImageInfo(),filter,Images.TO_IMAGE_DETAILS);
  reply.getImagesSet().addAll(imageDetailsList);
  ImageUtil.cleanDeregistered();
  return reply;
}

Fixed version (ground truth):
public DescribeImagesResponseType describe(final DescribeImagesType request) throws EucalyptusCloudException, TransactionException {
  DescribeImagesResponseType reply=request.getReply();
  final Context ctx=Contexts.lookup();
  final String requestAccountId=ctx.getUserFullName().getAccountNumber();
  final List<String> ownersSet=request.getOwnersSet();
  if (ownersSet.remove(Images.SELF)) {
    ownersSet.add(requestAccountId);
  }
  Predicate<ImageInfo> rangeFilter=Predicates.and(CloudMetadatas.filterById(request.getImagesSet()),CloudMetadatas.filterByOwningAccount(request.getOwnersSet()),Images.filterExecutableBy(request.getExecutableBySet()));
  Predicate<ImageInfo> privilegesFilter=Predicates.and(Images.FilterPermissions.INSTANCE,RestrictedTypes.filterPrivilegedWithoutOwner());
  Predicate<ImageInfo> filter=Predicates.and(privilegesFilter,rangeFilter);
  List<ImageDetails> imageDetailsList=Transactions.filteredTransform(new ImageInfo(),filter,Images.TO_IMAGE_DETAILS);
  reply.getImagesSet().addAll(imageDetailsList);
  ImageUtil.cleanDeregistered();
  return reply;
}
Program: 14498
Project: 14498
Buggy source:
public ResourceToken(final Allocation allocInfo,final int resourceAllocationSequenceNumber,final int launchIndex){
  this.allocation=allocInfo;
  this.expirationTime=allocInfo.getExpiration();
  this.launchIndex=launchIndex;
  this.instanceId=allocInfo.getInstanceId(launchIndex);
  this.instanceUuid=UUID.randomUUID().toString();
  this.resourceAllocationSequenceNumber=resourceAllocationSequenceNumber;
  this.creationTime=Calendar.getInstance().getTime();
  ServiceConfiguration config=Topology.lookup(ClusterController.class,this.getAllocationInfo().getPartition());
  this.cluster=Clusters.lookup(config);
}

Fixed version (ground truth):
public ResourceToken(final Allocation allocInfo,final int resourceAllocationSequenceNumber,final int launchIndex){
  this.allocation=allocInfo;
  this.expirationTime=allocInfo.getExpiration();
  this.launchIndex=launchIndex;
  this.instanceId=allocInfo.getInstanceId(launchIndex);
  if (this.instanceId == null) {
    throw new IllegalArgumentException("String_Node_Str" + allocInfo);
  }
  this.instanceUuid=UUID.randomUUID().toString();
  this.resourceAllocationSequenceNumber=resourceAllocationSequenceNumber;
  this.creationTime=Calendar.getInstance().getTime();
  ServiceConfiguration config=Topology.lookup(ClusterController.class,this.getAllocationInfo().getPartition());
  this.cluster=Clusters.lookup(config);
}
Program: 14499
Project: 14499
Buggy source:
@Override public ResourceToken get(){
  return this.iter.next();
}

Fixed version (ground truth):
@Override public ResourceToken get(){
  ResourceToken ret=this.iter.next();
  allocInfo.getAllocationTokens().add(ret);
  return ret;
}
Program: 14500
Project: 14500
Buggy source:
private List<ResourceToken> requestResourceToken(final Allocation allocInfo,final int tryAmount,final int maxAmount) throws Exception {
  ServiceConfiguration config=Topology.lookup(ClusterController.class,allocInfo.getPartition());
  Cluster cluster=Clusters.lookup(config);
  final ResourceState state=cluster.getNodeState();
  final List<ResourceToken> tokens=state.requestResourceAllocation(allocInfo,tryAmount,maxAmount);
  final Supplier<ResourceToken> allocator=new Supplier<ResourceToken>(){
    Iterator<ResourceToken> iter=tokens.iterator();
    @Override public ResourceToken get(){
      return this.iter.next();
    }
  }
;
  List<ResourceToken> pendingTokens=RestrictedTypes.allocateUnitlessResources(tokens.size(),allocator);
  allocInfo.getAllocationTokens().addAll(pendingTokens);
  return pendingTokens;
}

Fixed version (ground truth):
private List<ResourceToken> requestResourceToken(final Allocation allocInfo,final int tryAmount,final int maxAmount) throws Exception {
  ServiceConfiguration config=Topology.lookup(ClusterController.class,allocInfo.getPartition());
  Cluster cluster=Clusters.lookup(config);
  final ResourceState state=cluster.getNodeState();
  final List<ResourceToken> tokens=state.requestResourceAllocation(allocInfo,tryAmount,maxAmount);
  final Supplier<ResourceToken> allocator=new Supplier<ResourceToken>(){
    Iterator<ResourceToken> iter=tokens.iterator();
    @Override public ResourceToken get(){
      ResourceToken ret=this.iter.next();
      allocInfo.getAllocationTokens().add(ret);
      return ret;
    }
  }
;
  RestrictedTypes.allocateUnitlessResources(tokens.size(),allocator);
  return allocInfo.getAllocationTokens();
}
Program: 14502
Project: 14502
Buggy source:
static State transformStorageState(final State volumeState,final String storageState){
  if (State.GENERATING.equals(volumeState)) {
    if ("String_Node_Str".toString().equals(storageState)) {
      return State.FAIL;
    }
 else     if ("String_Node_Str".toString().equals(storageState)) {
      return State.EXTANT;
    }
 else {
      return State.GENERATING;
    }
  }
 else   if (!State.ANNIHILATING.equals(volumeState) && !State.BUSY.equals(volumeState)) {
    if ("String_Node_Str".toString().equals(storageState)) {
      return State.FAIL;
    }
 else     if ("String_Node_Str".toString().equals(storageState)) {
      return State.GENERATING;
    }
 else     if ("String_Node_Str".toString().equals(storageState)) {
      return State.EXTANT;
    }
 else     if ("String_Node_Str".equals(storageState)) {
      return State.BUSY;
    }
 else {
      return State.ANNIHILATED;
    }
  }
 else   if (State.BUSY.equals(volumeState)) {
    return State.BUSY;
  }
 else {
    if ("String_Node_Str".toString().equals(storageState)) {
      return State.FAIL;
    }
 else {
      return State.ANNIHILATED;
    }
  }
}

Fixed version (ground truth):
static State transformStorageState(final State volumeState,final String storageState){
  if (State.GENERATING.equals(volumeState)) {
    if ("String_Node_Str".toString().equals(storageState)) {
      return State.FAIL;
    }
 else     if ("String_Node_Str".toString().equals(storageState)) {
      return State.EXTANT;
    }
 else {
      return State.GENERATING;
    }
  }
 else   if (State.ANNIHILATING.equals(volumeState)) {
    return State.ANNIHILATING;
  }
 else   if (!State.ANNIHILATING.equals(volumeState) && !State.BUSY.equals(volumeState)) {
    if ("String_Node_Str".toString().equals(storageState)) {
      return State.FAIL;
    }
 else     if ("String_Node_Str".toString().equals(storageState)) {
      return State.GENERATING;
    }
 else     if ("String_Node_Str".toString().equals(storageState)) {
      return State.EXTANT;
    }
 else     if ("String_Node_Str".equals(storageState)) {
      return State.BUSY;
    }
 else {
      return State.ANNIHILATED;
    }
  }
 else   if (State.BUSY.equals(volumeState)) {
    return State.BUSY;
  }
 else {
    if ("String_Node_Str".toString().equals(storageState)) {
      return State.FAIL;
    }
 else {
      return State.ANNIHILATED;
    }
  }
}
Program: 14503
Project: 14503
Buggy source:
public DescribeImagesResponseType describe(final DescribeImagesType request) throws EucalyptusCloudException, TransactionException {
  DescribeImagesResponseType reply=request.getReply();
  final Context ctx=Contexts.lookup();
  final String requestAccountId=ctx.getUserFullName().getAccountNumber();
  final List<String> ownersSet=request.getOwnersSet();
  if (ownersSet.remove(Images.SELF)) {
    ownersSet.add(requestAccountId);
  }
  Predicate<ImageInfo> rangeFilter=Predicates.and(CloudMetadatas.filterById(request.getImagesSet()),CloudMetadatas.filterByOwningAccount(request.getOwnersSet()),Images.filterExecutableBy(ownersSet));
  Predicate<ImageInfo> privilegesFilter=Predicates.and(Images.FilterPermissions.INSTANCE,RestrictedTypes.filterPrivilegedWithoutOwner());
  Predicate<ImageInfo> filter=Predicates.and(privilegesFilter,rangeFilter);
  List<ImageDetails> imageDetailsList=Transactions.filteredTransform(new ImageInfo(),filter,Images.TO_IMAGE_DETAILS);
  reply.getImagesSet().addAll(imageDetailsList);
  ImageUtil.cleanDeregistered();
  return reply;
}

Fixed version (ground truth):
public DescribeImagesResponseType describe(final DescribeImagesType request) throws EucalyptusCloudException, TransactionException {
  DescribeImagesResponseType reply=request.getReply();
  final Context ctx=Contexts.lookup();
  final String requestAccountId=ctx.getUserFullName().getAccountNumber();
  final List<String> ownersSet=request.getOwnersSet();
  if (ownersSet.remove(Images.SELF)) {
    ownersSet.add(requestAccountId);
  }
  Predicate<ImageInfo> rangeFilter=Predicates.and(CloudMetadatas.filterById(request.getImagesSet()),CloudMetadatas.filterByOwningAccount(request.getOwnersSet()),Images.filterExecutableBy(request.getExecutableBySet()));
  Predicate<ImageInfo> privilegesFilter=Predicates.and(Images.FilterPermissions.INSTANCE,RestrictedTypes.filterPrivilegedWithoutOwner());
  Predicate<ImageInfo> filter=Predicates.and(privilegesFilter,rangeFilter);
  List<ImageDetails> imageDetailsList=Transactions.filteredTransform(new ImageInfo(),filter,Images.TO_IMAGE_DETAILS);
  reply.getImagesSet().addAll(imageDetailsList);
  ImageUtil.cleanDeregistered();
  return reply;
}
Program: 14504
Project: 14504
Buggy source:
public long getNetIoMegs(){
  double duration=(double)(period.getEndingMs() - period.getBeginningMs());
  double gap=0d;
  double result=(double)lastSnapshot.getCumulativeNetworkIoMegs() - (double)firstSnapshot.getCumulativeNetworkIoMegs();
  if (firstSnapshot.getTimestampMs() < period.getBeginningMs()) {
    gap=(double)(period.getBeginningMs() - firstSnapshot.getTimestampMs());
    result*=1d - (gap / duration);
  }
  if (lastSnapshot.getTimestampMs() > period.getEndingMs()) {
    gap=(double)(lastSnapshot.getTimestampMs() - period.getEndingMs());
    result*=1d - (gap / duration);
  }
  return (long)result;
}

Fixed version (ground truth):
public long getNetIoMegs(){
  double duration=(double)(period.getEndingMs() - period.getBeginningMs());
  double gap=0d;
  double result=(double)lastSnapshot.getCumulativeNetworkIoMegs() - (double)firstSnapshot.getCumulativeNetworkIoMegs();
  log.debug("String_Node_Str" + result);
  if (firstSnapshot.getTimestampMs() < period.getBeginningMs()) {
    gap=(double)(period.getBeginningMs() - firstSnapshot.getTimestampMs());
    result*=1d - (gap / duration);
  }
  if (lastSnapshot.getTimestampMs() > period.getEndingMs()) {
    gap=(double)(lastSnapshot.getTimestampMs() - period.getEndingMs());
    result*=1d - (gap / duration);
  }
  log.debug("String_Node_Str" + result);
  return (long)result;
}
Program: 14506
Project: 14506
Buggy source:
public void update(InstanceUsageSnapshot snapshot){
  this.lastSnapshot=snapshot;
}

Fixed version (ground truth):
public void update(InstanceUsageSnapshot snapshot){
  final long timeMs=snapshot.getTimestampMs().longValue();
  if (timeMs > lastSnapshot.getTimestampMs().longValue()) {
    this.lastSnapshot=snapshot;
  }
 else   if (timeMs < firstSnapshot.getTimestampMs().longValue()) {
    this.firstSnapshot=snapshot;
  }
}
Program: 14507
Project: 14507
Buggy source:
public long getDiskIoMegs(){
  double duration=(double)(period.getEndingMs() - period.getBeginningMs());
  double gap=0d;
  double result=(double)lastSnapshot.getCumulativeDiskIoMegs() - (double)firstSnapshot.getCumulativeDiskIoMegs();
  if (firstSnapshot.getTimestampMs() < period.getBeginningMs()) {
    gap=(double)(period.getBeginningMs() - firstSnapshot.getTimestampMs());
    result*=1d - (gap / duration);
  }
  if (lastSnapshot.getTimestampMs() > period.getEndingMs()) {
    gap=(double)(lastSnapshot.getTimestampMs() - period.getEndingMs());
    result*=1d - (gap / duration);
  }
  return (long)result;
}

Fixed version (ground truth):
public long getDiskIoMegs(){
  double duration=(double)(period.getEndingMs() - period.getBeginningMs());
  double gap=0d;
  double result=(double)lastSnapshot.getCumulativeDiskIoMegs() - (double)firstSnapshot.getCumulativeDiskIoMegs();
  log.debug("String_Node_Str" + result);
  if (firstSnapshot.getTimestampMs() < period.getBeginningMs()) {
    gap=(double)(period.getBeginningMs() - firstSnapshot.getTimestampMs());
    result*=1d - (gap / duration);
  }
  if (lastSnapshot.getTimestampMs() > period.getEndingMs()) {
    gap=(double)(lastSnapshot.getTimestampMs() - period.getEndingMs());
    result*=1d - (gap / duration);
  }
  log.debug("String_Node_Str" + result);
  return (long)result;
}
Program: 14509
Project: 14509
Buggy source:
public void update(InstanceUsageSnapshot snapshot){
  this.lastSnapshot=snapshot;
}

Fixed version (ground truth):
public void update(InstanceUsageSnapshot snapshot){
  final long timeMs=snapshot.getTimestampMs().longValue();
  if (timeMs > lastSnapshot.getTimestampMs().longValue()) {
    this.lastSnapshot=snapshot;
  }
 else   if (timeMs < firstSnapshot.getTimestampMs().longValue()) {
    this.firstSnapshot=snapshot;
  }
}