Program: 15350
Project: 15350
Buggy source:
public static ImageInfo createFromDeviceMapping(UserFullName userFullName,String rootDeviceName,final List<BlockDeviceMappingItemType> blockDeviceMappings) throws EucalyptusCloudException {
  Context ctx=Contexts.lookup();
  BlockDeviceMappingItemType rootBlockDevice=Iterables.find(blockDeviceMappings,findEbsRoot(rootDeviceName));
  String snapshotId=rootBlockDevice.getEbs().getSnapshotId();
  try {
    Snapshot snap=Snapshots.lookup(userFullName,snapshotId);
    if (!userFullName.getUserId().equals(snap.getOwnerUserId())) {
      throw new EucalyptusCloudException("String_Node_Str" + rootBlockDevice + "String_Node_Str");
    }
    Integer snapVolumeSize=snap.getVolumeSize();
    Integer suppliedVolumeSize=(rootBlockDevice.getEbs().getVolumeSize() != null) ? rootBlockDevice.getEbs().getVolumeSize() : -1;
    suppliedVolumeSize=(suppliedVolumeSize == null) ? rootBlockDevice.getSize() : suppliedVolumeSize;
    Integer targetVolumeSize=(snapVolumeSize <= suppliedVolumeSize) ? suppliedVolumeSize : snapVolumeSize;
    Boolean targetDeleteOnTermination=Boolean.TRUE.equals(rootBlockDevice.getEbs().getDeleteOnTermination());
    BlockStorageImageInfo ret=new BlockStorageImageInfo(generateImageId(Image.Type.machine.getTypePrefix(),snapshotId),snap.getDisplayName(),targetVolumeSize,targetDeleteOnTermination);
    ret=Transactions.save(ret,new Callback<BlockStorageImageInfo>(){
      @Override public void fire(      BlockStorageImageInfo t){
        t.getDeviceMappings().addAll(Lists.transform(blockDeviceMappings,Images.deviceMappingGenerator(t)));
      }
    }
);
    return ret;
  }
 catch (  TransactionFireException ex) {
    throw new EucalyptusCloudException("String_Node_Str" + rootBlockDevice + "String_Node_Str"+ ex.getMessage());
  }
catch (  ExecutionException ex) {
    LOG.error(ex,ex);
    throw new EucalyptusCloudException("String_Node_Str" + rootBlockDevice + "String_Node_Str"+ ex.getMessage());
  }
}

Fixed version (ground truth):
public static ImageInfo createFromDeviceMapping(UserFullName userFullName,String imageName,String imageDescription,Image.Architecture imageArch,Image.Platform imagePlatform,String rootDeviceName,final List<BlockDeviceMappingItemType> blockDeviceMappings) throws EucalyptusCloudException {
  Context ctx=Contexts.lookup();
  BlockDeviceMappingItemType rootBlockDevice=Iterables.find(blockDeviceMappings,findEbsRoot(rootDeviceName));
  String snapshotId=rootBlockDevice.getEbs().getSnapshotId();
  try {
    Snapshot snap=Snapshots.lookup(userFullName,snapshotId);
    if (!userFullName.getUserId().equals(snap.getOwnerUserId())) {
      throw new EucalyptusCloudException("String_Node_Str" + rootBlockDevice + "String_Node_Str");
    }
    Integer snapVolumeSize=snap.getVolumeSize();
    Integer suppliedVolumeSize=(rootBlockDevice.getEbs().getVolumeSize() != null) ? rootBlockDevice.getEbs().getVolumeSize() : -1;
    suppliedVolumeSize=(suppliedVolumeSize == null) ? rootBlockDevice.getSize() : suppliedVolumeSize;
    Integer targetVolumeSizeGB=(snapVolumeSize <= suppliedVolumeSize) ? suppliedVolumeSize : snapVolumeSize;
    Long imageSizeKB=targetVolumeSizeGB * 1024l * 1024l;
    Boolean targetDeleteOnTermination=Boolean.TRUE.equals(rootBlockDevice.getEbs().getDeleteOnTermination());
    String imageId=generateImageId(Image.Type.machine.getTypePrefix(),snapshotId);
    BlockStorageImageInfo ret=new BlockStorageImageInfo(userFullName,imageId,imageName,imageDescription,imageSizeKB,imageArch,imagePlatform,snap.getDisplayName(),targetDeleteOnTermination);
    ret=Transactions.save(ret,new Callback<BlockStorageImageInfo>(){
      @Override public void fire(      BlockStorageImageInfo t){
        t.getDeviceMappings().addAll(Lists.transform(blockDeviceMappings,Images.deviceMappingGenerator(t)));
      }
    }
);
    return ret;
  }
 catch (  TransactionFireException ex) {
    throw new EucalyptusCloudException("String_Node_Str" + rootBlockDevice + "String_Node_Str"+ ex.getMessage());
  }
catch (  ExecutionException ex) {
    LOG.error(ex,ex);
    throw new EucalyptusCloudException("String_Node_Str" + rootBlockDevice + "String_Node_Str"+ ex.getMessage());
  }
}