Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pearl1594 can you help me understanding on which object we are getting NPE. I'm seeing only srcVolumeInfo as possible object but it would have failed earlier at 198 Line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harikrishna-patnala I've updated the exception, you're right, the exception happens at line198 - I had added a few debug lines which was why it showed the exception occuring at L200

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GutoVeronezi wouldn't srcVolumeInfo.getTemplateId() != null prevents what you mentioned?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GabrielBrascher It will. I mention it to explain why it is happening.

if (sourceTemplateDataStore != null) {
Expand Down