Program: 14938
Project: 14938
Buggy source:
public PutObjectInlineResponseType putObjectInline(PutObjectInlineType request) throws EucalyptusCloudException {
  PutObjectInlineResponseType reply=(PutObjectInlineResponseType)request.getReply();
  Context ctx=Contexts.lookup();
  Account account=ctx.getAccount();
  String bucketName=request.getBucket();
  String objectKey=request.getKey();
  String md5="String_Node_Str";
  Long oldBucketSize=0L;
  Date lastModified;
  AccessControlListType accessControlList=request.getAccessControlList();
  if (accessControlList == null) {
    accessControlList=new AccessControlListType();
  }
  EntityWrapper<BucketInfo> db=EntityWrapper.get(BucketInfo.class);
  BucketInfo bucketInfo=new BucketInfo(bucketName);
  List<BucketInfo> bucketList=db.query(bucketInfo);
  if (bucketList.size() > 0) {
    BucketInfo bucket=bucketList.get(0);
    BucketLogData logData=bucket.getLoggingEnabled() ? request.getLogData() : null;
    long objSize=0;
    try {
      objSize=Long.valueOf(request.getContentLength());
    }
 catch (    NumberFormatException e) {
      LOG.error("String_Node_Str" + request.getContentLength());
      objSize=1L;
    }
    if (ctx.hasAdministrativePrivileges() || (bucket.canWrite(account.getAccountNumber()) && Lookups.checkPrivilege(PolicySpec.S3_PUTOBJECT,PolicySpec.VENDOR_S3,PolicySpec.S3_RESOURCE_BUCKET,bucketName,bucket.getOwnerId()))) {
      EntityWrapper<ObjectInfo> dbObject=db.recast(ObjectInfo.class);
      ObjectInfo searchObjectInfo=new ObjectInfo();
      searchObjectInfo.setBucketName(bucketName);
      ObjectInfo foundObject=null;
      List<ObjectInfo> objectInfos=dbObject.query(searchObjectInfo);
      for (      ObjectInfo objectInfo : objectInfos) {
        if (objectInfo.getObjectKey().equals(objectKey)) {
          if (!objectInfo.canWrite(account.getAccountNumber())) {
            db.rollback();
            throw new AccessDeniedException("String_Node_Str",objectKey,logData);
          }
          foundObject=objectInfo;
          oldBucketSize=-foundObject.getSize();
          break;
        }
      }
      String objectName;
      if (foundObject == null) {
        foundObject=new ObjectInfo(bucketName,objectKey);
        foundObject.setOwnerId(account.getAccountNumber());
        List<GrantInfo> grantInfos=new ArrayList<GrantInfo>();
        foundObject.addGrants(account.getAccountNumber(),grantInfos,accessControlList);
        foundObject.setGrants(grantInfos);
        objectName=UUID.randomUUID().toString();
        foundObject.setObjectName(objectName);
        dbObject.add(foundObject);
      }
 else {
        if (ctx.hasAdministrativePrivileges() || foundObject.canWriteACP(account.getAccountNumber())) {
          List<GrantInfo> grantInfos=foundObject.getGrants();
          foundObject.addGrants(account.getAccountNumber(),grantInfos,accessControlList);
        }
        objectName=foundObject.getObjectName();
      }
      foundObject.setObjectKey(objectKey);
      try {
        if (request.getBase64Data().getBytes().length > WalrusProperties.MAX_INLINE_DATA_SIZE) {
          db.rollback();
          throw new InlineDataTooLargeException(bucketName + "String_Node_Str" + objectKey);
        }
        byte[] base64Data=Hashes.base64decode(request.getBase64Data()).getBytes();
        foundObject.setObjectName(objectName);
        try {
          FileIO fileIO=storageManager.prepareForWrite(bucketName,objectName);
          if (fileIO != null) {
            fileIO.write(base64Data);
            fileIO.finish();
          }
        }
 catch (        Exception ex) {
          db.rollback();
          throw new EucalyptusCloudException(ex);
        }
        md5=Hashes.getHexString(Digest.MD5.get().digest(base64Data));
        foundObject.setEtag(md5);
        Long size=(long)base64Data.length;
        foundObject.setSize(size);
        if (WalrusProperties.shouldEnforceUsageLimits && !Contexts.lookup().hasAdministrativePrivileges()) {
          Long bucketSize=bucket.getBucketSize();
          long newSize=bucketSize + oldBucketSize + size;
          if (newSize > (WalrusInfo.getWalrusInfo().getStorageMaxBucketSizeInMB() * WalrusProperties.M)) {
            db.rollback();
            throw new EntityTooLargeException("String_Node_Str",objectKey,logData);
          }
          bucket.setBucketSize(newSize);
        }
        if (Permissions.canAllocate(PolicySpec.VENDOR_S3,PolicySpec.S3_RESOURCE_BUCKET,bucketName,PolicySpec.S3_PUTOBJECT,ctx.getUser(),size) && !ctx.hasAdministrativePrivileges()) {
          db.rollback();
          LOG.error("String_Node_Str");
          throw new EntityTooLargeException("String_Node_Str",objectKey,logData);
        }
        if (WalrusProperties.trackUsageStatistics) {
          walrusStatistics.updateBytesIn(size);
          walrusStatistics.updateSpaceUsed(size);
        }
        if (request.getMetaData() != null)         foundObject.replaceMetaData(request.getMetaData());
        foundObject.setStorageClass("String_Node_Str");
        lastModified=new Date();
        foundObject.setLastModified(lastModified);
        if (logData != null) {
          updateLogData(bucket,logData);
          logData.setObjectSize(size);
          reply.setLogData(logData);
        }
        QueueSender queueSender=QueueFactory.getInstance().getSender(QueueIdentifier.S3);
        queueSender.send(new S3Event(true,size / WalrusProperties.M,ctx.getUser().getUserId(),ctx.getUser().getName(),ctx.getAccount().getAccountNumber(),ctx.getAccount().getName()));
      }
 catch (      Exception ex) {
        LOG.error(ex);
        db.rollback();
        throw new EucalyptusCloudException(bucketName);
      }
    }
 else {
      db.rollback();
      throw new AccessDeniedException("String_Node_Str",bucketName,logData);
    }
  }
 else {
    db.rollback();
    throw new NoSuchBucketException(bucketName);
  }
  db.commit();
  reply.setEtag(md5);
  reply.setLastModified(DateUtils.format(lastModified.getTime(),DateUtils.ISO8601_DATETIME_PATTERN) + "String_Node_Str");
  return reply;
}

