interop-testing: fix race in CascadingTest

ServerCall.close() is meant to only be accessed from a single thread, but in the test it is accessed from the callbacks of several client calls.  Synchronize access to sate TSAN.
This commit is contained in:
Carl Mastrangelo 2019-07-15 11:17:54 -07:00 committed by GitHub
parent 855740622a
commit c3d7d74175
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -295,8 +295,10 @@ public class CascadingTest {
Context.currentContextExecutor(otherWork).execute(new Runnable() { Context.currentContextExecutor(otherWork).execute(new Runnable() {
@Override @Override
public void run() { public void run() {
synchronized (call) {
call.close(Status.ABORTED, new Metadata()); call.close(Status.ABORTED, new Metadata());
} }
}
}); });
} else if (req.getResponseSize() != 0) { } else if (req.getResponseSize() != 0) {
// We are in a non leaf node so fire off two requests // We are in a non leaf node so fire off two requests
@ -316,7 +318,9 @@ public class CascadingTest {
} }
// Propagate closure upwards. // Propagate closure upwards.
try { try {
synchronized (call) {
call.close(status, new Metadata()); call.close(status, new Metadata());
}
} catch (IllegalStateException t2) { } catch (IllegalStateException t2) {
// Ignore error if already closed. // Ignore error if already closed.
} }