You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2022/11/09 17:49:15 UTC

[GitHub] [cloudstack] csquire commented on a diff in pull request #6879: Check for null volume pool ID when tagging

csquire commented on code in PR #6879:
URL: https://github.com/apache/cloudstack/pull/6879#discussion_r1018246126


##########
server/src/main/java/com/cloud/tags/TaggedResourceManagerImpl.java:
##########
@@ -318,7 +318,11 @@ public Map<String, String> getTagsFromResource(ResourceObjectType type, long res
     private void informStoragePoolForVmTags(long vmId, String key, String value) {
         List<VolumeVO> volumeVos = volumeDao.findByInstance(vmId);
         for (VolumeVO volume : volumeVos) {
-            DataStore dataStore = dataStoreMgr.getDataStore(volume.getPoolId(), DataStoreRole.Primary);
+            Long poolId = volume.getPoolId();
+            if (poolId == null) {
+                continue;
+            }
+            DataStore dataStore = dataStoreMgr.getDataStore(poolId, DataStoreRole.Primary);
             if (dataStore == null || !(dataStore.getDriver() instanceof PrimaryDataStoreDriver)) {
                 continue;
             }

Review Comment:
   Hi Daan, I extracted it. I'm not sure I follow what the goal is with the throwing. It would still require a null check after the catch and another `continue`.



-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org