Program: 14059
Project: 14059
Buggy source:
@Override public CreateStorageSnapshotResponseType CreateStorageSnapshot(CreateStorageSnapshotType request) throws EucalyptusCloudException {
  final long actionStart=System.currentTimeMillis();
  CreateStorageSnapshotResponseType reply=(CreateStorageSnapshotResponseType)request.getReply();
  StorageProperties.updateWalrusUrl();
  if (!StorageProperties.enableSnapshots) {
    LOG.error("String_Node_Str");
    return reply;
  }
  String volumeId=request.getVolumeId();
  LOG.info("String_Node_Str" + volumeId);
  String snapshotId=request.getSnapshotId();
  VolumeInfo sourceVolumeInfo=null;
  try (TransactionResource tran=Entities.transactionFor(VolumeInfo.class)){
    VolumeInfo volumeInfo=new VolumeInfo(volumeId);
    sourceVolumeInfo=Entities.uniqueResult(volumeInfo);
    tran.commit();
  }
 catch (  NoSuchElementException e) {
    LOG.debug("String_Node_Str" + volumeId + "String_Node_Str");
    throw new NoSuchVolumeException(volumeId);
  }
catch (  final Throwable e) {
    LOG.warn("String_Node_Str" + volumeId + "String_Node_Str"+ e.getMessage());
    throw new EucalyptusCloudException("String_Node_Str" + volumeId,e);
  }
  if (sourceVolumeInfo == null) {
    throw new NoSuchVolumeException(volumeId);
  }
 else {
    if (!sourceVolumeInfo.getStatus().equals(StorageProperties.Status.available.toString())) {
      throw new VolumeNotReadyException(volumeId);
    }
 else {
      ThruputMetrics.startOperation(MonitoredAction.CREATE_SNAPSHOT,snapshotId,actionStart);
      if (StorageProperties.shouldEnforceUsageLimits) {
        int maxSize=-1;
        try {
          maxSize=BlockStorageGlobalConfiguration.getInstance().getGlobal_total_snapshot_size_limit_gb();
        }
 catch (        Exception e) {
          LOG.error("String_Node_Str",e);
          throw new EucalyptusCloudException("String_Node_Str",e);
        }
        if (maxSize <= 0) {
          LOG.warn("String_Node_Str");
          throw new EucalyptusCloudException("String_Node_Str");
        }
        if (totalSnapshotSizeLimitExceeded(snapshotId,sourceVolumeInfo.getSize(),maxSize)) {
          LOG.info("String_Node_Str" + snapshotId + "String_Node_Str"+ maxSize+ "String_Node_Str");
          throw new SnapshotTooLargeException(maxSize);
        }
      }
      SnapshotCreator snapshotter=null;
      SnapshotInfo snapshotInfo=new SnapshotInfo(snapshotId);
      try {
        snapshotInfo.setUserName(sourceVolumeInfo.getUserName());
        snapshotInfo.setVolumeId(volumeId);
        snapshotInfo.setProgress("String_Node_Str");
        snapshotInfo.setSizeGb(sourceVolumeInfo.getSize());
        snapshotInfo.setStatus(StorageProperties.Status.creating.toString());
        snapshotInfo.setIsOrigin(Boolean.TRUE);
        String snapPointId=null;
        try {
          if (snapshotPointSemaphore == null) {
            Integer maxConcurrentSnapshots=StorageInfo.getStorageInfo().getMaxConcurrentSnapshots();
            int snapshotPointSemaphorePermits=(maxConcurrentSnapshots == null ? SNAPSHOT_POINT_DEFAULT_CONCURRENCY : maxConcurrentSnapshots);
            snapshotPointSemaphore=EucaSemaphoreDirectory.getSemaphore(SNAPSHOT_POINT_SEMAPHORE_KEY,snapshotPointSemaphorePermits);
            LOG.debug("String_Node_Str" + snapshotPointSemaphorePermits + "String_Node_Str");
          }
          try {
            try {
              snapshotPointSemaphore.acquire();
              LOG.debug("String_Node_Str");
            }
 catch (            InterruptedException ex) {
              throw new EucalyptusCloudException("String_Node_Str" + snapshotId + "String_Node_Str"+ volumeId+ "String_Node_Str");
            }
            snapPointId=blockManager.createSnapshotPoint(volumeId,snapshotId);
          }
  finally {
            LOG.debug("String_Node_Str");
            snapshotPointSemaphore.release();
          }
          snapshotInfo.setStartTime(new Date());
          if (snapPointId == null) {
            LOG.debug("String_Node_Str");
          }
 else {
            snapshotInfo.setSnapPointId(snapPointId);
          }
          snapshotInfo.setStatus(StorageProperties.Status.creating.toString());
          try (TransactionResource tran=Entities.transactionFor(SnapshotInfo.class)){
            Entities.persist(snapshotInfo);
            tran.commit();
          }
 catch (          Exception e) {
            LOG.warn("String_Node_Str" + snapshotId,e);
            throw e;
          }
          Context ctx=null;
          try {
            ctx=Contexts.lookup(request.getCorrelationId());
            if (!ctx.getChannel().isOpen()) {
              throw new NoSuchContextException("String_Node_Str");
            }
          }
 catch (          NoSuchContextException e) {
            if (snapPointId != null) {
              throw new EucalyptusCloudException("String_Node_Str");
            }
          }
        }
 catch (        EucalyptusCloudException e) {
          try {
            blockManager.deleteSnapshotPoint(volumeId,snapshotId,snapPointId);
          }
 catch (          Exception ex) {
            LOG.error("String_Node_Str" + snapshotId + "String_Node_Str"+ e.getMessage());
          }
          LOG.error("String_Node_Str" + snapshotId + "String_Node_Str"+ e.getMessage());
          throw e;
        }
        snapshotter=new SnapshotCreator(volumeId,snapshotId,snapPointId,blockManager);
        reply.setSnapshotId(snapshotId);
        reply.setVolumeId(volumeId);
        reply.setStartTime(DateUtils.format(snapshotInfo.getStartTime().getTime(),DateUtils.ISO8601_DATETIME_PATTERN) + "String_Node_Str");
        reply.setProgress(snapshotInfo.getProgress());
      }
 catch (      EucalyptusCloudException cloudEx) {
        snapshotInfo.setStatus(StorageProperties.Status.failed.toString());
        markSnapshotFailed(snapshotId);
        LOG.error("String_Node_Str" + snapshotId + "String_Node_Str",cloudEx);
        throw cloudEx;
      }
catch (      final Throwable e) {
        snapshotInfo.setStatus(StorageProperties.Status.failed.toString());
        markSnapshotFailed(snapshotId);
        LOG.error("String_Node_Str" + snapshotId + "String_Node_Str",e);
        throw new EucalyptusCloudException("String_Node_Str" + snapshotId + "String_Node_Str",e);
      }
      reply.setStatus(snapshotInfo.getStatus());
      if (snapshotter != null) {
        try {
          SnapshotThreadPool.add(snapshotter);
        }
 catch (        Exception e) {
          LOG.warn("String_Node_Str" + snapshotId + "String_Node_Str",e);
          markSnapshotFailed(snapshotId);
          throw new EucalyptusCloudException("String_Node_Str" + snapshotId + "String_Node_Str",e);
        }
      }
    }
  }
  return reply;
}

