Automated rollback of commit d59e82a235f6e6e3391cdbf7e4cb596f82b6416a.

*** Reason for rollback ***

Breaks com.google.devtools.build.lib.skyframe.MacOSXFsEventsDiffAwarenessTest on mac (https://buildkite.com/bazel/bazel-bazel/builds/7219#721977eb-8795-4ae1-b0b4-c02034219083)

*** Original change description ***

Trigger a "NoBuildEvent" in cases where we fail early in the BlazeCommandDispatcher.

This informs BEP logic that the build has failed, but otherwise doing an orderly completion.

RELNOTES: None
PiperOrigin-RevId: 238603678
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java
index eb0823b..52b8c17 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java
@@ -24,7 +24,6 @@
 import com.google.common.collect.ImmutableSet;
 import com.google.common.io.Flushables;
 import com.google.common.util.concurrent.UncheckedExecutionException;
-import com.google.devtools.build.lib.analysis.NoBuildEvent;
 import com.google.devtools.build.lib.bugreport.BugReport;
 import com.google.devtools.build.lib.buildtool.buildevent.ProfilerStartedEvent;
 import com.google.devtools.build.lib.clock.BlazeClock;
@@ -331,14 +330,7 @@
       // Early exit. We need to guarantee that the ErrOut and Reporter setup below never error out,
       // so any invariants they need must be checked before this point.
       if (!earlyExitCode.equals(ExitCode.SUCCESS)) {
-        return replayEarlyExitEvents(
-            outErr,
-            optionHandler,
-            storedEventHandler,
-            env,
-            earlyExitCode,
-            new NoBuildEvent(
-                commandName, firstContactTime, false, true, env.getCommandId().toString()));
+        return replayEarlyExitEvents(outErr, optionHandler, storedEventHandler, env, earlyExitCode);
       }
 
       Reporter reporter = env.getReporter();
@@ -496,14 +488,7 @@
       // Parse starlark options.
       earlyExitCode = optionHandler.parseStarlarkOptions(env, storedEventHandler);
       if (!earlyExitCode.equals(ExitCode.SUCCESS)) {
-        return replayEarlyExitEvents(
-            outErr,
-            optionHandler,
-            storedEventHandler,
-            env,
-            earlyExitCode,
-            new NoBuildEvent(
-                commandName, firstContactTime, false, true, env.getCommandId().toString()));
+        return replayEarlyExitEvents(outErr, optionHandler, storedEventHandler, env, earlyExitCode);
       }
       options = optionHandler.getOptionsResult();
 
@@ -544,8 +529,7 @@
       BlazeOptionHandler optionHandler,
       StoredEventHandler storedEventHandler,
       CommandEnvironment env,
-      ExitCode earlyExitCode,
-      NoBuildEvent noBuildEvent) {
+      ExitCode earlyExitCode) {
     PrintingEventHandler printingEventHandler =
         new PrintingEventHandler(outErr, EventKind.ALL_EVENTS);
     for (String note : optionHandler.getRcfileNotes()) {
@@ -557,7 +541,6 @@
     for (Postable post : storedEventHandler.getPosts()) {
       env.getEventBus().post(post);
     }
-    env.getEventBus().post(noBuildEvent);
     return BlazeCommandResult.exitCode(earlyExitCode);
   }