-
15 Jul 2009 1:27 PM #1
[FIXED] Dispatcher fix for concurrent access error add new controller
[FIXED] Dispatcher fix for concurrent access error add new controller
Iterating over a "copy" of the controller list should eliminate concurrent access errors that occur when trying to add a controller in the middle of an event being dispatched.
This is the same technique that is used in BaseObservable
Code:private void dispatch(AppEvent event, boolean createhistory) { MvcEvent e = new MvcEvent(this, event); e.setAppEvent(event); if (fireEvent(BeforeDispatch, e)) { List<Controllers> copy = new ArrayList<Controllers>(controllers); for (Controller controller : copy) { if (controller.canHandle(event)) { if (!controller.initialized) { controller.initialized = true; controller.initialize(); } controller.handleEvent(event); } } fireEvent(AfterDispatch, e); } if (createhistory && event.isHistoryEvent()) { String token = event.getToken(); if (token == null) { token = "" + new Date().getTime(); } history.put(token, event); History.newItem(token, false); } } }
-
15 Jul 2009 1:36 PM #2
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote