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

jleroux 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 3e902e923f Fixed: IndexOutOfBoundsException occured while placing 
order (OFBIZ-12838)
3e902e923f is described below

commit 3e902e923f72f6516e781ed10b2617370f34679b
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
---
 applications/order/groovyScripts/entry/ShowPromoText.groovy | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/applications/order/groovyScripts/entry/ShowPromoText.groovy 
b/applications/order/groovyScripts/entry/ShowPromoText.groovy
index a9834da105..ad2aca342f 100644
--- a/applications/order/groovyScripts/entry/ShowPromoText.groovy
+++ b/applications/order/groovyScripts/entry/ShowPromoText.groovy
@@ -17,11 +17,11 @@
  * under the License.
  */
 
-import org.apache.ofbiz.order.shoppingcart.product.ProductPromoWorker
-import org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents
-
 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()
 
@@ -49,7 +49,7 @@ if (mode == 'SALES_ORDER') {
     if (productPromosRandomTemp.size() > promoShowLimit) {
         productPromos = new ArrayList(promoShowLimit)
         for (i = 0; i < promoShowLimit; i++) {
-            randomIndex = Math.round(new SecureRandom().nextInt() * 
(productPromosRandomTemp.size() - 1)) as int
+            randomIndex = new 
SecureRandom().nextInt(productPromosRandomTemp.size())
             productPromos.add(productPromosRandomTemp.remove(randomIndex))
         }
     } else {

Reply via email to