atrocitytheme commented on a change in pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358#discussion_r697959408



##########
File path: 
engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
##########
@@ -311,7 +311,10 @@ public VolumeVO allocateDuplicateVolumeVO(Volume oldVol, 
Long templateId) {
     }
 
     private Optional<StoragePool> getPreferredStoragePool(List<StoragePool> 
poolList, VirtualMachine vm) {
-        String accountStoragePoolUuid = 
StorageManager.PreferredStoragePool.valueIn(vm.getAccountId());
+        String accountStoragePoolUuid = null;
+        if (vm != null) {
+            accountStoragePoolUuid = 
StorageManager.PreferredStoragePool.valueIn(vm.getAccountId());

Review comment:
       The issue can be caused when a temporary snapshot (which is used only to 
copy a new VM or volumes) was created, I had this null pointer exception when 
implementing Clone a Virtual Machine 
https://github.com/apache/cloudstack/pull/5216/files, and this null pointer 
exception can be fixed after this implementation. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to