Skip to content

Fix IllegalState Attempting to use a Ccm rule while another is in use. This is disallowed issue #338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ 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);
throw e;
}
} 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 +56,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
Loading