Let AbstractSpawnStrategy be more robust against an interface that currently
doesn't always behave as advertised.

RELNOTES: None.
PiperOrigin-RevId: 211807540
diff --git a/src/main/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategy.java b/src/main/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategy.java
index 23e10a7..e186975 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategy.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/AbstractSpawnStrategy.java
@@ -81,7 +81,6 @@
       ActionExecutionContext actionExecutionContext,
       AtomicReference<Class<? extends SpawnActionContext>> writeOutputFiles)
       throws ExecException, InterruptedException {
-
     actionExecutionContext.maybeReportSubcommand(spawn);
 
     final Duration timeout = Spawns.getTimeout(spawn);
@@ -252,6 +251,12 @@
         return;
       }
 
+      // TODO(djasper): This should not happen as per the contract of ActionExecutionMetadata, but
+      // there are implementations that violate the contract. Remove when those are gone.
+      if (action.getPrimaryOutput() == null) {
+        return;
+      }
+
       // TODO(ulfjack): We should report more details to the UI.
       EventBus eventBus = actionExecutionContext.getEventBus();
       switch (state) {