Idempiere 4300 (#78)

* IDEMPIERE-4300 DashboardPanel subclass should not cache Env Ctx

Remove Env.getCtx() cache

* IDEMPIERE-4300 DashboardPanel subclass should not cache Env Ctx

Fix usage of private ctx
This commit is contained in:
hengsin 2020-05-23 06:34:23 +08:00 committed by GitHub
parent 4eac03ba0f
commit bf6fd2bb71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 28 deletions

View File

@ -113,14 +113,6 @@ public class MSystem extends X_AD_System
s_system.put(0, this);
} // MSystem
/**
* Constructor
*/
public MSystem ()
{
this (new Properties(), 0, null);
} // MSystem
/**
* Is LDAP Authentification defined
* @return true if ldap defined
@ -498,14 +490,5 @@ public class MSystem extends X_AD_System
String ca = MSysConfig.getValue(MSysConfig.SWING_LOGIN_ALLOW_REMEMBER_ME, SYSTEM_ALLOW_REMEMBER_PASSWORD);
return (ca.equalsIgnoreCase(SYSTEM_ALLOW_REMEMBER_PASSWORD) && !MSysConfig.getBooleanValue(MSysConfig.USER_PASSWORD_HASH, false));
}
/**
* Test
* @param args
*/
public static void main (String[] args)
{
new MSystem();
} // main
} // MSystem

View File

@ -30,6 +30,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.adempiere.util.ServerContext;
import org.apache.ecs.AlignType;
import org.apache.ecs.xhtml.a;
import org.apache.ecs.xhtml.body;
@ -180,11 +181,16 @@ public class WebEnv
if (log.isLoggable(Level.INFO)) log.info(info.toString());
//
Properties ctx = new Properties();
MClient client = MClient.get(ctx, 0);
MSystem system = MSystem.get(ctx);
client.sendEMail(client.getRequestEMail(),
"Server started: " + system.getName() + " (" + WebUtil.getServerName() + ")",
"ServerInfo: " + context.getServerInfo(), null);
try {
ServerContext.setCurrentInstance(ctx);
MClient client = MClient.get(Env.getCtx(), 0);
MSystem system = MSystem.get(Env.getCtx());
client.sendEMail(client.getRequestEMail(),
"Server started: " + system.getName() + " (" + WebUtil.getServerName() + ")",
"ServerInfo: " + context.getServerInfo(), null);
} finally {
ServerContext.dispose();
}
return s_initOK;
} // initWeb

View File

@ -37,6 +37,7 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.adempiere.util.ServerContext;
import org.apache.ecs.HtmlColor;
import org.apache.ecs.xhtml.a;
import org.apache.ecs.xhtml.b;
@ -770,8 +771,14 @@ public class AdempiereMonitor extends HttpServlet
}
bb.addElement(para);
// **** Log Management ****
createLogMgtPage(bb, members, local);
// **** Log Management ****
try {
Properties ctx = new Properties();
ServerContext.setCurrentInstance(ctx);
createLogMgtPage(bb, members, local);
} finally {
ServerContext.dispose();
}
// ***** Server Details *****
bb.removeEndEndModifier();
@ -1014,8 +1021,8 @@ public class AdempiereMonitor extends HttpServlet
table.setCellSpacing(2);
table.setCellPadding(2);
//
Properties ctx = new Properties();
MSystem system = MSystem.get(ctx);
MSystem system = MSystem.get(Env.getCtx());
SystemInfo systemInfo = SystemInfo.getLocalSystemInfo();
tr line = new tr();
line.addElement(new th().addElement(Adempiere.getURL()));
@ -1165,7 +1172,7 @@ public class AdempiereMonitor extends HttpServlet
table.setCellPadding(2);
//
line = new tr();
MClient[] clients = MClient.getAll(ctx, "AD_Client_ID");
MClient[] clients = MClient.getAll(Env.getCtx(), "AD_Client_ID");
line.addElement(new th().addElement("Client #" + clients.length + " - EMail Test:"));
p = new p();
for (int i = 0; i < clients.length; i++)
@ -1240,7 +1247,7 @@ public class AdempiereMonitor extends HttpServlet
else if (inMaintenanceClients.size() > 0) {
boolean first = true;
for (int clientID : inMaintenanceClients) {
MClient client = MClient.get(ctx, clientID);
MClient client = MClient.get(Env.getCtx(), clientID);
if (!client.isActive())
continue;
if (!first)