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

dixitdeepak 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 66c7f59d99 Updated ShoppingCartEvents.destroyCart() to invoke 
clearCart() after removing session attributes (OFBIZ-6805) Previously, 
clearCart() could invalidate the session for anonymous users before 
destroyCart() attempted to remove additional session attributes, resulting in a 
Session already invalidated exception.
66c7f59d99 is described below

commit 66c7f59d998af1c920ebfdbedabd402df2963a35
Author: Deepak Dixit <[email protected]>
AuthorDate: Wed Jul 1 11:39:32 2026 +0530

    Updated ShoppingCartEvents.destroyCart() to invoke clearCart() after 
removing session attributes (OFBIZ-6805)
    Previously, clearCart() could invalidate the session for anonymous users 
before destroyCart() attempted to remove additional session attributes, 
resulting in a Session already invalidated exception.
---
 .../java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java   | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 
a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java
 
b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java
index b4b37c8699..2fb0b58910 100644
--- 
a/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java
+++ 
b/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCartEvents.java
@@ -955,12 +955,13 @@ public class ShoppingCartEvents {
     /** Totally wipe out the cart, removes all stored info. */
     public static String destroyCart(HttpServletRequest request, 
HttpServletResponse response) {
         HttpSession session = request.getSession();
-        clearCart(request, response);
         session.removeAttribute("shoppingCart");
         session.removeAttribute("orderPartyId");
         session.removeAttribute("orderMode");
         session.removeAttribute("productStoreId");
         session.removeAttribute("CURRENT_CATALOG_ID");
+        // Call clearCart at the end as if user is anonymous then it will 
throw session already invalidated error on removeAttribute method.
+        clearCart(request, response);
         return "success";
     }
 

Reply via email to