From 3a97a86be8f20f0716a8c59427daec6ee85601d8 Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Fri, 27 Sep 2024 09:55:08 +0200 Subject: [PATCH] [Fix] Don't close a TX retrieved from TransactionThreadLocal.getTx() --- .../runtime/privilege/DefaultStrolchPrivilegeHandler.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/strolch-agent/src/main/java/li/strolch/runtime/privilege/DefaultStrolchPrivilegeHandler.java b/strolch-agent/src/main/java/li/strolch/runtime/privilege/DefaultStrolchPrivilegeHandler.java index 5bff9bb97..7fa1bf789 100644 --- a/strolch-agent/src/main/java/li/strolch/runtime/privilege/DefaultStrolchPrivilegeHandler.java +++ b/strolch-agent/src/main/java/li/strolch/runtime/privilege/DefaultStrolchPrivilegeHandler.java @@ -178,6 +178,14 @@ public boolean isRefreshAllowed() { } private void writeAudit(Certificate certificate, String login, AccessType accessType, String username) { + if (hasTx()) { + StrolchTransaction tx = getTx(); + tx.setSuppressAudits(true); + Audit audit = tx.auditFrom(accessType, PRIVILEGE, CERTIFICATE, username); + tx.getAuditTrail().add(tx, audit); + return; + } + StrolchRealm realm = getContainer().getRealm(certificate); try (StrolchTransaction tx = hasTx() ? getTx() : openTx(certificate, login, realm)) { tx.setSuppressAudits(true);