IDEMPIERE-5811 - Fix NPE on event for BroadcastMessages / fix kill session feature (#1956)

This commit is contained in:
Carlos Ruiz 2023-07-28 23:37:05 +02:00 committed by GitHub
parent 9af815acf6
commit 1eef599bb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 14 deletions

View File

@ -972,49 +972,44 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
BroadCastMsg msg = (BroadCastMsg) event.getData(); BroadCastMsg msg = (BroadCastMsg) event.getData();
MBroadcastMessage mbMessage = MBroadcastMessage.get(Env.getCtx(), msg.getIntData());
if (mbMessage == null)
return;
MBroadcastMessage mbMessage = null;
switch (msg.getEventId()) { switch (msg.getEventId()) {
case BroadCastUtil.EVENT_TEST_BROADCAST_MESSAGE: case BroadCastUtil.EVENT_TEST_BROADCAST_MESSAGE:
String currSession = Integer mbMessage = MBroadcastMessage.get(Env.getCtx(), msg.getIntData());
.toString(Env.getContextAsInt(Env.getCtx(), if (mbMessage == null)
"AD_Session_ID")); return;
String currSession = Integer.toString(Env.getContextAsInt(Env.getCtx(), "AD_Session_ID"));
if (currSession.equals(msg.getTarget())) { if (currSession.equals(msg.getTarget())) {
BroadcastMessageWindow testMessageWindow = new BroadcastMessageWindow( BroadcastMessageWindow testMessageWindow = new BroadcastMessageWindow(
pnlHead); pnlHead);
testMessageWindow.appendMessage(mbMessage, true); testMessageWindow.appendMessage(mbMessage, true);
testMessageWindow = null; testMessageWindow = null;
} }
break; break;
case BroadCastUtil.EVENT_BROADCAST_MESSAGE: case BroadCastUtil.EVENT_BROADCAST_MESSAGE:
mbMessage = MBroadcastMessage.get(Env.getCtx(), msg.getIntData());
if (mbMessage == null)
return;
if (mbMessage.isValidUserforMessage()) { if (mbMessage.isValidUserforMessage()) {
BroadcastMessageWindow messageWindow = new BroadcastMessageWindow( BroadcastMessageWindow messageWindow = new BroadcastMessageWindow(
pnlHead); pnlHead);
messageWindow.appendMessage(mbMessage, false); messageWindow.appendMessage(mbMessage, false);
} }
break; break;
case BroadCastUtil.EVENT_SESSION_TIMEOUT: case BroadCastUtil.EVENT_SESSION_TIMEOUT:
currSession = Integer.toString(Env.getContextAsInt( currSession = Integer.toString(Env.getContextAsInt(
Env.getCtx(), "AD_Session_ID")); Env.getCtx(), "AD_Session_ID"));
if (currSession.equalsIgnoreCase(msg.getTarget())) { if (currSession.equalsIgnoreCase(msg.getTarget())) {
new TimeoutPanel(pnlHead, msg.getIntData()); new TimeoutPanel(pnlHead, msg.getIntData());
} }
break; break;
case BroadCastUtil.EVENT_SESSION_ONNODE_TIMEOUT: case BroadCastUtil.EVENT_SESSION_ONNODE_TIMEOUT:
currSession = WebUtil.getServerName(); currSession = WebUtil.getServerName();
if (currSession.equalsIgnoreCase(msg.getTarget())) { if (currSession.equalsIgnoreCase(msg.getTarget())) {
new TimeoutPanel(pnlHead, msg.getIntData()); new TimeoutPanel(pnlHead, msg.getIntData());
} }
break;
} }
} }