IDEMPIERE-4679 SvrProcess: ensure unlock and flushBufferLog happens after transaction commit and close (#560)

This commit is contained in:
hengsin 2021-02-01 22:25:34 +08:00 committed by GitHub
parent c5c08a8b87
commit 4009c9c8ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 50 additions and 10 deletions

View File

@ -39,6 +39,7 @@ import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Trx;
import org.compiere.util.TrxEventListener;
import org.osgi.service.event.Event;
/**
@ -176,7 +177,6 @@ public abstract class SvrProcess implements ProcessCall
m_trx.close();
m_trx = null;
m_pi.setTransactionName(null);
}
unlock();
@ -186,6 +186,31 @@ public abstract class SvrProcess implements ProcessCall
@SuppressWarnings("unused")
Event eventPP = sendProcessEvent(IEventTopics.POST_PROCESS);
}
else
{
m_trx.addTrxEventListener(new TrxEventListener() {
@Override
public void afterRollback(Trx trx, boolean success) {
}
@Override
public void afterCommit(Trx trx, boolean success) {
}
@Override
public void afterClose(Trx trx) {
unlock();
// outside transaction processing [ teo_sarca, 1646891 ]
postProcess(!m_pi.isError());
@SuppressWarnings("unused")
Event eventPP = sendProcessEvent(IEventTopics.POST_PROCESS);
}
});
}
Thread.currentThread().setContextClassLoader(contextLoader);
}
} finally {
@ -245,8 +270,23 @@ public abstract class SvrProcess implements ProcessCall
if(msg != null && msg.startsWith("@Error@"))
success = false;
if (success) {
m_trx.addTrxEventListener(new TrxEventListener() {
@Override
public void afterRollback(Trx trx, boolean success) {
}
@Override
public void afterCommit(Trx trx, boolean success) {
if (success)
flushBufferLog();
}
@Override
public void afterClose(Trx trx) {
}
});
}
// Parse Variables
msg = Msg.parseTranslation(m_ctx, msg);