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


##########
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java:
##########
@@ -8486,8 +8486,11 @@ private void 
applySourceOfferingValuesToCloneCmd(CloneNetworkOfferingCmd cmd,
     private Map<String, String> getSourceOfferingDetails(Long 
sourceOfferingId) {
         List<NetworkOfferingDetailsVO> sourceDetailsVOs = 
networkOfferingDetailsDao.listDetails(sourceOfferingId);
         Map<String, String> sourceDetailsMap = new HashMap<>();
+        List<String> ignoredSourceDetails = 
Arrays.asList(Detail.internetProtocol.name(), Detail.domainid.name(), 
Detail.zoneid.name());

Review Comment:
   `ignoredSourceDetails` is used only for `contains()` checks; using a `Set` 
avoids repeated linear scans and better conveys intent (membership test).



##########
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java:
##########
@@ -8635,7 +8638,7 @@ private void 
applyResolvedValuesToCommand(CloneNetworkOfferingCmd cmd, NetworkOf
 
             if (cmd.getDetails() == null || cmd.getDetails().isEmpty()) {
                 if (!sourceDetailsMap.isEmpty()) {
-                    setField(cmd, "details", sourceDetailsMap);
+                    setField(cmd, "sourceDetailsMap", sourceDetailsMap);
                 }

Review Comment:
   This change fixes a runtime `ClassCastException` during cloning by routing 
source details through `sourceDetailsMap`. Please add/extend a unit/integration 
test that reproduces the reported failure (source offering has details 
including `internetProtocol=IPv4` and cloning succeeds without exceptions), so 
the regression is prevented going forward.



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