Automated rollback of commit 2bc2efd8bd0af15bc727523a56fdcefe87e2f41d.
*** Reason for rollback ***
b/119861715
*** Original change description ***
bep: close the bep transports in afterCommand
Before this change we'd block an undefined SkyFrame thread when
waiting for the BEP/BES upload to finish. This would also not
allow us to reliably report errors. This change moves the waiting
to afterCommand() where one is allowed to block and can reliably
report errors by throwing an exception.
RELNOTES: None
PiperOrigin-RevId: 222549755
diff --git a/src/test/java/com/google/devtools/build/lib/runtime/BuildEventStreamerTest.java b/src/test/java/com/google/devtools/build/lib/runtime/BuildEventStreamerTest.java
index 9d054f7..7260a1e 100644
--- a/src/test/java/com/google/devtools/build/lib/runtime/BuildEventStreamerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/runtime/BuildEventStreamerTest.java
@@ -48,6 +48,7 @@
import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos;
import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.BuildEventId.NamedSetOfFilesId;
import com.google.devtools.build.lib.buildeventstream.BuildEventTransport;
+import com.google.devtools.build.lib.buildeventstream.BuildEventTransportClosedEvent;
import com.google.devtools.build.lib.buildeventstream.BuildEventWithConfiguration;
import com.google.devtools.build.lib.buildeventstream.BuildEventWithOrderConstraint;
import com.google.devtools.build.lib.buildeventstream.GenericBuildEvent;
@@ -70,6 +71,8 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.LockSupport;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -279,6 +282,11 @@
void transportsAnnounced(AnnounceBuildEventTransportsEvent evt) {
transportSet = Collections.synchronizedSet(new HashSet<>(evt.transports()));
}
+
+ @Subscribe
+ void transportClosed(BuildEventTransportClosedEvent evt) {
+ transportSet.remove(evt.transport());
+ }
}
@Before
@@ -327,6 +335,10 @@
assertThat(transport.getEventProtos().get(0).getLastMessage()).isFalse();
assertThat(transport.getEventProtos().get(1).getLastMessage()).isFalse();
assertThat(transport.getEventProtos().get(2).getLastMessage()).isTrue();
+
+ while (!handler.transportSet.isEmpty()) {
+ LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(100));
+ }
}
@Test