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 7a97ba0bb4 Fixed: createFacilityLocation locationSeqId collision 
fallback regression (OFBIZ-13557)
7a97ba0bb4 is described below

commit 7a97ba0bb405d8723b096285052659ebda1a86ee
Author: Mridul Pathak <[email protected]>
AuthorDate: Fri Sep 11 01:25:53 2026 +0530

    Fixed: createFacilityLocation locationSeqId collision fallback regression 
(OFBIZ-13557)
    
    Restore original collision handling to try a single _2 suffix before 
falling back to a sequenced id instead of looping indefinitely with incremental 
suffixes.
---
 .../ofbiz/product/facility/storage/StorageServices.groovy | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git 
a/applications/product/src/main/groovy/org/apache/ofbiz/product/facility/storage/StorageServices.groovy
 
b/applications/product/src/main/groovy/org/apache/ofbiz/product/facility/storage/StorageServices.groovy
index 99c967a23f..84603bb205 100644
--- 
a/applications/product/src/main/groovy/org/apache/ofbiz/product/facility/storage/StorageServices.groovy
+++ 
b/applications/product/src/main/groovy/org/apache/ofbiz/product/facility/storage/StorageServices.groovy
@@ -30,15 +30,16 @@ Map createFacilityLocation() {
     "${parameters.levelId ?: ''}${parameters.positionId ?: ''}"
 
     if (locationSeqId) {
-        int i = 1
-        String nextLocationSeqId = locationSeqId
-        while (from('FacilityLocation')
-                .where([locationSeqId: nextLocationSeqId,
-                        facilityId: parameters.facilityId])
+        if (from('FacilityLocation')
+                .where(facilityId: parameters.facilityId, locationSeqId: 
locationSeqId)
                 .queryOne()) {
-            nextLocationSeqId = "${locationSeqId}_${i++}"
+            locationSeqId = "${locationSeqId}_2"
+            if (from('FacilityLocation')
+                    .where(facilityId: parameters.facilityId, locationSeqId: 
locationSeqId)
+                    .queryOne()) {
+                locationSeqId = delegator.getNextSeqId('FacilityLocation')
+            }
         }
-        locationSeqId = nextLocationSeqId
     } else {
         locationSeqId = delegator.getNextSeqId('FacilityLocation')
     }

Reply via email to