IDEMPIERE-4268 Web Services : Read miss cross-tenant check (#456)

Extracting from @hengsin pull request 453
This commit is contained in:
Carlos Ruiz 2020-12-11 09:48:16 +01:00 committed by GitHub
parent f2c5ec429b
commit 9d6de521f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 12 deletions

View File

@ -36,6 +36,7 @@ public class MUserDefWin extends X_AD_UserDef_Win implements ImmutablePOSupport
*/
private static final long serialVersionUID = -7542708120229671875L;
private volatile static List<MUserDefWin> m_fullList = null;
private static final Object m_fullListLock = new Object();
/**
* Standard constructor.
@ -103,6 +104,7 @@ public class MUserDefWin extends X_AD_UserDef_Win implements ImmutablePOSupport
*/
private static MUserDefWin[] getAll (Properties ctx, int window_ID )
{
synchronized (m_fullListLock) {
if (m_fullList == null) {
try {
PO.setCrossTenantSafe();
@ -113,6 +115,7 @@ public class MUserDefWin extends X_AD_UserDef_Win implements ImmutablePOSupport
PO.clearCrossTenantSafe();
}
}
}
if (m_fullList.size() == 0) {
return null;

View File

@ -209,7 +209,7 @@ public abstract class PO
else
load(ID, trxName);
checkValidClient(false);
checkCrossTenant(false);
} // PO
/**
@ -2082,7 +2082,7 @@ public abstract class PO
checkImmutable();
checkValidContext();
checkValidClient(true);
checkCrossTenant(true);
CLogger.resetLast();
boolean newRecord = is_new(); // save locally as load resets
if (!newRecord && !is_Changed())
@ -3270,7 +3270,7 @@ public abstract class PO
checkImmutable();
checkValidContext();
checkValidClient(true);
checkCrossTenant(true);
CLogger.resetLast();
if (is_new())
return true;
@ -5002,7 +5002,7 @@ public abstract class PO
isSafeCrossTenant.set(Boolean.FALSE);
}
private void checkValidClient(boolean writing) {
private void checkCrossTenant(boolean writing) {
if (isSafeCrossTenant.get())
return;
int envClientID = Env.getAD_Client_ID(getCtx());