Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-10369

ConfigXMLReader - Events are not executed in the order defined

    XMLWordPrintableJSON

Details

    • Patch

    Description

      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,

      
          <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>
      
      

      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.

      
      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>();
      
      

       

      Attachments

        Issue Links

          Activity

            People

              nmalin Nicolas Malin
              vikasmayur Vikas Mayur
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: