Program: 113338
Project: 113338
Buggy source:
/** 
 * Gets all quota information, applies the default user and group quota and saves them, if it has to.
 * @param quotaFileInformation
 * @param saveAppliedDefaultQuota
 * @param update
 * @return
 * @throws UserException
 */
private QuotaInformation getAndApplyQuotaInformation(QuotaFileInformation quotaFileInformation,boolean saveAppliedDefaultQuota,AtomicDBUpdate update) throws UserException {
  QuotaInformation quotaInformation=null;
  try {
    boolean userQuotaDefined=false, groupQuotaDefined=false;
    String ownerId=quotaFileInformation.getOwnerId();
    String ownerGroupId=quotaFileInformation.getOwnerGroupId();
    long userQuota=volStorageManager.getUserQuota(ownerId);
    long groupQuota=volStorageManager.getGroupQuota(ownerGroupId);
    quotaInformation=new QuotaInformation(volumeQuota,userQuota,groupQuota);
    long volumeUsedSpace=volStorageManager.getVolumeUsedSpace();
    quotaInformation.setVolumeUsedSpace(volumeUsedSpace);
    if (volumeQuota != QuotaConstants.unlimitedQuota) {
      long volumeBlockedSpace=volStorageManager.getVolumeBlockedSpace();
      quotaInformation.setVolumeBlockedSpace(volumeBlockedSpace);
      long volumeFreeSpace=volumeQuota - (volumeUsedSpace + volumeBlockedSpace);
      if (volumeFreeSpace < quotaInformation.getFreeSpace()) {
        quotaInformation.setFreeSpace(volumeFreeSpace);
        quotaInformation.setQuotaType("String_Node_Str");
      }
    }
    if (userQuota == QuotaConstants.noQuota) {
      userQuota=volumeDefaultUserQuota;
      quotaInformation.setUserQuota(userQuota);
      userQuotaDefined=true;
    }
    long userUsedSpace=volStorageManager.getUserUsedSpace(ownerId);
    quotaInformation.setUserUsedSpace(userUsedSpace);
    if (userQuota != QuotaConstants.unlimitedQuota) {
      long userBlockedSpace=volStorageManager.getUserBlockedSpace(ownerId);
      quotaInformation.setUserBlockedSpace(userBlockedSpace);
      long userFreeSpace=userQuota - (userUsedSpace + userBlockedSpace);
      if (userFreeSpace < quotaInformation.getFreeSpace()) {
        quotaInformation.setFreeSpace(userFreeSpace);
        quotaInformation.setQuotaType("String_Node_Str");
      }
    }
    if (groupQuota == QuotaConstants.noQuota) {
      groupQuota=volumeDefaultGroupQuota;
      quotaInformation.setGroupQuota(groupQuota);
      groupQuotaDefined=true;
    }
    long groupUsedSpace=volStorageManager.getGroupUsedSpace(ownerGroupId);
    quotaInformation.setGroupUsedSpace(groupUsedSpace);
    if (groupQuota != QuotaConstants.unlimitedQuota) {
      long groupBlockedSpace=volStorageManager.getGroupBlockedSpace(ownerGroupId);
      quotaInformation.setGroupBlockedSpace(groupBlockedSpace);
      long groupFreeSpace=groupQuota - (groupUsedSpace + groupBlockedSpace);
      if (groupFreeSpace < quotaInformation.getFreeSpace()) {
        quotaInformation.setFreeSpace(groupFreeSpace);
        quotaInformation.setQuotaType("String_Node_Str");
      }
    }
    if (saveAppliedDefaultQuota) {
      if (userQuota != QuotaConstants.unlimitedQuota && userQuotaDefined) {
        volStorageManager.setUserQuota(ownerId,userQuota,update);
      }
      if (groupQuota != QuotaConstants.unlimitedQuota && groupQuotaDefined) {
        volStorageManager.setGroupQuota(ownerGroupId,groupQuota,update);
      }
    }
  }
 catch (  DatabaseException e) {
    Logging.logError(Logging.LEVEL_ERROR,"String_Node_Str",e);
    throw new UserException(POSIXErrno.POSIX_ERROR_EIO,"String_Node_Str");
  }
  return quotaInformation;
}

Fixed version (ground truth):
/** 
 * Gets all quota information, applies the default user and group quota and saves them, if it has to.
 * @param quotaFileInformation
 * @param saveAppliedDefaultQuota
 * @param update
 * @return
 * @throws UserException
 */
private QuotaInformation getAndApplyQuotaInformation(QuotaFileInformation quotaFileInformation,boolean saveAppliedDefaultQuota,AtomicDBUpdate update) throws UserException {
  QuotaInformation quotaInformation=new QuotaInformation(volumeQuota,0,0);
  quotaInformation=getAndApplyVolumeQuotaInformation(quotaInformation,quotaFileInformation,saveAppliedDefaultQuota,update);
  quotaInformation=getAndApplyUserQuotaInformation(quotaInformation,quotaFileInformation,saveAppliedDefaultQuota,update);
  quotaInformation=getAndApplyGroupQuotaInformation(quotaInformation,quotaFileInformation,saveAppliedDefaultQuota,update);
  return quotaInformation;
}