From b50ae570922eb0fbc284fe08bd75cc2a047fc050 Mon Sep 17 00:00:00 2001 From: Dmitry Kropachev Date: Thu, 5 Sep 2024 23:45:18 -0400 Subject: [PATCH] 1 --- .../driver/api/testinfra/ccm/CustomCcmRule.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test-infra/src/main/java/com/datastax/oss/driver/api/testinfra/ccm/CustomCcmRule.java b/test-infra/src/main/java/com/datastax/oss/driver/api/testinfra/ccm/CustomCcmRule.java index 58bafd438f8..0c2f0b47dfe 100644 --- a/test-infra/src/main/java/com/datastax/oss/driver/api/testinfra/ccm/CustomCcmRule.java +++ b/test-infra/src/main/java/com/datastax/oss/driver/api/testinfra/ccm/CustomCcmRule.java @@ -39,7 +39,13 @@ public class CustomCcmRule extends BaseCcmRule { @Override protected void before() { if (CURRENT.get() == null && CURRENT.compareAndSet(null, this)) { - super.before(); + try { + super.before(); + } catch (Exception e) { + // If exception is thrown in this rule, `after` is not going to be executed and test suit is going to become broken + // So we need to drop CURRENT to let other tests run + CURRENT.set(null); + } } else if (CURRENT.get() != this) { throw new IllegalStateException( "Attempting to use a Ccm rule while another is in use. This is disallowed"); @@ -48,8 +54,11 @@ protected void before() { @Override protected void after() { - super.after(); - CURRENT.compareAndSet(this, null); + try { + super.after(); + } finally { + CURRENT.compareAndSet(this, null); + } } public CcmBridge getCcmBridge() {