From 861c3caa85e47da35a8a4f1512e57d43b9263c37 Mon Sep 17 00:00:00 2001 From: Lars Clausen Date: Wed, 28 Jul 2021 12:11:15 +0200 Subject: [PATCH] Revert "Remote: Fix a race when reporting action progresses." This reverts commit 170e57d06326c8773cf3cfd3f3d73fda2e9c8cc5. --- .../build/lib/runtime/UiStateTracker.java | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/runtime/UiStateTracker.java b/src/main/java/com/google/devtools/build/lib/runtime/UiStateTracker.java index eef7ea5c64ae7c..c709eb36316840 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/UiStateTracker.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/UiStateTracker.java @@ -62,14 +62,12 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.PriorityQueue; import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import javax.annotation.Nullable; -import javax.annotation.concurrent.GuardedBy; import javax.annotation.concurrent.ThreadSafe; /** Tracks state for the UI. */ @@ -230,7 +228,6 @@ private ProgressState(String id, long nanoStartTime) { } } - @GuardedBy("this") private final LinkedHashMap runningProgresses = new LinkedHashMap<>(); /** Starts tracking the state of an action. */ @@ -336,13 +333,6 @@ synchronized void onProgressEvent(ActionProgressEvent event, long nanoChangeTime state.latestEvent = event; } - synchronized Optional firstProgress() { - if (runningProgresses.isEmpty()) { - return Optional.empty(); - } - return Optional.of(runningProgresses.entrySet().iterator().next().getValue()); - } - /** Generates a human-readable description of this action's state. */ synchronized String describe() { if (runningStrategiesBitmap != 0) { @@ -715,12 +705,12 @@ private String describeTestGroup( } private String describeActionProgress(ActionState action, int desiredWidth) { - Optional stateOpt = action.firstProgress(); - if (!stateOpt.isPresent()) { + if (action.runningProgresses.isEmpty()) { return ""; } - ActionState.ProgressState state = stateOpt.get(); + ActionState.ProgressState state = + action.runningProgresses.entrySet().iterator().next().getValue(); ActionProgressEvent event = state.latestEvent; String message = event.progress(); if (message.isEmpty()) {