GutoVeronezi commented on a change in pull request #4771:
URL: https://github.com/apache/cloudstack/pull/4771#discussion_r589420140
##########
File path:
engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/KvmNonManagedStorageDataMotionStrategy.java
##########
@@ -195,7 +195,10 @@ protected boolean shouldMigrateVolume(StoragePoolVO
sourceStoragePool, Host dest
@Override
protected void copyTemplateToTargetFilesystemStorageIfNeeded(VolumeInfo
srcVolumeInfo, StoragePool srcStoragePool, DataStore destDataStore, StoragePool
destStoragePool,
Host destHost) {
- VMTemplateStoragePoolVO sourceVolumeTemplateStoragePoolVO =
vmTemplatePoolDao.findByPoolTemplate(destStoragePool.getId(),
srcVolumeInfo.getTemplateId(), null);
+ VMTemplateStoragePoolVO sourceVolumeTemplateStoragePoolVO = null;
+ if (srcVolumeInfo != null && srcVolumeInfo.getTemplateId() != null) {
+ sourceVolumeTemplateStoragePoolVO =
vmTemplatePoolDao.findByPoolTemplate(destStoragePool.getId(),
srcVolumeInfo.getTemplateId(), null);
+ }
if (sourceVolumeTemplateStoragePoolVO == null &&
destStoragePool.getPoolType() == StoragePoolType.Filesystem) {
DataStore sourceTemplateDataStore =
dataStoreManagerImpl.getRandomImageStore(srcVolumeInfo.getDataCenterId());
Review comment:
@harikrishna-patnala The problem is that `findByPoolTemplate` receives a
`long` (primitive type) to `template` and `getTemplateId` returns a `Long`
(object type). Java will do an autounboxing, but as `getTemplateId` returns
`null` for non-template volume (data disks), it will generate a NPE when trying
to autounbox this value.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]