Fixed version (ground truth):
public PutObjectInlineResponseType putObjectInline(PutObjectInlineType request) throws EucalyptusCloudException {
  PutObjectInlineResponseType reply=(PutObjectInlineResponseType)request.getReply();
  Context ctx=Contexts.lookup();
  Account account=ctx.getAccount();
  String bucketName=request.getBucket();
  String objectKey=request.getKey();
  String md5="String_Node_Str";
  Long oldBucketSize=0L;
  Date lastModified;
  AccessControlListType accessControlList=request.getAccessControlList();
  if (accessControlList == null) {
    accessControlList=new AccessControlListType();
  }
  EntityWrapper<BucketInfo> db=EntityWrapper.get(BucketInfo.class);
  BucketInfo bucketInfo=new BucketInfo(bucketName);
  List<BucketInfo> bucketList=db.query(bucketInfo);
  if (bucketList.size() > 0) {
    BucketInfo bucket=bucketList.get(0);
    BucketLogData logData=bucket.getLoggingEnabled() ? request.getLogData() : null;
    long objSize=0;
    try {
      objSize=Long.valueOf(request.getContentLength());
    }
 catch (    NumberFormatException e) {
      LOG.error("String_Node_Str" + request.getContentLength());
      objSize=1L;
    }
    if (ctx.hasAdministrativePrivileges() || (bucket.canWrite(account.getAccountNumber()) && Lookups.checkPrivilege(PolicySpec.S3_PUTOBJECT,PolicySpec.VENDOR_S3,PolicySpec.S3_RESOURCE_BUCKET,bucketName,bucket.getOwnerId()))) {
      EntityWrapper<ObjectInfo> dbObject=db.recast(ObjectInfo.class);
      ObjectInfo searchObjectInfo=new ObjectInfo();
      searchObjectInfo.setBucketName(bucketName);
      ObjectInfo foundObject=null;
      List<ObjectInfo> objectInfos=dbObject.query(searchObjectInfo);
      for (      ObjectInfo objectInfo : objectInfos) {
        if (objectInfo.getObjectKey().equals(objectKey)) {
          if (!objectInfo.canWrite(account.getAccountNumber())) {
            db.rollback();
            throw new AccessDeniedException("String_Node_Str",objectKey,logData);
          }
          foundObject=objectInfo;
          oldBucketSize=-foundObject.getSize();
          break;
        }
      }
      String objectName;
      if (foundObject == null) {
        foundObject=new ObjectInfo(bucketName,objectKey);
        foundObject.setOwnerId(account.getAccountNumber());
        List<GrantInfo> grantInfos=new ArrayList<GrantInfo>();
        foundObject.addGrants(account.getAccountNumber(),grantInfos,accessControlList);
        foundObject.setGrants(grantInfos);
        objectName=UUID.randomUUID().toString();
        foundObject.setObjectName(objectName);
        dbObject.add(foundObject);
      }
 else {
        if (ctx.hasAdministrativePrivileges() || foundObject.canWriteACP(account.getAccountNumber())) {
          List<GrantInfo> grantInfos=foundObject.getGrants();
          foundObject.addGrants(account.getAccountNumber(),grantInfos,accessControlList);
        }
        objectName=foundObject.getObjectName();
      }
      foundObject.setObjectKey(objectKey);
      try {
        if (request.getBase64Data().getBytes().length > WalrusProperties.MAX_INLINE_DATA_SIZE) {
          db.rollback();
          throw new InlineDataTooLargeException(bucketName + "String_Node_Str" + objectKey);
        }
        byte[] base64Data=Hashes.base64decode(request.getBase64Data()).getBytes();
        foundObject.setObjectName(objectName);
        try {
          FileIO fileIO=storageManager.prepareForWrite(bucketName,objectName);
          if (fileIO != null) {
            fileIO.write(base64Data);
            fileIO.finish();
          }
        }
 catch (        Exception ex) {
          db.rollback();
          throw new EucalyptusCloudException(ex);
        }
        md5=Hashes.getHexString(Digest.MD5.get().digest(base64Data));
        foundObject.setEtag(md5);
        Long size=(long)base64Data.length;
        foundObject.setSize(size);
        boolean success=false;
        int retryCount=0;
        do {
          try {
            incrementBucketSize(bucketName,objectKey,oldBucketSize,size);
            success=true;
          }
 catch (          EntityTooLargeException ex) {
            db.rollback();
            throw ex;
          }
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));
        if (Permissions.canAllocate(PolicySpec.VENDOR_S3,PolicySpec.S3_RESOURCE_BUCKET,bucketName,PolicySpec.S3_PUTOBJECT,ctx.getUser(),size) && !ctx.hasAdministrativePrivileges()) {
          db.rollback();
          LOG.error("String_Node_Str");
          throw new EntityTooLargeException("String_Node_Str",objectKey,logData);
        }
        if (WalrusProperties.trackUsageStatistics) {
          walrusStatistics.updateBytesIn(size);
          walrusStatistics.updateSpaceUsed(size);
        }
        if (request.getMetaData() != null)         foundObject.replaceMetaData(request.getMetaData());
        foundObject.setStorageClass("String_Node_Str");
        lastModified=new Date();
        foundObject.setLastModified(lastModified);
        if (logData != null) {
          updateLogData(bucket,logData);
          logData.setObjectSize(size);
          reply.setLogData(logData);
        }
        QueueSender queueSender=QueueFactory.getInstance().getSender(QueueIdentifier.S3);
        queueSender.send(new S3Event(true,size / WalrusProperties.M,ctx.getUser().getUserId(),ctx.getUser().getName(),ctx.getAccount().getAccountNumber(),ctx.getAccount().getName()));
      }
 catch (      Exception ex) {
        LOG.error(ex);
        db.rollback();
        throw new EucalyptusCloudException(bucketName);
      }
    }
 else {
      db.rollback();
      throw new AccessDeniedException("String_Node_Str",bucketName,logData);
    }
  }
 else {
    db.rollback();
    throw new NoSuchBucketException(bucketName);
  }
  db.commit();
  reply.setEtag(md5);
  reply.setLastModified(DateUtils.format(lastModified.getTime(),DateUtils.ISO8601_DATETIME_PATTERN) + "String_Node_Str");
  return reply;
}