Buggy code:
@ Inject HypervisorCapabilitiesDao _hypervisorCapabilitiesDao ; @ Inject AsyncJobManager _jobMgr ; @ Inject VmWorkJobDao _workJobDao ; private List < StoragePoolAllocator > _storagePoolAllocators ; VmWorkJobHandlerProxy _jobHandlerProxy = new VmWorkJobHandlerProxy ( this ) ; static final ConfigKey < Long > VmJobCheckInterval = new ConfigKey < Long > ( "Advanced" , Long . class , "vm.job.check.interval" , "3000" , "Interval<seq2seq4repair_space>in<seq2seq4repair_space>milliseconds<seq2seq4repair_space>to<seq2seq4repair_space>check<seq2seq4repair_space>if<seq2seq4repair_space>the<seq2seq4repair_space>job<seq2seq4repair_space>is<seq2seq4repair_space>complete" , false ) ; private long _maxVolumeSizeInGb ; private final StateMachine2 < Volume . State , Volume . Event , Volume > _volStateMachine ; protected VolumeApiServiceImpl ( ) { } @ Override @ DB @ ActionEvent ( eventType = EventTypes . EVENT_VOLUME_UPLOAD , eventDescription = "uploading<seq2seq4repair_space>volume" , async = true ) public VolumeVO uploadVolume ( UploadVolumeCmd cmd ) throws ResourceAllocationException { } @ Override @ ActionEvent ( eventType = EventTypes . EVENT_VOLUME_UPLOAD , eventDescription = "uploading<seq2seq4repair_space>volume<seq2seq4repair_space>for<seq2seq4repair_space>post<seq2seq4repair_space>upload" , async = true ) public GetUploadParamsResponse uploadVolume ( final GetUploadParamsForVolumeCmd cmd ) throws ResourceAllocationException , MalformedURLException { Account caller = CallContext . current ( ) . getCallingAccount ( ) ; long ownerId = cmd . getEntityOwnerId ( ) ; final Account owner = _entityMgr . findById ( Account . class , ownerId ) ; final Long zoneId = cmd . getZoneId ( ) ; final String volumeName = cmd . getName ( ) ; String format = cmd . getFormat ( ) ; final Long diskOfferingId = cmd . getDiskOfferingId ( ) ; String imageStoreUuid = cmd . getImageStoreUuid ( ) ; final DataStore store = _tmpltMgr . getImageStore ( imageStoreUuid , zoneId ) ; validateVolume ( caller , ownerId , zoneId , volumeName , null , format , diskOfferingId ) ; return Transaction . execute ( new com . cloud . utils . db . TransactionCallbackWithException < GetUploadParamsResponse , MalformedURLException > ( ) { @ Override public GetUploadParamsResponse doInTransaction ( TransactionStatus status ) throws MalformedURLException { VolumeVO volume = persistVolume ( owner , zoneId , volumeName , null , cmd . getFormat ( ) , diskOfferingId , NotUploaded ) ; VolumeInfo vol = volFactory . getVolume ( volume . getId ( ) ) ; RegisterVolumePayload payload = new RegisterVolumePayload ( null , cmd . getChecksum ( ) , cmd . getFormat ( ) ) ; vol . addPayload ( payload ) ; Pair < EndPoint , DataObject > pair = volService . registerVolumeForPostUpload ( vol , store ) ; EndPoint ep = pair . first ( ) ; DataObject dataObject = pair . second ( ) ; GetUploadParamsResponse response = new GetUploadParamsResponse ( ) ; String ssvmUrlDomain = _configDao . getValue ( SecStorageSecureCopyCert . key ( ) ) ; String url = ImageStoreUtil . generatePostUploadUrl ( ssvmUrlDomain , ep . getPublicAddr ( ) , vol . getUuid ( ) ) ; response . setPostURL ( new URL ( url ) ) ; VolumeDataStoreVO volumeStore = _volumeStoreDao . findByVolume ( vol . getId ( ) ) ; if ( volumeStore != null ) { volumeStore . setExtractUrl ( url ) ; _volumeStoreDao . persist ( volumeStore ) ; } response . setId ( UUID . fromString ( vol . getUuid ( ) ) ) ; int timeout = ImageStoreUploadMonitorImpl . getUploadOperationTimeout ( ) ; DateTime currentDateTime = new DateTime ( DateTimeZone . UTC ) ; String expires = currentDateTime . plusMinutes ( timeout ) . toString ( ) ; response . setTimeout ( expires ) ; String key = _configDao . getValue ( SSVMPSK . key ( ) ) ; <START_BUG> TemplateOrVolumePostUploadCommand command = new TemplateOrVolumePostUploadCommand ( vol . getId ( ) , vol . getUuid ( ) , volumeStore . getInstallPath ( ) , volumeStore . getChecksum ( ) , vol . getType ( ) . toString ( ) , vol . getName ( ) , vol . getFormat ( ) . toString ( ) , dataObject . getDataStore ( ) . getUri ( ) , dataObject . getDataStore ( ) . getRole ( ) . toString ( ) ) ; <END_BUG> command . setLocalPath ( volumeStore . getLocalDownloadPath ( ) ) ; command . setMaxUploadSize ( _configDao . getValue ( MaxUploadVolumeSize . key ( ) ) ) ; Gson gson = new GsonBuilder ( ) . create ( ) ; String metadata = EncryptionUtil . encodeData ( gson . toJson ( command ) , key ) ; response . setMetadata ( metadata ) ; response . setSignature ( EncryptionUtil . generateSignature ( ( ( metadata + url ) + expires ) , key ) ) ; return response ; } } ) ; } private boolean validateVolume ( Account caller , long ownerId , Long zoneId , String volumeName , String url , String format , Long diskOfferingId ) throws ResourceAllocationException { } public String getRandomVolumeName ( ) { } @ DB protected VolumeVO persistVolume ( final Account owner , final Long zoneId , final String volumeName , final String url , final String format , final Long diskOfferingId , final Volume . State state ) { } @ Override @ DB @ ActionEvent ( eventType = EventTypes . EVENT_VOLUME_CREATE , eventDescription = "creating<seq2seq4repair_space>volume" , create = true ) public VolumeVO allocVolume ( CreateVolumeCmd cmd ) throws ResourceAllocationException { } private VolumeVO commitVolume ( final CreateVolumeCmd cmd , final Account caller , final Account owner , final Boolean displayVolume , final Long zoneId , final Long diskOfferingId , final Storage . ProvisioningType provisioningType , final Long size , final Long minIops , final Long maxIops , final VolumeVO parentVolume , final String userSpecifiedName , final String uuid ) { } public boolean validateVolumeSizeRange ( long size ) { } @ Override @ DB @ ActionEvent ( eventType = EventTypes . EVENT_VOLUME_CREATE , eventDescription = "creating<seq2seq4repair_space>volume" , async = true ) public VolumeVO createVolume ( CreateVolumeCmd cmd ) { } protected VolumeVO createVolumeFromSnapshot ( VolumeVO volume , long snapshotId , Long vmId ) throws StorageUnavailableException { } @ Override @ DB @ ActionEvent ( eventType = EventTypes . EVENT_VOLUME_RESIZE , eventDescription = "resizing<seq2seq4repair_space>volume" , async = true ) public VolumeVO resizeVolume ( ResizeVolumeCmd cmd ) throws ResourceAllocationException { }

Fix:
TemplateOrVolumePostUploadCommand command = new TemplateOrVolumePostUploadCommand ( vol . getId ( ) , vol . getUuid ( ) , volumeStore . getInstallPath ( ) , cmd . getChecksum ( ) , vol . getType ( ) . toString ( ) , vol . getName ( ) , vol . getFormat ( ) . toString ( ) , dataObject . getDataStore ( ) . getUri ( ) , dataObject . getDataStore ( ) . getRole ( ) . toString ( ) ) ;