Program: 113340
Project: 113340
Buggy source:
@Override public void startRequest(MRCRequest rq) throws Throwable {
  if (master.getReplMasterUUID() != null && !master.getReplMasterUUID().equals(master.getConfig().getUUID().toString()))   throw new DatabaseException(ExceptionType.REDIRECT);
  final xtreemfs_clear_vouchersRequest cvRequest=(xtreemfs_clear_vouchersRequest)rq.getRequestArgs();
  Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + cvRequest.toString());
  Capability cap=new Capability(cvRequest.getCreds().getXcap(),master.getConfig().getCapabilitySecret());
  Set<Long> expireTimeSet=new HashSet<Long>(cvRequest.getExpireTimeMsList());
  List<OSDFinalizeVouchersResponse> osdFinalizeVouchersResponseList=cvRequest.getOsdFinalizeVouchersResponseList();
  if (!cap.hasValidSignature())   throw new UserException(POSIXErrno.POSIX_ERROR_EPERM,cap + "String_Node_Str");
  if (cap.hasExpired())   throw new UserException(POSIXErrno.POSIX_ERROR_EPERM,cap + "String_Node_Str");
  StripingPolicy sp=cvRequest.getCreds().getXlocs().getReplicasList().get(0).getStripingPolicy();
  if (osdFinalizeVouchersResponseList.size() != sp.getWidth()) {
    throw new UserException(POSIXErrno.POSIX_ERROR_EINVAL,cvRequest + "String_Node_Str");
  }
  expireTimeSet.add(cap.getExpireMs());
  FinalizeVoucherResponseHelper responseHelper=new FinalizeVoucherResponseHelper(master.getConfig().getCapabilitySecret());
  long newFileSizeMax=-1;
  long truncateEpoch=-1;
  for (  OSDFinalizeVouchersResponse osdFinalizeVouchersResponse : osdFinalizeVouchersResponseList) {
    boolean valid=responseHelper.validateSignature(osdFinalizeVouchersResponse,expireTimeSet);
    if (!valid) {
      throw new UserException(POSIXErrno.POSIX_ERROR_EINVAL,osdFinalizeVouchersResponse + "String_Node_Str");
    }
    if (truncateEpoch == -1) {
      osdFinalizeVouchersResponse.getTruncateEpoch();
    }
 else     if (truncateEpoch != osdFinalizeVouchersResponse.getTruncateEpoch()) {
      throw new UserException(POSIXErrno.POSIX_ERROR_EINVAL,osdFinalizeVouchersResponse + "String_Node_Str" + truncateEpoch);
    }
    if (osdFinalizeVouchersResponse.getSizeInBytes() > newFileSizeMax) {
      newFileSizeMax=osdFinalizeVouchersResponse.getSizeInBytes();
    }
  }
  if (newFileSizeMax == -1) {
    throw new UserException(POSIXErrno.POSIX_ERROR_EINVAL,"String_Node_Str");
  }
  GlobalFileIdResolver globalFileIdResolver=new GlobalFileIdResolver(cap.getFileId());
  StorageManager sMan=master.getVolumeManager().getStorageManager(globalFileIdResolver.getVolumeId());
  AtomicDBUpdate update=sMan.createAtomicDBUpdate(master,rq);
  FileMetadata metadata=sMan.getMetadata(globalFileIdResolver.getLocalFileId());
  QuotaFileInformation quotaFileInformation=new QuotaFileInformation(globalFileIdResolver.getVolumeId(),metadata);
  master.getMrcVoucherManager().clearVouchers(quotaFileInformation,cap.getClientIdentity(),expireTimeSet,newFileSizeMax,update);
  rq.setResponse(emptyResponse.getDefaultInstance());
  update.execute();
}

Fixed version (ground truth):
@Override public void startRequest(MRCRequest rq) throws Throwable {
  if (master.getReplMasterUUID() != null && !master.getReplMasterUUID().equals(master.getConfig().getUUID().toString()))   throw new DatabaseException(ExceptionType.REDIRECT);
  final xtreemfs_clear_vouchersRequest cvRequest=(xtreemfs_clear_vouchersRequest)rq.getRequestArgs();
  Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + cvRequest.toString());
  Capability cap=new Capability(cvRequest.getCreds().getXcap(),master.getConfig().getCapabilitySecret());
  Set<Long> expireTimeSet=new HashSet<Long>(cvRequest.getExpireTimeMsList());
  List<OSDFinalizeVouchersResponse> osdFinalizeVouchersResponseList=cvRequest.getOsdFinalizeVouchersResponseList();
  if (!cap.hasValidSignature())   throw new UserException(POSIXErrno.POSIX_ERROR_EPERM,cap + "String_Node_Str");
  if (cap.hasExpired())   throw new UserException(POSIXErrno.POSIX_ERROR_EPERM,cap + "String_Node_Str");
  StripingPolicy sp=cvRequest.getCreds().getXlocs().getReplicasList().get(0).getStripingPolicy();
  if (osdFinalizeVouchersResponseList.size() != sp.getWidth()) {
    throw new UserException(POSIXErrno.POSIX_ERROR_EINVAL,cvRequest + "String_Node_Str");
  }
  expireTimeSet.add(cap.getExpireMs());
  FinalizeVoucherResponseHelper responseHelper=new FinalizeVoucherResponseHelper(master.getConfig().getCapabilitySecret());
  long newFileSizeMax=-1;
  long truncateEpoch=-1;
  for (  OSDFinalizeVouchersResponse osdFinalizeVouchersResponse : osdFinalizeVouchersResponseList) {
    boolean valid=responseHelper.validateSignature(osdFinalizeVouchersResponse,expireTimeSet);
    if (!valid) {
      throw new UserException(POSIXErrno.POSIX_ERROR_EINVAL,osdFinalizeVouchersResponse + "String_Node_Str");
    }
    if (truncateEpoch == -1) {
      osdFinalizeVouchersResponse.getTruncateEpoch();
    }
 else     if (truncateEpoch != osdFinalizeVouchersResponse.getTruncateEpoch()) {
      throw new UserException(POSIXErrno.POSIX_ERROR_EINVAL,osdFinalizeVouchersResponse + "String_Node_Str" + truncateEpoch);
    }
    if (osdFinalizeVouchersResponse.getSizeInBytes() > newFileSizeMax) {
      newFileSizeMax=osdFinalizeVouchersResponse.getSizeInBytes();
    }
  }
  if (newFileSizeMax == -1) {
    throw new UserException(POSIXErrno.POSIX_ERROR_EINVAL,"String_Node_Str");
  }
  GlobalFileIdResolver globalFileIdResolver=new GlobalFileIdResolver(cap.getFileId());
  StorageManager sMan=master.getVolumeManager().getStorageManager(globalFileIdResolver.getVolumeId());
  AtomicDBUpdate update=sMan.createAtomicDBUpdate(master,rq);
  FileMetadata metadata=sMan.getMetadata(globalFileIdResolver.getLocalFileId());
  if (metadata != null) {
    QuotaFileInformation quotaFileInformation=new QuotaFileInformation(globalFileIdResolver.getVolumeId(),metadata);
    master.getMrcVoucherManager().clearVouchers(quotaFileInformation,cap.getClientIdentity(),expireTimeSet,newFileSizeMax,update);
  }
  rq.setResponse(emptyResponse.getDefaultInstance());
  update.execute();
}