IDEMPIERE-2944 AP2-330 Web services logging. Access to csMap is not thread safe. ctxMap should not cache full context of previous service execution.
This commit is contained in:
parent
817f23835c
commit
4c644268e1
|
@ -144,9 +144,9 @@ public class CompiereService {
|
||||||
public void disconnect()
|
public void disconnect()
|
||||||
{
|
{
|
||||||
// TODO: create a thread that checks expired connected compiereservices and log them out
|
// TODO: create a thread that checks expired connected compiereservices and log them out
|
||||||
if (! isExpired()) {
|
if (isExpired()) {
|
||||||
// do not close, save session in cache
|
synchronized (csMap) {
|
||||||
if (! csMap.containsValue(this)) {
|
//save session in cache
|
||||||
String key = getKey(m_AD_Client_ID,
|
String key = getKey(m_AD_Client_ID,
|
||||||
m_AD_Org_ID,
|
m_AD_Org_ID,
|
||||||
m_userName,
|
m_userName,
|
||||||
|
@ -155,11 +155,10 @@ public class CompiereService {
|
||||||
m_locale,
|
m_locale,
|
||||||
m_password,
|
m_password,
|
||||||
m_IPAddress);
|
m_IPAddress);
|
||||||
csMap.put(key.toString(), this);
|
if (csMap.containsKey(key)) {
|
||||||
Properties savedCache = new Properties();
|
csMap.remove(key.toString());
|
||||||
savedCache.putAll(Env.getCtx());
|
ctxMap.remove(key.toString());
|
||||||
ctxMap.put(key.toString(), savedCache);
|
}
|
||||||
if (log.isLoggable(Level.INFO)) log.info("Saving " + this + " in cache");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -315,6 +314,26 @@ public class CompiereService {
|
||||||
session.saveEx();
|
session.saveEx();
|
||||||
|
|
||||||
m_loggedin = true;
|
m_loggedin = true;
|
||||||
|
|
||||||
|
synchronized (csMap) {
|
||||||
|
//save session in cache
|
||||||
|
String key = getKey(m_AD_Client_ID,
|
||||||
|
m_AD_Org_ID,
|
||||||
|
m_userName,
|
||||||
|
m_AD_Role_ID,
|
||||||
|
m_M_Warehouse_ID,
|
||||||
|
m_locale,
|
||||||
|
m_password,
|
||||||
|
m_IPAddress);
|
||||||
|
if (! csMap.containsKey(key)) {
|
||||||
|
csMap.put(key.toString(), this);
|
||||||
|
Properties savedCache = new Properties();
|
||||||
|
savedCache.putAll(Env.getCtx());
|
||||||
|
ctxMap.put(key.toString(), savedCache);
|
||||||
|
if (log.isLoggable(Level.INFO)) log.info("Saving " + this + " in cache");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,17 +423,19 @@ public class CompiereService {
|
||||||
loginRequest.getPass(),
|
loginRequest.getPass(),
|
||||||
req.getRemoteAddr());
|
req.getRemoteAddr());
|
||||||
CompiereService l_cs = null;
|
CompiereService l_cs = null;
|
||||||
if (csMap.containsKey(key)) {
|
synchronized (csMap) {
|
||||||
l_cs = csMap.get(key);
|
if (csMap.containsKey(key)) {
|
||||||
if (l_cs != null) {
|
l_cs = csMap.get(key);
|
||||||
if (l_cs.isExpired()) {
|
if (l_cs != null) {
|
||||||
csMap.remove(key);
|
if (l_cs.isExpired()) {
|
||||||
ctxMap.remove(key);
|
csMap.remove(key);
|
||||||
l_cs = null;
|
ctxMap.remove(key);
|
||||||
} else {
|
l_cs = null;
|
||||||
Properties cachedCtx = ctxMap.get(key);
|
} else {
|
||||||
Env.getCtx().putAll(cachedCtx);
|
Properties cachedCtx = ctxMap.get(key);
|
||||||
if (log.isLoggable(Level.INFO)) log.info("Reusing " + l_cs);
|
Env.getCtx().putAll(cachedCtx);
|
||||||
|
if (log.isLoggable(Level.INFO)) log.info("Reusing " + l_cs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue