Skip to content

Commit

Permalink
Merge pull request #188 from Pldi23/flakebusters
Browse files Browse the repository at this point in the history
Fix flakiness by synchronising the State
  • Loading branch information
jglick authored Aug 2, 2022
2 parents 4b6f6ff + e7db03f commit a3a087b
Showing 1 changed file with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,15 @@ public void success(Object returnValue) {

public static void success(String k, Object returnValue) {
State s = State.get();
if (s.contexts.containsKey(k)) {
System.err.println("Unblocking " + k + " as success");
getContext(s, k).onSuccess(returnValue);
} else {
System.err.println("Planning to unblock " + k + " as success");
s.returnValues.put(k, returnValue);
synchronized (s) {
if (!s.contexts.containsKey(k)) {
System.err.println("Planning to unblock " + k + " as success");
s.returnValues.put(k, returnValue);
return;
}
}
System.err.println("Unblocking " + k + " as success");
getContext(s, k).onSuccess(returnValue);
}

/** Marks the step as having failed; or, if not yet started, makes it do so synchronously when started. */
Expand All @@ -119,13 +121,15 @@ public void failure(Throwable error) {

public static void failure(String k, Throwable error) {
State s = State.get();
if (s.contexts.containsKey(k)) {
System.err.println("Unblocking " + k + " as failure");
getContext(s, k).onFailure(error);
} else {
System.err.println("Planning to unblock " + k + " as failure");
s.errors.put(k, error);
synchronized (s) {
if (!s.contexts.containsKey(k)) {
System.err.println("Planning to unblock " + k + " as failure");
s.errors.put(k, error);
return;
}
}
System.err.println("Unblocking " + k + " as failure");
getContext(s, k).onFailure(error);
}

public StepContext getContext() {
Expand Down

0 comments on commit a3a087b

Please sign in to comment.