Skip to content

Commit

Permalink
Fix Edge Case Running Status of Sandbox (#205)
Browse files Browse the repository at this point in the history
* Fix Edge Case Running Status of Sandbox

* Proper Fix
  • Loading branch information
IntegerLimit authored Jul 23, 2024
1 parent 81fd37e commit cca1525
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,16 @@ protected void runScript(Script script){
}

public <T> T runClosure(Closure<T> closure, Object... args) {
startRunning();
boolean wasRunning = isRunning();
if (!wasRunning) startRunning();
T result = null;
try {
result = closure.call(args);
} catch (Exception e) {
GroovyScript.LOGGER.error("Caught an exception trying to run a closure:");
e.printStackTrace();
} finally {
stopRunning();
if (!wasRunning) stopRunning();
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ public void load() throws Exception {
@ApiStatus.Internal
@Override
public <T> T runClosure(Closure<T> closure, Object... args) {
startRunning();
boolean wasRunning = isRunning();
if (!wasRunning) startRunning();
T result = null;
try {
result = runClosureInternal(closure, args);
Expand All @@ -189,7 +190,7 @@ public <T> T runClosure(Closure<T> closure, Object... args) {
return new AtomicInteger();
}).addAndGet(1);
} finally {
stopRunning();
if (!wasRunning) stopRunning();
}
return result;
}
Expand Down

0 comments on commit cca1525

Please sign in to comment.