From 6a4ece291cb50bb93f484647fa0ec434333b2d55 Mon Sep 17 00:00:00 2001 From: Michael Seaton Date: Wed, 29 Oct 2025 16:52:20 -0400 Subject: [PATCH] SYNC-370 - Ensure thread locale variables are cleaned up properly in the interceptor --- .../sync/api/db/hibernate/HibernateSyncInterceptor.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/org/openmrs/module/sync/api/db/hibernate/HibernateSyncInterceptor.java b/api/src/main/java/org/openmrs/module/sync/api/db/hibernate/HibernateSyncInterceptor.java index 8fa21a6..a461431 100644 --- a/api/src/main/java/org/openmrs/module/sync/api/db/hibernate/HibernateSyncInterceptor.java +++ b/api/src/main/java/org/openmrs/module/sync/api/db/hibernate/HibernateSyncInterceptor.java @@ -1690,10 +1690,13 @@ public SyncRecord getSyncRecordForCurrentTx() { public SyncRecord endTransaction(Transaction tx) { SyncRecord record = syncRecords.remove(tx); Transaction expected = transactions.pop(); + processRegistered.remove(tx); + if (transactions.isEmpty()) { + syncRecordThreadLocal.remove(); + } if (record == null || expected == null || !expected.equals(tx)) { throw new IllegalStateException("Ending transaction did not find the expected transaction on the stack"); } - syncRecordThreadLocal.get().setProcessRegistered(tx, false); return record; } }