Copilot commented on code in PR #11782:
URL: https://github.com/apache/cloudstack/pull/11782#discussion_r2410519544


##########
engine/schema/src/main/java/com/cloud/storage/dao/VMTemplatePoolDaoImpl.java:
##########
@@ -150,6 +150,16 @@ public VMTemplateStoragePoolVO findByPoolTemplate(long 
poolId, long templateId,
         return findOneIncludingRemovedBy(sc);
     }
 
+    @Override
+    public List<VMTemplateStoragePoolVO> listByPoolIdsAndTemplate(List<Long> 
poolIds, Long templateId) {
+        SearchCriteria<VMTemplateStoragePoolVO> sc = 
PoolTemplateSearch.create();
+        if (CollectionUtils.isNotEmpty(poolIds)) {
+            sc.setParameters("pool_id", poolIds.toArray());
+        }

Review Comment:
   When poolIds is empty, the search criteria will not filter by pool_id, which 
could return all template-pool relationships for the given templateId instead 
of an empty result. Consider adding an early return for empty poolIds list to 
avoid unintended behavior.
   ```suggestion
           if (CollectionUtils.isEmpty(poolIds)) {
               return Collections.emptyList();
           }
           SearchCriteria<VMTemplateStoragePoolVO> sc = 
PoolTemplateSearch.create();
           sc.setParameters("pool_id", poolIds.toArray());
   ```



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