From 9f915e66bd8c6f3419f4247ab6fd6d1e1012084b Mon Sep 17 00:00:00 2001 From: Lubos Racansky Date: Thu, 13 Jun 2024 14:26:11 +0200 Subject: [PATCH] Fix #301: Change transaction propagation of DatabaseAuditWriter#flush to REQUIRES_NEW --- .../wultra/core/audit/base/database/DatabaseAuditWriter.java | 2 ++ audit-base/src/test/resources/application.properties | 2 ++ 2 files changed, 4 insertions(+) diff --git a/audit-base/src/main/java/com/wultra/core/audit/base/database/DatabaseAuditWriter.java b/audit-base/src/main/java/com/wultra/core/audit/base/database/DatabaseAuditWriter.java index c57ac5a..a4d75ea 100644 --- a/audit-base/src/main/java/com/wultra/core/audit/base/database/DatabaseAuditWriter.java +++ b/audit-base/src/main/java/com/wultra/core/audit/base/database/DatabaseAuditWriter.java @@ -31,6 +31,7 @@ import org.springframework.jdbc.core.PreparedStatementCallback; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; +import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.support.TransactionTemplate; import org.springframework.util.StringUtils; @@ -159,6 +160,7 @@ public void flush() { } synchronized (FLUSH_LOCK) { + transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); transactionTemplate.executeWithoutResult(status -> { while (!queue.isEmpty()) { try { diff --git a/audit-base/src/test/resources/application.properties b/audit-base/src/test/resources/application.properties index d47f7a9..cb3d705 100644 --- a/audit-base/src/test/resources/application.properties +++ b/audit-base/src/test/resources/application.properties @@ -1,2 +1,4 @@ # Audit configuration spring.application.name=test-application + +spring.datasource.hikari.auto-commit=false