Skip to content

Commit

Permalink
Fix #301: Change transaction propagation of DatabaseAuditWriter#flush…
Browse files Browse the repository at this point in the history
… to REQUIRES_NEW
  • Loading branch information
banterCZ committed Jun 13, 2024
1 parent 1c952d3 commit 9f915e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -159,6 +160,7 @@ public void flush() {
}

synchronized (FLUSH_LOCK) {
transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
transactionTemplate.executeWithoutResult(status -> {
while (!queue.isEmpty()) {
try {
Expand Down
2 changes: 2 additions & 0 deletions audit-base/src/test/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Audit configuration
spring.application.name=test-application

spring.datasource.hikari.auto-commit=false

0 comments on commit 9f915e6

Please sign in to comment.