[jira] [Created] (OFBIZ-10369) ConfigXMLReader - Does not execute events in the defined order

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (OFBIZ-10369) ConfigXMLReader - Does not execute events in the defined order

Nicolas Malin (Jira)
Vikas Mayur created OFBIZ-10369:
-----------------------------------

             Summary: ConfigXMLReader - Does not execute events in the defined order
                 Key: OFBIZ-10369
                 URL: https://issues.apache.org/jira/browse/OFBIZ-10369
             Project: OFBiz
          Issue Type: Bug
          Components: ALL APPLICATIONS
    Affects Versions: Release Branch 16.11
            Reporter: Vikas Mayur
             Fix For: Upcoming Branch


The events contained in the controller configuration for first-visit, pre-post processor and before-after login are executed in arbitrary order rather than the defined order. This results in unexpected results.

For example,

{code}

    <after-login>

        <event name="keepCartUpdated" type="java" path="org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents" invoke="keepCartUpdated"/>

        <event name="restoreAutoSaveList" type="java" path="org.apache.ofbiz.order.shoppinglist.ShoppingListEvents" invoke="restoreAutoSaveList"/>

        <event name="saveCartToAutoSaveList" type="java" path="org.apache.ofbiz.order.shoppinglist.ShoppingListEvents" invoke="saveCartToAutoSaveList"/>

    </after-login>

{code}

While debugging I have found that the event 'restoreAutoSaveList' run before 'keepCartUpdated'. I would expect the events to run from top (first) to bottom (last).

 

I am unable to attach a patch but below are the changes to fix the issue. I have tested the issue on release 16 and it may be an issue in trunk.

{code}

Index: framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java

===================================================================

--- framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java (revision 1830130)

+++ framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java (working copy)

@@ -25,6 +25,7 @@

 import java.util.ArrayList;

 import java.util.HashMap;

 import java.util.HashSet;

+import java.util.LinkedHashMap;

 import java.util.LinkedList;

 import java.util.List;

 import java.util.Map;

@@ -182,11 +183,11 @@

         private String defaultRequest;

         private String statusCode;

         private List<URL> includes = new ArrayList<URL>();

-        private Map<String, Event> firstVisitEventList = new HashMap<String, Event>();

-        private Map<String, Event> preprocessorEventList = new HashMap<String, Event>();

-        private Map<String, Event> postprocessorEventList = new HashMap<String, Event>();

-        private Map<String, Event> afterLoginEventList = new HashMap<String, Event>();

-        private Map<String, Event> beforeLogoutEventList = new HashMap<String, Event>();

+        private Map<String, Event> firstVisitEventList = new LinkedHashMap<String, Event>();

+        private Map<String, Event> preprocessorEventList = new LinkedHashMap<String, Event>();

+        private Map<String, Event> postprocessorEventList = new LinkedHashMap<String, Event>();

+        private Map<String, Event> afterLoginEventList = new LinkedHashMap<String, Event>();

+        private Map<String, Event> beforeLogoutEventList = new LinkedHashMap<String, Event>();

         private Map<String, String> eventHandlerMap = new HashMap<String, String>();

         private Map<String, String> viewHandlerMap = new HashMap<String, String>();

         private Map<String, RequestMap> requestMapMap = new HashMap<String, RequestMap>();

{code}

 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)