This is an automated email from the ASF dual-hosted git repository.

mridulpathak pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 45cae40eee Remove the this-escape warning in the ModelService copy 
constructor
45cae40eee is described below

commit 45cae40eeec41a750c22eb374981a391c469daeb
Author: Mridul Pathak <[email protected]>
AuthorDate: Sat Oct 31 23:41:27 2026 +0530

    Remove the this-escape warning in the ModelService copy constructor
    
    The copy constructor added each copied parameter through the overridable 
addParamClone, which let a subclass see the copy before it was fully built. It 
now copies the parameters into its own map and list directly. It also copies 
the implemented services and the override parameters instead of sharing the 
original's sets.
---
 .../main/java/org/apache/ofbiz/service/ModelService.java    | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git 
a/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java 
b/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java
index eb82ea0393..58d79a6267 100644
--- a/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java
+++ b/framework/service/src/main/java/org/apache/ofbiz/service/ModelService.java
@@ -794,8 +794,10 @@ public class ModelService extends AbstractMap<String, 
Object> implements Seriali
         if (model.modelPermission != null) {
             modelPermission = model.modelPermission;
         }
-        this.implServices = model.implServices;
-        this.overrideParameters = model.overrideParameters;
+        if (model.implServices != null) {
+            this.implServices = new LinkedHashSet<>(model.implServices);
+        }
+        this.overrideParameters = new 
LinkedHashSet<>(model.overrideParameters);
         this.permissionGroups = new LinkedList<>(model.permissionGroups);
         if (model.notifications != null) {
             this.notifications = new LinkedList<>(model.notifications);
@@ -807,9 +809,10 @@ public class ModelService extends AbstractMap<String, 
Object> implements Seriali
         this.internalGroup = model.internalGroup;
         this.hideResultInLog = model.hideResultInLog;
         this.metrics = model.metrics;
-        List<ModelParam> modelParamList = model.getModelParamList();
-        for (ModelParam param: modelParamList) {
-            this.addParamClone(param);
+        for (ModelParam param: model.contextParamList) {
+            ModelParam copy = new ModelParam(param);
+            this.contextInfo.put(copy.getName(), copy);
+            this.contextParamList.add(copy);
         }
     }
 

Reply via email to