|
18 | 18 | import static com.google.common.base.Strings.nullToEmpty;
|
19 | 19 |
|
20 | 20 | import com.google.common.annotations.VisibleForTesting;
|
21 |
| -import com.google.common.collect.HashMultimap; |
22 | 21 | import com.google.common.collect.ImmutableList;
|
23 | 22 | import com.google.common.collect.ImmutableMap;
|
24 | 23 | import com.google.common.collect.ImmutableSet;
|
25 | 24 | import com.google.common.collect.Iterables;
|
26 |
| -import com.google.common.collect.Multimap; |
| 25 | +import com.google.common.collect.LinkedHashMultimap; |
| 26 | +import com.google.common.collect.SetMultimap; |
27 | 27 | import com.google.common.collect.Sets;
|
28 | 28 | import com.google.common.eventbus.AllowConcurrentEvents;
|
29 | 29 | import com.google.common.eventbus.Subscribe;
|
@@ -106,8 +106,11 @@ private enum RetentionDecision {
|
106 | 106 | @GuardedBy("this")
|
107 | 107 | private List<Pair<String, String>> bufferedStdoutStderrPairs = new ArrayList<>();
|
108 | 108 |
|
| 109 | + // Use LinkedHashMultimap to maintain a FIFO ordering of pending events. |
| 110 | + // This is important in case of Skymeld, so that the TestAttempt events are resolved in the |
| 111 | + // correct order. |
109 | 112 | @GuardedBy("this")
|
110 |
| - private final Multimap<BuildEventId, BuildEvent> pendingEvents = HashMultimap.create(); |
| 113 | + private final SetMultimap<BuildEventId, BuildEvent> pendingEvents = LinkedHashMultimap.create(); |
111 | 114 |
|
112 | 115 | @GuardedBy("this")
|
113 | 116 | private int progressCount;
|
@@ -493,11 +496,11 @@ public void buildEvent(BuildEvent event) {
|
493 | 496 | }
|
494 | 497 |
|
495 | 498 | // Reconsider all events blocked by the event just posted.
|
496 |
| - Collection<BuildEvent> toReconsider; |
| 499 | + Set<BuildEvent> blockedEventsFifo; |
497 | 500 | synchronized (this) {
|
498 |
| - toReconsider = pendingEvents.removeAll(event.getEventId()); |
| 501 | + blockedEventsFifo = pendingEvents.removeAll(event.getEventId()); |
499 | 502 | }
|
500 |
| - for (BuildEvent freedEvent : toReconsider) { |
| 503 | + for (BuildEvent freedEvent : blockedEventsFifo) { |
501 | 504 | buildEvent(freedEvent);
|
502 | 505 | }
|
503 | 506 |
|
@@ -558,14 +561,14 @@ private void maybePostPendingEventsBeforeDiscarding(BuildEvent event) {
|
558 | 561 | // a lot of extra locking e.g. for every ActionExecutedEvent and it's only necessary to
|
559 | 562 | // check for this where events are configured to "post after" events that may be discarded.
|
560 | 563 | BuildEventId eventId = event.getEventId();
|
561 |
| - Collection<BuildEvent> toReconsider; |
| 564 | + Set<BuildEvent> blockedEventsFifo; |
562 | 565 | synchronized (this) {
|
563 |
| - toReconsider = pendingEvents.removeAll(eventId); |
| 566 | + blockedEventsFifo = pendingEvents.removeAll(eventId); |
564 | 567 | // Pretend we posted this event so a target summary arriving after this test summary (which
|
565 | 568 | // is common) doesn't get erroneously buffered in bufferUntilPrerequisitesReceived().
|
566 | 569 | postedEvents.add(eventId);
|
567 | 570 | }
|
568 |
| - for (BuildEvent freedEvent : toReconsider) { |
| 571 | + for (BuildEvent freedEvent : blockedEventsFifo) { |
569 | 572 | buildEvent(freedEvent);
|
570 | 573 | }
|
571 | 574 | }
|
|
0 commit comments