Program: 14939
Project: 14939
Buggy source:
public DeleteVersionResponseType deleteVersion(DeleteVersionType request) throws EucalyptusCloudException {
  DeleteVersionResponseType reply=(DeleteVersionResponseType)request.getReply();
  String bucketName=request.getBucket();
  String objectKey=request.getKey();
  Context ctx=Contexts.lookup();
  Account account=ctx.getAccount();
  EntityWrapper<BucketInfo> db=EntityWrapper.get(BucketInfo.class);
  BucketInfo bucketInfos=new BucketInfo(bucketName);
  List<BucketInfo> bucketList=db.query(bucketInfos);
  if (bucketList.size() > 0) {
    BucketInfo bucketInfo=bucketList.get(0);
    BucketLogData logData=bucketInfo.getLoggingEnabled() ? request.getLogData() : null;
    ObjectInfo foundObject=null;
    EntityWrapper<ObjectInfo> dbObject=db.recast(ObjectInfo.class);
    ObjectInfo searchObjectInfo=new ObjectInfo(bucketName,objectKey);
    if (request.getVersionid() == null) {
      db.rollback();
      throw new EucalyptusCloudException("String_Node_Str");
    }
    searchObjectInfo.setVersionId(request.getVersionid());
    List<ObjectInfo> objectInfos=dbObject.query(searchObjectInfo);
    if (objectInfos.size() > 0) {
      foundObject=objectInfos.get(0);
    }
    if (foundObject != null) {
      if (ctx.hasAdministrativePrivileges() || (foundObject.canWrite(account.getAccountNumber()) && Lookups.checkPrivilege(PolicySpec.S3_DELETEOBJECTVERSION,PolicySpec.VENDOR_S3,PolicySpec.S3_RESOURCE_OBJECT,PolicySpec.objectFullName(bucketName,objectKey),foundObject.getOwnerId()))) {
        dbObject.delete(foundObject);
        if (!foundObject.getDeleted()) {
          String objectName=foundObject.getObjectName();
          for (          GrantInfo grantInfo : foundObject.getGrants()) {
            db.delete(grantInfo);
          }
          Long size=foundObject.getSize();
          bucketInfo.setBucketSize(bucketInfo.getBucketSize() - size);
          ObjectDeleter objectDeleter=new ObjectDeleter(bucketName,objectName,size,ctx.getUser().getName(),ctx.getUser().getUserId(),ctx.getAccount().getName(),ctx.getAccount().getAccountNumber());
          objectDeleter.start();
        }
        reply.setCode("String_Node_Str");
        reply.setDescription("String_Node_Str");
        if (logData != null) {
          updateLogData(bucketInfo,logData);
          reply.setLogData(logData);
        }
      }
 else {
        db.rollback();
        throw new AccessDeniedException("String_Node_Str",objectKey,logData);
      }
    }
 else {
      db.rollback();
      throw new NoSuchEntityException(objectKey,logData);
    }
  }
 else {
    db.rollback();
    throw new NoSuchBucketException(bucketName);
  }
  db.commit();
  return reply;
}

Fixed version (ground truth):
public DeleteVersionResponseType deleteVersion(DeleteVersionType request) throws EucalyptusCloudException {
  DeleteVersionResponseType reply=(DeleteVersionResponseType)request.getReply();
  String bucketName=request.getBucket();
  String objectKey=request.getKey();
  Context ctx=Contexts.lookup();
  Account account=ctx.getAccount();
  EntityWrapper<BucketInfo> db=EntityWrapper.get(BucketInfo.class);
  BucketInfo bucketInfos=new BucketInfo(bucketName);
  List<BucketInfo> bucketList=db.query(bucketInfos);
  if (bucketList.size() > 0) {
    BucketInfo bucketInfo=bucketList.get(0);
    BucketLogData logData=bucketInfo.getLoggingEnabled() ? request.getLogData() : null;
    ObjectInfo foundObject=null;
    EntityWrapper<ObjectInfo> dbObject=db.recast(ObjectInfo.class);
    ObjectInfo searchObjectInfo=new ObjectInfo(bucketName,objectKey);
    if (request.getVersionid() == null) {
      db.rollback();
      throw new EucalyptusCloudException("String_Node_Str");
    }
    searchObjectInfo.setVersionId(request.getVersionid());
    List<ObjectInfo> objectInfos=dbObject.query(searchObjectInfo);
    if (objectInfos.size() > 0) {
      foundObject=objectInfos.get(0);
    }
    if (foundObject != null) {
      if (ctx.hasAdministrativePrivileges() || (foundObject.canWrite(account.getAccountNumber()) && Lookups.checkPrivilege(PolicySpec.S3_DELETEOBJECTVERSION,PolicySpec.VENDOR_S3,PolicySpec.S3_RESOURCE_OBJECT,PolicySpec.objectFullName(bucketName,objectKey),foundObject.getOwnerId()))) {
        dbObject.delete(foundObject);
        if (!foundObject.getDeleted()) {
          String objectName=foundObject.getObjectName();
          for (          GrantInfo grantInfo : foundObject.getGrants()) {
            db.delete(grantInfo);
          }
          Long size=foundObject.getSize();
          boolean success=false;
          int retryCount=0;
          do {
            try {
              decrementBucketSize(bucketName,size);
              success=true;
            }
 catch (            NoSuchBucketException ex) {
              db.rollback();
              throw ex;
            }
catch (            RollbackException ex) {
              retryCount++;
              LOG.trace("String_Node_Str" + bucketName);
            }
catch (            EucalyptusCloudException ex) {
              db.rollback();
              throw ex;
            }
          }
 while (!success && (retryCount < 5));
          ObjectDeleter objectDeleter=new ObjectDeleter(bucketName,objectName,size,ctx.getUser().getName(),ctx.getUser().getUserId(),ctx.getAccount().getName(),ctx.getAccount().getAccountNumber());
          objectDeleter.start();
        }
        reply.setCode("String_Node_Str");
        reply.setDescription("String_Node_Str");
        if (logData != null) {
          updateLogData(bucketInfo,logData);
          reply.setLogData(logData);
        }
      }
 else {
        db.rollback();
        throw new AccessDeniedException("String_Node_Str",objectKey,logData);
      }
    }
 else {
      db.rollback();
      throw new NoSuchEntityException(objectKey,logData);
    }
  }
 else {
    db.rollback();
    throw new NoSuchBucketException(bucketName);
  }
  db.commit();
  return reply;
}