Fixed version (ground truth):
@Override public CreateStorageSnapshotResponseType CreateStorageSnapshot(CreateStorageSnapshotType request) throws EucalyptusCloudException {
  final long actionStart=System.currentTimeMillis();
  CreateStorageSnapshotResponseType reply=(CreateStorageSnapshotResponseType)request.getReply();
  StorageProperties.updateWalrusUrl();
  if (!StorageProperties.enableSnapshots) {
    LOG.error("String_Node_Str");
    return reply;
  }
  String volumeId=request.getVolumeId();
  LOG.info("String_Node_Str" + volumeId);
  String snapshotId=request.getSnapshotId();
  VolumeInfo sourceVolumeInfo=null;
  try (TransactionResource tran=Entities.transactionFor(VolumeInfo.class)){
    VolumeInfo volumeInfo=new VolumeInfo(volumeId);
    sourceVolumeInfo=Entities.uniqueResult(volumeInfo);
    tran.commit();
  }
 catch (  NoSuchElementException e) {
    LOG.debug("String_Node_Str" + volumeId + "String_Node_Str");
    throw new NoSuchVolumeException(volumeId);
  }
catch (  final Throwable e) {
    LOG.warn("String_Node_Str" + volumeId + "String_Node_Str"+ e.getMessage());
    throw new EucalyptusCloudException("String_Node_Str" + volumeId,e);
  }
  if (sourceVolumeInfo == null) {
    throw new NoSuchVolumeException(volumeId);
  }
 else {
    if (!sourceVolumeInfo.getStatus().equals(StorageProperties.Status.available.toString())) {
      throw new VolumeNotReadyException(volumeId);
    }
 else {
      ThruputMetrics.startOperation(MonitoredAction.CREATE_SNAPSHOT,snapshotId,actionStart);
      if (StorageProperties.shouldEnforceUsageLimits) {
        int maxSize=-1;
        try {
          maxSize=BlockStorageGlobalConfiguration.getInstance().getGlobal_total_snapshot_size_limit_gb();
        }
 catch (        Exception e) {
          LOG.error("String_Node_Str",e);
          throw new EucalyptusCloudException("String_Node_Str",e);
        }
        if (maxSize <= 0) {
          LOG.warn("String_Node_Str");
          throw new EucalyptusCloudException("String_Node_Str");
        }
        if (totalSnapshotSizeLimitExceeded(snapshotId,sourceVolumeInfo.getSize(),maxSize)) {
          LOG.info("String_Node_Str" + snapshotId + "String_Node_Str"+ maxSize+ "String_Node_Str");
          throw new SnapshotTooLargeException(maxSize);
        }
      }
      SnapshotCreator snapshotter=null;
      SnapshotInfo snapshotInfo=new SnapshotInfo(snapshotId);
      try {
        snapshotInfo.setUserName(sourceVolumeInfo.getUserName());
        snapshotInfo.setVolumeId(volumeId);
        snapshotInfo.setProgress("String_Node_Str");
        snapshotInfo.setSizeGb(sourceVolumeInfo.getSize());
        snapshotInfo.setStatus(StorageProperties.Status.creating.toString());
        snapshotInfo.setIsOrigin(Boolean.TRUE);
        String snapPointId=null;
        try {
          try {
            snapshotPointSemaphoreSupplier.get().acquire();
            LOG.trace("String_Node_Str" + snapshotPointSemaphoreSupplier.get().availablePermits());
          }
 catch (          InterruptedException ex) {
            throw new EucalyptusCloudException("String_Node_Str" + snapshotId + "String_Node_Str"+ volumeId+ "String_Node_Str");
          }
          try {
            snapPointId=blockManager.createSnapshotPoint(volumeId,snapshotId);
          }
  finally {
            LOG.trace("String_Node_Str");
            snapshotPointSemaphoreSupplier.get().release();
          }
          snapshotInfo.setStartTime(new Date());
          if (snapPointId == null) {
            LOG.debug("String_Node_Str");
          }
 else {
            snapshotInfo.setSnapPointId(snapPointId);
          }
          snapshotInfo.setStatus(StorageProperties.Status.creating.toString());
          try (TransactionResource tran=Entities.transactionFor(SnapshotInfo.class)){
            Entities.persist(snapshotInfo);
            tran.commit();
          }
 catch (          Exception e) {
            LOG.warn("String_Node_Str" + snapshotId,e);
            throw e;
          }
          Context ctx=null;
          try {
            ctx=Contexts.lookup(request.getCorrelationId());
            if (!ctx.getChannel().isOpen()) {
              throw new NoSuchContextException("String_Node_Str");
            }
          }
 catch (          NoSuchContextException e) {
            if (snapPointId != null) {
              throw new EucalyptusCloudException("String_Node_Str");
            }
          }
        }
 catch (        EucalyptusCloudException e) {
          try {
            blockManager.deleteSnapshotPoint(volumeId,snapshotId,snapPointId);
          }
 catch (          Exception ex) {
            LOG.error("String_Node_Str" + snapshotId + "String_Node_Str"+ e.getMessage());
          }
          LOG.error("String_Node_Str" + snapshotId + "String_Node_Str"+ e.getMessage());
          throw e;
        }
        snapshotter=new SnapshotCreator(volumeId,snapshotId,snapPointId,blockManager);
        reply.setSnapshotId(snapshotId);
        reply.setVolumeId(volumeId);
        reply.setStartTime(DateUtils.format(snapshotInfo.getStartTime().getTime(),DateUtils.ISO8601_DATETIME_PATTERN) + "String_Node_Str");
        reply.setProgress(snapshotInfo.getProgress());
      }
 catch (      EucalyptusCloudException cloudEx) {
        snapshotInfo.setStatus(StorageProperties.Status.failed.toString());
        markSnapshotFailed(snapshotId);
        LOG.error("String_Node_Str" + snapshotId + "String_Node_Str",cloudEx);
        throw cloudEx;
      }
catch (      final Throwable e) {
        snapshotInfo.setStatus(StorageProperties.Status.failed.toString());
        markSnapshotFailed(snapshotId);
        LOG.error("String_Node_Str" + snapshotId + "String_Node_Str",e);
        throw new EucalyptusCloudException("String_Node_Str" + snapshotId + "String_Node_Str",e);
      }
      reply.setStatus(snapshotInfo.getStatus());
      if (snapshotter != null) {
        try {
          SnapshotThreadPool.add(snapshotter);
        }
 catch (        Exception e) {
          LOG.warn("String_Node_Str" + snapshotId + "String_Node_Str",e);
          markSnapshotFailed(snapshotId);
          throw new EucalyptusCloudException("String_Node_Str" + snapshotId + "String_Node_Str",e);
        }
      }
    }
  }
  return reply;
}