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

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


The following commit(s) were added to refs/heads/release22.01 by this push:
     new 1c2532a350 Fixed: IndexOutOfBoundsException occured while placing 
order (OFBIZ-12838)
1c2532a350 is described below

commit 1c2532a350ab6842295bfcf32f5cb418269563fb
Author: Jacques Le Roux <jacques.le.r...@les7arts.com>
AuthorDate: Mon Jul 17 09:55:41 2023 +0200

    Fixed: IndexOutOfBoundsException occured while placing order (OFBIZ-12838)
    
    After "continuing" twice while creating a sales order the error appears.
    This is due to OFBIZ-11167
    
    Thanks: Chirag Jain for reporting and a detailed explanation for the fix
    
    Conflict handled by hand
---
 applications/order/groovyScripts/entry/ShowPromoText.groovy | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/applications/order/groovyScripts/entry/ShowPromoText.groovy 
b/applications/order/groovyScripts/entry/ShowPromoText.groovy
index cd5a6ba6c5..d4e11a52f7 100644
--- a/applications/order/groovyScripts/entry/ShowPromoText.groovy
+++ b/applications/order/groovyScripts/entry/ShowPromoText.groovy
@@ -17,8 +17,10 @@
  * under the License.
  */
 
-import org.apache.ofbiz.order.shoppingcart.product.ProductPromoWorker
+import java.security.SecureRandom
+
 import org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents
+import org.apache.ofbiz.order.shoppingcart.product.ProductPromoWorker
 
 shoppingCart = ShoppingCartEvents.getCartObject(request)
 mode = shoppingCart.getOrderType()
@@ -47,7 +49,7 @@ if ("SALES_ORDER".equals(mode)) {
     if (productPromosRandomTemp.size() > promoShowLimit) {
         productPromos = new ArrayList(promoShowLimit)
         for (i = 0; i < promoShowLimit; i++) {
-            randomIndex = Math.round(java.lang.Math.random() * 
(productPromosRandomTemp.size() - 1)) as int
+            randomIndex = new 
SecureRandom().nextInt(productPromosRandomTemp.size())
             productPromos.add(productPromosRandomTemp.remove(randomIndex))
         }
     } else {

Reply via email to