From d99f0b52d202bc36a4731652052b706e096a412f Mon Sep 17 00:00:00 2001 From: Michael Musgrove Date: Wed, 2 Aug 2023 17:38:22 +0100 Subject: [PATCH] Ensure the narayana-jta extension fully shuts down the recovery manager --- .../narayana/jta/runtime/NarayanaJtaRecorder.java | 10 ++++++++-- .../narayana/jta/runtime/QuarkusRecoveryService.java | 7 +++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/NarayanaJtaRecorder.java b/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/NarayanaJtaRecorder.java index 38b1b1293ae94..c73a1cddb39ca 100644 --- a/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/NarayanaJtaRecorder.java +++ b/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/NarayanaJtaRecorder.java @@ -16,7 +16,6 @@ import com.arjuna.ats.arjuna.common.arjPropertyManager; import com.arjuna.ats.arjuna.coordinator.TransactionReaper; import com.arjuna.ats.arjuna.coordinator.TxControl; -import com.arjuna.ats.arjuna.recovery.RecoveryManager; import com.arjuna.ats.internal.arjuna.objectstore.jdbc.JDBCStore; import com.arjuna.ats.jta.common.JTAEnvironmentBean; import com.arjuna.ats.jta.common.jtaPropertyManager; @@ -158,7 +157,14 @@ public void startRecoveryService(final TransactionManagerConfiguration transacti public void handleShutdown(ShutdownContext context, TransactionManagerConfiguration transactions) { context.addLastShutdownTask(() -> { if (transactions.enableRecovery) { - RecoveryManager.manager().terminate(true); + try { + QuarkusRecoveryService.getInstance().stop(); + } catch (Exception e) { + // the recovery manager throws IllegalStateException if it has already been shutdown + log.warn("The recovery manager has already been shutdown", e); + } finally { + QuarkusRecoveryService.getInstance().destroy(); + } } TransactionReaper.terminate(false); }); diff --git a/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/QuarkusRecoveryService.java b/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/QuarkusRecoveryService.java index 55ff7ae05fe22..923bcfe4625a1 100644 --- a/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/QuarkusRecoveryService.java +++ b/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/QuarkusRecoveryService.java @@ -51,4 +51,11 @@ public void create() { } xaResources.clear(); } + + @Override + public void destroy() { + super.destroy(); + isCreated = false; + recoveryManagerService = null; + } }