Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ private enum PessimisticLockingFailureCode {

ROLLBACK("40"), // Transaction rollback
DEADLOCK("60"), // Oracle: deadlock
HY00("HY", "Lock wait timeout exceeded"), // MySql deadlock HY00
;
HY00("HY", "Lock wait timeout exceeded"), SNAPSHOT_CONFLICT("HY", "Record has changed since last read");

private final String code;
private final String msg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
public class SavingsAccountTransactionTest {

private static final Logger log = LoggerFactory.getLogger(SavingsAccountTransactionTest.class);

private static final String RECORD_CHANGED_SINCE_LAST_READ = "Record has changed since last read";
public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
final String startDateString = "03 June 2023";
final String depositDateString = "05 June 2023";
Expand Down Expand Up @@ -381,8 +381,12 @@ public void run() {
assertNotNull(responses, "Responses");
if (enclosingTransaction) {
Integer statusCode1 = responses.get(0).getStatusCode();
String msg1 = Strings.nullToEmpty(responses.get(0).getBody());
assertNotNull(statusCode1, "First enlosingTransaction response status code");
assertTrue(SC_OK == statusCode1 || SC_CONFLICT == statusCode1, "Status code: " + statusCode1);
assertTrue(
SC_OK == statusCode1 || SC_CONFLICT == statusCode1
|| (SC_FORBIDDEN == statusCode1 && msg1.contains(RECORD_CHANGED_SINCE_LAST_READ)),
"Status code: " + statusCode1 + ", message: " + msg1);
if (SC_OK == statusCode1) {
assertEquals(4, responses.size(), "Response size for enlosingTransaction OK response");
Integer statusCode4 = responses.get(3).getStatusCode();
Expand All @@ -394,16 +398,20 @@ public void run() {
} else {
assertEquals(4, responses.size(), "Response size for without-enlosingTransaction response");
Integer statusCode1 = responses.get(0).getStatusCode();
String msg1 = Strings.nullToEmpty(responses.get(0).getBody());
assertNotNull(statusCode1, "First without-enlosingTransaction response status code");
assertTrue(SC_OK == statusCode1 || SC_CONFLICT == statusCode1,
"First without-enlosingTransaction response status code: " + statusCode1);
assertTrue(
SC_OK == statusCode1 || SC_CONFLICT == statusCode1
|| (SC_FORBIDDEN == statusCode1 && msg1.contains(RECORD_CHANGED_SINCE_LAST_READ)),
"First without-enlosingTransaction response status code: " + statusCode1 + ", message: " + msg1);
Integer statusCode4 = responses.get(3).getStatusCode();
assertNotNull(statusCode4, "Last without-enlosingTransaction response status code");
assertTrue(
SC_OK == statusCode1 ? (SC_OK == statusCode4 || SC_CONFLICT == statusCode4)
: (SC_FORBIDDEN == statusCode4 || SC_CONFLICT == statusCode4),
"Last without-enlosingTransaction response status code: " + statusCode4);
}

} else {
String json = transactionData.getJson();
String response = (String) this.savingsHelper.depositToSavingsAccount(savingsId, json, null);
Expand Down Expand Up @@ -445,7 +453,8 @@ private void runDeadlockBatch(SavingsAccountHelper savingsHelper, Integer saving
assertNotNull(statusCode, "First response status code");
assertTrue(
SC_OK == statusCode || SC_CONFLICT == statusCode
|| (SC_FORBIDDEN == statusCode && msg.contains("Cannot add or update a child row")),
|| (SC_FORBIDDEN == statusCode
&& (msg.contains("Cannot add or update a child row") || msg.contains(RECORD_CHANGED_SINCE_LAST_READ))),
"Status code: " + statusCode + ", message: " + msg);
if (SC_OK == statusCode) {
assertEquals(4, responses.size(), "Response size for OK response");
Expand Down