IDEMPIERE-3350 Accounting Processor GL postings to "secondary" schema unreliable. Use savepoint to avoid rollback of doc workflow transaction.
This commit is contained in:
parent
2ac53ef2fd
commit
b4990515b0
|
@ -19,6 +19,7 @@ package org.compiere.acct;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Savepoint;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -286,8 +287,10 @@ public class DocManager {
|
||||||
|
|
||||||
Trx trx = Trx.get(trxName, true);
|
Trx trx = Trx.get(trxName, true);
|
||||||
String error = null;
|
String error = null;
|
||||||
|
Savepoint savepoint = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
savepoint = localTrxName == null ? trx.setSavepoint(null) : null;
|
||||||
String status = "";
|
String status = "";
|
||||||
for(MAcctSchema as : ass)
|
for(MAcctSchema as : ass)
|
||||||
{
|
{
|
||||||
|
@ -298,13 +301,19 @@ public class DocManager {
|
||||||
status = doc.getPostStatus();
|
status = doc.getPostStatus();
|
||||||
if (error != null && error.trim().length() > 0)
|
if (error != null && error.trim().length() > 0)
|
||||||
{
|
{
|
||||||
trx.rollback();
|
if (savepoint != null)
|
||||||
|
trx.rollback(savepoint);
|
||||||
|
else
|
||||||
|
trx.rollback();
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
trx.rollback();
|
if (savepoint != null)
|
||||||
|
trx.rollback(savepoint);
|
||||||
|
else
|
||||||
|
trx.rollback();
|
||||||
return "NoDoc";
|
return "NoDoc";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -319,15 +328,27 @@ public class DocManager {
|
||||||
if (localTrxName != null) {
|
if (localTrxName != null) {
|
||||||
if (trx != null)
|
if (trx != null)
|
||||||
trx.rollback();
|
trx.rollback();
|
||||||
|
} else if (trx != null && savepoint != null) {
|
||||||
|
trx.rollback(savepoint);
|
||||||
|
savepoint = null;
|
||||||
}
|
}
|
||||||
if (dbError != null)
|
if (dbError != null)
|
||||||
error = dbError.getValue();
|
error = dbError.getValue();
|
||||||
else
|
else
|
||||||
error = "SaveError";
|
error = "SaveError";
|
||||||
}
|
}
|
||||||
if (localTrxName != null) {
|
if (savepoint != null)
|
||||||
if (trx != null)
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
trx.releaseSavepoint(savepoint);
|
||||||
|
} catch (SQLException e1) {}
|
||||||
|
savepoint = null;
|
||||||
|
}
|
||||||
|
if (localTrxName != null && error == null) {
|
||||||
|
if (trx != null) {
|
||||||
trx.commit();
|
trx.commit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -335,6 +356,10 @@ public class DocManager {
|
||||||
if (localTrxName != null) {
|
if (localTrxName != null) {
|
||||||
if (trx != null)
|
if (trx != null)
|
||||||
trx.rollback();
|
trx.rollback();
|
||||||
|
} else if (trx != null && savepoint != null) {
|
||||||
|
try {
|
||||||
|
trx.rollback(savepoint);
|
||||||
|
} catch (SQLException e1) {}
|
||||||
}
|
}
|
||||||
if (e instanceof RuntimeException)
|
if (e instanceof RuntimeException)
|
||||||
throw (RuntimeException) e;
|
throw (RuntimeException) e;
|
||||||
|
|
Loading…
Reference in New Issue