Dashboard Rendering Threads do not hold language set after login
Description
Environment
is caused by
Activity
Norbert Bede February 4, 2023 at 11:26 AM
tested, pass. n
Heng Sin Low February 2, 2023 at 8:43 AM
hi @Peter Takacs ,
Please test https://github.com/idempiere/idempiere/pull/1659 , thanks.
Heng Sin Low January 27, 2023 at 9:17 AM
I think this is a broader issue that needs a more general fix. ContextRunnable is use in many other place in zk and probably effected by the same issue as well. I think we need to create a new ZkContextRunnable (extends the current ContextRunnable or just replace it) and call Locales.setThreadLocal in the run method (and according to the setThreadLocal javadoc should perform cleanup in the finally block). Existing code in zk that uses ContextRunnable should then change to use ZkContextRunnable instead.
Norbert Bede January 26, 2023 at 4:57 PM
We assume this is general improvement, not for our code. if not then you can reject it well.
Peter Takacs January 26, 2023 at 2:25 PM
Hi @Carlos Ruiz @Heng Sin Low,
Currently I could not reproduce it in the community code. We have multi-dashboard implemented and it looses the language when changing dashboards. I will create a PR with the fix, then you can judge if this is useful for community or not.
After the implementation of asynchronous rendering of the dashboard gadgets https://idempiere.atlassian.net/browse/IDEMPIERE-5527 we have discovered an issue: new rendering-threads do not hold the language which is set after login. In certain use cases it can possibly cause an error:
11:21:09.912===========> Messages.error: Message code not found: 27112801 not in en_US:[org.zkoss.zul.mesg.MZul, /metainfo/mesg/msgzul] [180] 11:21:09.929===========> Messages.error: Message code not found: 27112801 not in en_US:[org.zkoss.zul.mesg.MZul, /metainfo/mesg/msgzul] [119] 11:21:09.922===========> Messages.error: Message code not found: 27112801 not in en_US:[org.zkoss.zul.mesg.MZul, /metainfo/mesg/msgzul] [114] 11:21:09.930===========> Messages.error: Message code not found: 27112801 not in en_US:[org.zkoss.zul.mesg.MZul, /metainfo/mesg/msgzul] [122] 11:21:09.958===========> Messages.error: [114] java.lang.IllegalStateException: Missing resource: [org.zkoss.zul.mesg.MZul, /metainfo/mesg/msgzul] locale=en_US at org.zkoss.mesg.Messages.getFromBundle(Messages.java:89) at org.zkoss.mesg.Messages.get(Messages.java:134) at org.zkoss.mesg.Messages.get(Messages.java:52) at org.zkoss.zul.Datebox.<init>(Datebox.java:95) at org.adempiere.webui.component.Datebox.<init>(Datebox.java:38) at org.adempiere.webui.editor.WDateEditor.<init>(WDateEditor.java:72) at org.adempiere.webui.factory.DefaultEditorFactory.getEditor(DefaultEditorFactory.java:144) at org.adempiere.webui.editor.WebEditorFactory.getEditor(WebEditorFactory.java:98) at org.adempiere.webui.editor.WebEditorFactory.getEditor(WebEditorFactory.java:62) at org.adempiere.webui.editor.WebEditorFactory.getEditor(WebEditorFactory.java:50) at org.adempiere.webui.dashboard.DPChart.fillParameterEditors(DPChart.java:177) at org.adempiere.webui.dashboard.DPChart.renderParameters(DPChart.java:202) at org.adempiere.webui.dashboard.DPChart.init(DPChart.java:88) at org.adempiere.webui.dashboard.DPChart.<init>(DPChart.java:83) at org.adempiere.webui.desktop.DashboardController.asyncRenderComponents(DashboardController.java:1320) at org.adempiere.webui.desktop.DashboardController.asyncRenderGadgetPanel(DashboardController.java:883) at org.adempiere.webui.desktop.DashboardController$4.doRun(DashboardController.java:1045) at org.adempiere.util.ContextRunnable.run(ContextRunnable.java:38) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)