IDEMPIERE-2756 Background threads losing context when user log out - fix validation / integrate fix from hengsin: Improve handling of context lost ( due to user close browser ) exception for document workflow.
This commit is contained in:
parent
6522a64289
commit
8e193dad3d
|
@ -916,7 +916,25 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
|
|||
processMsg = e.getMessage();
|
||||
setTextMsg(processMsg);
|
||||
// addTextMsg(e); // do not add the exception text
|
||||
boolean contextLost = false;
|
||||
if (e instanceof AdempiereException && "Context lost".equals(e.getMessage()))
|
||||
{
|
||||
contextLost = true;
|
||||
m_docStatus = DocAction.STATUS_Invalid;
|
||||
}
|
||||
try {
|
||||
if (contextLost)
|
||||
{
|
||||
Env.getCtx().setProperty("#AD_Client_ID", (m_po != null ? Integer.toString(m_po.getAD_Client_ID()) : "0") );
|
||||
m_state = new StateEngine(WFSTATE_Running);
|
||||
setProcessed(true);
|
||||
setWFState (StateEngine.STATE_Aborted);
|
||||
}
|
||||
else
|
||||
{
|
||||
setWFState (StateEngine.STATE_Terminated); // unlocks
|
||||
}
|
||||
|
||||
// Set Document Status
|
||||
if (m_po != null && m_po instanceof DocAction && m_docStatus != null)
|
||||
{
|
||||
|
@ -930,6 +948,10 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
|
|||
m_process.setProcessMsg(this.getTextMsg());
|
||||
m_process.saveEx();
|
||||
}
|
||||
} finally {
|
||||
if (contextLost)
|
||||
Env.getCtx().remove("#AD_Client_ID");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
@ -461,6 +461,8 @@ public abstract class AbstractProcessDialog extends Window implements IProcessUI
|
|||
m_locked = false;
|
||||
|
||||
if (Executions.getCurrent() == null)
|
||||
{
|
||||
if (getDesktop() != null)
|
||||
{
|
||||
Executions.schedule(getDesktop(), new EventListener<Event>()
|
||||
{
|
||||
|
@ -469,6 +471,7 @@ public abstract class AbstractProcessDialog extends Window implements IProcessUI
|
|||
doUnlockUI();
|
||||
}
|
||||
}, new Event("onUnLockUI"));
|
||||
}
|
||||
} else {
|
||||
doUnlockUI();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue