Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
dkropachev committed Sep 6, 2024
1 parent fe5d469 commit b50ae57
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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() {
Expand Down

0 comments on commit b50ae57

Please sign in to comment.