Inject the product name in the constructor where needed

...instead of passing it everywhere so we can rewrite the local env.

PiperOrigin-RevId: 186316859
diff --git a/src/main/java/com/google/devtools/build/lib/exec/apple/XCodeLocalEnvProvider.java b/src/main/java/com/google/devtools/build/lib/exec/apple/XCodeLocalEnvProvider.java
index b0acfbf..553fef0 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/apple/XCodeLocalEnvProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/apple/XCodeLocalEnvProvider.java
@@ -47,6 +47,7 @@
   private static final String XCRUN_CACHE_FILENAME = "__xcruncache";
   private static final String XCODE_LOCATOR_CACHE_FILENAME = "__xcodelocatorcache";
 
+  private final String productName;
   private final Map<String, String> clientEnv;
 
   /**
@@ -54,13 +55,14 @@
    *
    * @param clientEnv a map of the current Bazel command's environment
    */
-  public XCodeLocalEnvProvider(Map<String, String> clientEnv) {
+  public XCodeLocalEnvProvider(String productName, Map<String, String> clientEnv) {
+    this.productName = productName;
     this.clientEnv = clientEnv;
   }
 
   @Override
   public Map<String, String> rewriteLocalEnv(
-      Map<String, String> env, Path execRoot, String fallbackTmpDir, String productName)
+      Map<String, String> env, Path execRoot, String fallbackTmpDir)
       throws IOException {
     boolean containsXcodeVersion = env.containsKey(AppleConfiguration.XCODE_VERSION_ENV_NAME);
     boolean containsAppleSdkVersion =
diff --git a/src/main/java/com/google/devtools/build/lib/exec/local/LocalEnvProvider.java b/src/main/java/com/google/devtools/build/lib/exec/local/LocalEnvProvider.java
index 4007565..5af7a19 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/local/LocalEnvProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/local/LocalEnvProvider.java
@@ -27,7 +27,7 @@
       new LocalEnvProvider() {
         @Override
         public Map<String, String> rewriteLocalEnv(
-            Map<String, String> env, Path execRoot, String fallbackTmpDir, String productName) {
+            Map<String, String> env, Path execRoot, String fallbackTmpDir) {
           return env;
         }
       };
@@ -41,9 +41,8 @@
    *     particular implementation of {@link LocalEnvProvider} may choose to use some other path,
    *     typically the "TMPDIR" environment variable in the Bazel client's environment, but if
    *     that's unavailable, the implementation may decide to use this {@code fallbackTmpDir}.
-   * @param productName name of the Bazel binary, e.g. "bazel"
    */
   Map<String, String> rewriteLocalEnv(
-      Map<String, String> env, Path execRoot, String fallbackTmpDir, String productName)
+      Map<String, String> env, Path execRoot, String fallbackTmpDir)
       throws IOException;
 }
diff --git a/src/main/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunner.java
index de2c06f..c695fd6 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunner.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunner.java
@@ -76,7 +76,6 @@
   private final boolean useProcessWrapper;
   private final String processWrapper;
 
-  private final String productName;
   private final LocalEnvProvider localEnvProvider;
 
   // TODO(b/62588075): Move this logic to ProcessWrapperUtil?
@@ -90,7 +89,6 @@
       ResourceManager resourceManager,
       boolean useProcessWrapper,
       OS localOs,
-      String productName,
       LocalEnvProvider localEnvProvider) {
     this.execRoot = execRoot;
     this.processWrapper = getProcessWrapper(execRoot, localOs).getPathString();
@@ -98,7 +96,6 @@
     this.hostName = NetUtil.getCachedShortHostName();
     this.resourceManager = resourceManager;
     this.useProcessWrapper = useProcessWrapper;
-    this.productName = productName;
     this.localEnvProvider = localEnvProvider;
   }
 
@@ -106,7 +103,6 @@
       Path execRoot,
       LocalExecutionOptions localExecutionOptions,
       ResourceManager resourceManager,
-      String productName,
       LocalEnvProvider localEnvProvider) {
     this(
         execRoot,
@@ -114,7 +110,6 @@
         resourceManager,
         OS.getCurrent() != OS.WINDOWS && getProcessWrapper(execRoot, OS.getCurrent()).exists(),
         OS.getCurrent(),
-        productName,
         localEnvProvider);
   }
 
@@ -255,6 +250,9 @@
         OutputStream stdErr;
         Path commandTmpDir = tmpDir.getRelative("work");
         commandTmpDir.createDirectory();
+        Map<String, String> environment =
+            localEnvProvider.rewriteLocalEnv(
+                spawn.getEnvironment(), execRoot, commandTmpDir.getPathString());
         if (useProcessWrapper) {
           // If the process wrapper is enabled, we use its timeout feature, which first interrupts
           // the subprocess and only kills it after a grace period so that the subprocess can output
@@ -277,8 +275,7 @@
           cmd =
               new Command(
                   cmdLine.toArray(new String[0]),
-                  localEnvProvider.rewriteLocalEnv(
-                      spawn.getEnvironment(), execRoot, commandTmpDir.getPathString(), productName),
+                  environment,
                   execRoot.getPathFile());
         } else {
           stdOut = outErr.getOutputStream();
@@ -286,8 +283,7 @@
           cmd =
               new Command(
                   spawn.getArguments().toArray(new String[0]),
-                  localEnvProvider.rewriteLocalEnv(
-                      spawn.getEnvironment(), execRoot, commandTmpDir.getPathString(), productName),
+                  environment,
                   execRoot.getPathFile(),
                   policy.getTimeout());
         }
diff --git a/src/main/java/com/google/devtools/build/lib/exec/local/PosixLocalEnvProvider.java b/src/main/java/com/google/devtools/build/lib/exec/local/PosixLocalEnvProvider.java
index 1a30d3b..7a8bbe9 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/local/PosixLocalEnvProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/local/PosixLocalEnvProvider.java
@@ -41,7 +41,7 @@
    */
   @Override
   public Map<String, String> rewriteLocalEnv(
-      Map<String, String> env, Path execRoot, String fallbackTmpDir, String productName) {
+      Map<String, String> env, Path execRoot, String fallbackTmpDir) {
     ImmutableMap.Builder<String, String> result = ImmutableMap.builder();
     result.putAll(Maps.filterKeys(env, k -> !k.equals("TMPDIR")));
     String p = clientEnv.get("TMPDIR");
diff --git a/src/main/java/com/google/devtools/build/lib/exec/local/WindowsLocalEnvProvider.java b/src/main/java/com/google/devtools/build/lib/exec/local/WindowsLocalEnvProvider.java
index 91e218b..96ce78e 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/local/WindowsLocalEnvProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/local/WindowsLocalEnvProvider.java
@@ -48,7 +48,7 @@
    */
   @Override
   public Map<String, String> rewriteLocalEnv(
-      Map<String, String> env, Path execRoot, String fallbackTmpDir, String productName) {
+      Map<String, String> env, Path execRoot, String fallbackTmpDir) {
     ImmutableMap.Builder<String, String> result = ImmutableMap.builder();
     result.putAll(Maps.filterKeys(env, k -> !k.equals("TMP") && !k.equals("TEMP")));
     String p = clientEnv.get("TMP");
diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteActionContextProvider.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteActionContextProvider.java
index a3bcb4c..c761c10 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/RemoteActionContextProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteActionContextProvider.java
@@ -93,7 +93,7 @@
         env.getOptions().getOptions(LocalExecutionOptions.class);
     LocalEnvProvider localEnvProvider =
         OS.getCurrent() == OS.DARWIN
-            ? new XCodeLocalEnvProvider(env.getClientEnv())
+            ? new XCodeLocalEnvProvider(env.getRuntime().getProductName(), env.getClientEnv())
             : (OS.getCurrent() == OS.WINDOWS
                 ? new WindowsLocalEnvProvider(env.getClientEnv())
                 : new PosixLocalEnvProvider(env.getClientEnv()));
@@ -102,7 +102,6 @@
             env.getExecRoot(),
             localExecutionOptions,
             ResourceManager.instance(),
-            env.getRuntime().getProductName(),
             localEnvProvider);
   }
 
diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/DarwinSandboxedSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/sandbox/DarwinSandboxedSpawnRunner.java
index ebd75bf..9d924e9 100644
--- a/src/main/java/com/google/devtools/build/lib/sandbox/DarwinSandboxedSpawnRunner.java
+++ b/src/main/java/com/google/devtools/build/lib/sandbox/DarwinSandboxedSpawnRunner.java
@@ -150,7 +150,8 @@
     this.productName = productName;
     this.alwaysWritableDirs = getAlwaysWritableDirs(cmdEnv.getRuntime().getFileSystem());
     this.processWrapper = ProcessWrapperUtil.getProcessWrapper(cmdEnv);
-    this.localEnvProvider = new XCodeLocalEnvProvider(cmdEnv.getClientEnv());
+    this.localEnvProvider =
+        new XCodeLocalEnvProvider(cmdEnv.getRuntime().getProductName(), cmdEnv.getClientEnv());
     this.timeoutKillDelay = timeoutKillDelay;
   }
 
@@ -223,8 +224,7 @@
     Path tmpDir = sandboxExecRoot.getRelative("tmp");
 
     Map<String, String> environment =
-        localEnvProvider.rewriteLocalEnv(
-            spawn.getEnvironment(), execRoot, tmpDir.getPathString(), productName);
+        localEnvProvider.rewriteLocalEnv(spawn.getEnvironment(), execRoot, tmpDir.getPathString());
 
     final HashSet<Path> writableDirs = new HashSet<>(alwaysWritableDirs);
     ImmutableSet<Path> extraWritableDirs = getWritableDirs(sandboxExecRoot, environment);
diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java
index ad677f1..bd21c1b 100644
--- a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java
+++ b/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedSpawnRunner.java
@@ -85,66 +85,12 @@
   private final Path inaccessibleHelperDir;
   private final LocalEnvProvider localEnvProvider;
   private final Optional<Duration> timeoutKillDelay;
-  private final String productName;
-
-  /**
-   * Creates a sandboxed spawn runner that uses the {@code linux-sandbox} tool. If a spawn exceeds
-   * its timeout, then it will be killed instantly.
-   *
-   * @param cmdEnv the command environment to use
-   * @param sandboxBase path to the sandbox base directory
-   * @param productName the product name to use
-   * @param inaccessibleHelperFile path to a file that is (already) inaccessible
-   * @param inaccessibleHelperDir path to a directory that is (already) inaccessible
-   */
-  LinuxSandboxedSpawnRunner(
-      CommandEnvironment cmdEnv,
-      Path sandboxBase,
-      String productName,
-      Path inaccessibleHelperFile,
-      Path inaccessibleHelperDir) {
-    this(
-        cmdEnv,
-        sandboxBase,
-        productName,
-        inaccessibleHelperFile,
-        inaccessibleHelperDir,
-        Optional.empty());
-  }
-
-  /**
-   * Creates a sandboxed spawn runner that uses the {@code linux-sandbox} tool. If a spawn exceeds
-   * its timeout, then it will be killed after the specified delay.
-   *
-   * @param cmdEnv the command environment to use
-   * @param sandboxBase path to the sandbox base directory
-   * @param productName the product name to use
-   * @param inaccessibleHelperFile path to a file that is (already) inaccessible
-   * @param inaccessibleHelperDir path to a directory that is (already) inaccessible
-   * @param timeoutKillDelay an additional grace period before killing timing out commands
-   */
-  LinuxSandboxedSpawnRunner(
-      CommandEnvironment cmdEnv,
-      Path sandboxBase,
-      String productName,
-      Path inaccessibleHelperFile,
-      Path inaccessibleHelperDir,
-      Duration timeoutKillDelay) {
-    this(
-        cmdEnv,
-        sandboxBase,
-        productName,
-        inaccessibleHelperFile,
-        inaccessibleHelperDir,
-        Optional.of(timeoutKillDelay));
-  }
 
   /**
    * Creates a sandboxed spawn runner that uses the {@code linux-sandbox} tool.
    *
    * @param cmdEnv the command environment to use
    * @param sandboxBase path to the sandbox base directory
-   * @param productName the product name to use
    * @param inaccessibleHelperFile path to a file that is (already) inaccessible
    * @param inaccessibleHelperDir path to a directory that is (already) inaccessible
    * @param timeoutKillDelay an optional, additional grace period before killing timing out
@@ -153,7 +99,6 @@
   LinuxSandboxedSpawnRunner(
       CommandEnvironment cmdEnv,
       Path sandboxBase,
-      String productName,
       Path inaccessibleHelperFile,
       Path inaccessibleHelperDir,
       Optional<Duration> timeoutKillDelay) {
@@ -161,7 +106,6 @@
     this.fileSystem = cmdEnv.getRuntime().getFileSystem();
     this.blazeDirs = cmdEnv.getDirectories();
     this.execRoot = cmdEnv.getExecRoot();
-    this.productName = productName;
     this.allowNetwork = SandboxHelpers.shouldAllowNetwork(cmdEnv.getOptions());
     this.linuxSandbox = LinuxSandboxUtil.getLinuxSandbox(cmdEnv);
     this.inaccessibleHelperFile = inaccessibleHelperFile;
@@ -182,8 +126,7 @@
     Path tmpDir = sandboxExecRoot.getRelative("tmp");
 
     Map<String, String> environment =
-        localEnvProvider.rewriteLocalEnv(
-            spawn.getEnvironment(), execRoot, tmpDir.getPathString(), productName);
+        localEnvProvider.rewriteLocalEnv(spawn.getEnvironment(), execRoot, tmpDir.getPathString());
 
     Set<Path> writableDirs = getWritableDirs(sandboxExecRoot, environment);
     ImmutableSet<PathFragment> outputs = SandboxHelpers.getOutputFiles(spawn);
diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategy.java b/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategy.java
index 9e665db..360fcbb 100644
--- a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategy.java
+++ b/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategy.java
@@ -99,7 +99,6 @@
     return new LinuxSandboxedSpawnRunner(
         cmdEnv,
         sandboxBase,
-        productName,
         inaccessibleHelperFile,
         inaccessibleHelperDir,
         timeoutKillDelay);
diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/ProcessWrapperSandboxedSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/sandbox/ProcessWrapperSandboxedSpawnRunner.java
index 18b33c2..60bd17a 100644
--- a/src/main/java/com/google/devtools/build/lib/sandbox/ProcessWrapperSandboxedSpawnRunner.java
+++ b/src/main/java/com/google/devtools/build/lib/sandbox/ProcessWrapperSandboxedSpawnRunner.java
@@ -37,7 +37,6 @@
   }
 
   private final Path execRoot;
-  private final String productName;
   private final Path processWrapper;
   private final LocalEnvProvider localEnvProvider;
   private final Optional<Duration> timeoutKillDelay;
@@ -85,12 +84,11 @@
       Optional<Duration> timeoutKillDelay) {
     super(cmdEnv, sandboxBase);
     this.execRoot = cmdEnv.getExecRoot();
-    this.productName = productName;
     this.timeoutKillDelay = timeoutKillDelay;
     this.processWrapper = ProcessWrapperUtil.getProcessWrapper(cmdEnv);
     this.localEnvProvider =
         OS.getCurrent() == OS.DARWIN
-            ? new XCodeLocalEnvProvider(cmdEnv.getClientEnv())
+            ? new XCodeLocalEnvProvider(productName, cmdEnv.getClientEnv())
             : new PosixLocalEnvProvider(cmdEnv.getClientEnv());
   }
 
@@ -106,8 +104,7 @@
     Path tmpDir = sandboxExecRoot.getRelative("tmp");
 
     Map<String, String> environment =
-        localEnvProvider.rewriteLocalEnv(
-            spawn.getEnvironment(), execRoot, tmpDir.getPathString(), productName);
+        localEnvProvider.rewriteLocalEnv(spawn.getEnvironment(), execRoot, tmpDir.getPathString());
 
     Duration timeout = policy.getTimeout();
     ProcessWrapperUtil.CommandLineBuilder commandLineBuilder =
diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/SandboxActionContextProvider.java b/src/main/java/com/google/devtools/build/lib/sandbox/SandboxActionContextProvider.java
index 24a08c4..3e4af21 100644
--- a/src/main/java/com/google/devtools/build/lib/sandbox/SandboxActionContextProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/sandbox/SandboxActionContextProvider.java
@@ -100,14 +100,13 @@
         env.getOptions().getOptions(LocalExecutionOptions.class);
     LocalEnvProvider localEnvProvider =
         OS.getCurrent() == OS.DARWIN
-            ? new XCodeLocalEnvProvider(env.getClientEnv())
+            ? new XCodeLocalEnvProvider(env.getRuntime().getProductName(), env.getClientEnv())
             : new PosixLocalEnvProvider(env.getClientEnv());
     return
         new LocalSpawnRunner(
             env.getExecRoot(),
             localExecutionOptions,
             ResourceManager.instance(),
-            env.getRuntime().getProductName(),
             localEnvProvider);
   }
 
diff --git a/src/main/java/com/google/devtools/build/lib/standalone/StandaloneActionContextProvider.java b/src/main/java/com/google/devtools/build/lib/standalone/StandaloneActionContextProvider.java
index efdf7e5..c3ee188 100644
--- a/src/main/java/com/google/devtools/build/lib/standalone/StandaloneActionContextProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/standalone/StandaloneActionContextProvider.java
@@ -72,7 +72,7 @@
         env.getOptions().getOptions(LocalExecutionOptions.class);
     LocalEnvProvider localEnvProvider =
         OS.getCurrent() == OS.DARWIN
-            ? new XCodeLocalEnvProvider(env.getClientEnv())
+            ? new XCodeLocalEnvProvider(env.getRuntime().getProductName(), env.getClientEnv())
             : (OS.getCurrent() == OS.WINDOWS
                 ? new WindowsLocalEnvProvider(env.getClientEnv())
                 : new PosixLocalEnvProvider(env.getClientEnv()));
@@ -81,7 +81,6 @@
             env.getExecRoot(),
             localExecutionOptions,
             ResourceManager.instance(),
-            env.getRuntime().getProductName(),
             localEnvProvider);
   }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/worker/WorkerActionContextProvider.java b/src/main/java/com/google/devtools/build/lib/worker/WorkerActionContextProvider.java
index 9c1a834..f0b2070 100644
--- a/src/main/java/com/google/devtools/build/lib/worker/WorkerActionContextProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/worker/WorkerActionContextProvider.java
@@ -59,7 +59,7 @@
         env.getOptions().getOptions(LocalExecutionOptions.class);
     LocalEnvProvider localEnvProvider =
         OS.getCurrent() == OS.DARWIN
-            ? new XCodeLocalEnvProvider(env.getClientEnv())
+            ? new XCodeLocalEnvProvider(env.getRuntime().getProductName(), env.getClientEnv())
             : (OS.getCurrent() == OS.WINDOWS
                 ? new WindowsLocalEnvProvider(env.getClientEnv())
                 : new PosixLocalEnvProvider(env.getClientEnv()));
@@ -67,7 +67,6 @@
         env.getExecRoot(),
         localExecutionOptions,
         ResourceManager.instance(),
-        env.getRuntime().getProductName(),
         localEnvProvider);
   }
 
diff --git a/src/test/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunnerTest.java b/src/test/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunnerTest.java
index 54f0989..11312c8 100644
--- a/src/test/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunnerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunnerTest.java
@@ -92,7 +92,6 @@
         ResourceManager resourceManager,
         boolean useProcessWrapper,
         OS localOs,
-        String productName,
         LocalEnvProvider localEnvProvider) {
       super(
           execRoot,
@@ -100,7 +99,6 @@
           resourceManager,
           useProcessWrapper,
           localOs,
-          productName,
           localEnvProvider);
     }
 
@@ -310,7 +308,6 @@
             resourceManager,
             USE_WRAPPER,
             OS.LINUX,
-            "product-name",
             LocalEnvProvider.UNMODIFIED);
 
     FileOutErr fileOutErr = new FileOutErr(fs.getPath("/out/stdout"), fs.getPath("/out/stderr"));
@@ -365,7 +362,6 @@
             resourceManager,
             NO_WRAPPER,
             OS.LINUX,
-            "product-name",
             LocalEnvProvider.UNMODIFIED);
 
     FileOutErr fileOutErr = new FileOutErr(fs.getPath("/out/stdout"), fs.getPath("/out/stderr"));
@@ -410,7 +406,6 @@
             resourceManager,
             USE_WRAPPER,
             OS.LINUX,
-            "product-name",
             LocalEnvProvider.UNMODIFIED);
 
     assertThat(fs.getPath("/execroot").createDirectory()).isTrue();
@@ -456,7 +451,6 @@
             resourceManager,
             USE_WRAPPER,
             OS.LINUX,
-            "product-name",
             LocalEnvProvider.UNMODIFIED);
 
     assertThat(fs.getPath("/out").createDirectory()).isTrue();
@@ -492,7 +486,6 @@
             resourceManager,
             USE_WRAPPER,
             OS.LINUX,
-            "product-name",
             LocalEnvProvider.UNMODIFIED);
 
     assertThat(fs.getPath("/execroot").createDirectory()).isTrue();
@@ -543,7 +536,6 @@
             resourceManager,
             USE_WRAPPER,
             OS.LINUX,
-            "product-name",
             LocalEnvProvider.UNMODIFIED);
 
     FileOutErr fileOutErr = new FileOutErr(fs.getPath("/out/stdout"), fs.getPath("/out/stderr"));
@@ -575,7 +567,6 @@
             resourceManager,
             USE_WRAPPER,
             OS.LINUX,
-            "product-name",
             LocalEnvProvider.UNMODIFIED);
 
     FileOutErr fileOutErr = new FileOutErr(fs.getPath("/out/stdout"), fs.getPath("/out/stderr"));
@@ -602,7 +593,6 @@
             resourceManager,
             USE_WRAPPER,
             OS.LINUX,
-            "product-name",
             LocalEnvProvider.UNMODIFIED);
 
     FileOutErr fileOutErr = new FileOutErr(fs.getPath("/out/stdout"), fs.getPath("/out/stderr"));
@@ -633,7 +623,6 @@
             resourceManager,
             USE_WRAPPER,
             OS.LINUX,
-            "product-name",
             localEnvProvider);
 
     FileOutErr fileOutErr = new FileOutErr(fs.getPath("/out/stdout"), fs.getPath("/out/stderr"));
@@ -646,8 +635,7 @@
         .rewriteLocalEnv(
             any(),
             eq(fs.getPath("/execroot")),
-            matches("^/execroot/tmp[0-9a-fA-F]+_[0-9a-fA-F]+/work$"),
-            eq("product-name"));
+            matches("^/execroot/tmp[0-9a-fA-F]+_[0-9a-fA-F]+/work$"));
   }
 
   @Test
@@ -673,7 +661,6 @@
             resourceManager,
             USE_WRAPPER,
             OS.WINDOWS,
-            "product-name",
             LocalEnvProvider.UNMODIFIED);
 
     FileOutErr fileOutErr = new FileOutErr(fs.getPath("/out/stdout"), fs.getPath("/out/stderr"));
@@ -798,7 +785,6 @@
             resourceManager,
             USE_WRAPPER,
             OS.LINUX,
-            "product-name",
             LocalEnvProvider.UNMODIFIED);
 
     Spawn spawn =
@@ -860,7 +846,6 @@
             resourceManager,
             USE_WRAPPER,
             OS.LINUX,
-            "product-name",
             LocalEnvProvider.UNMODIFIED);
 
     Spawn spawn =
diff --git a/src/test/java/com/google/devtools/build/lib/exec/local/PosixLocalEnvProviderTest.java b/src/test/java/com/google/devtools/build/lib/exec/local/PosixLocalEnvProviderTest.java
index 314d0f0..f7f9ca5 100644
--- a/src/test/java/com/google/devtools/build/lib/exec/local/PosixLocalEnvProviderTest.java
+++ b/src/test/java/com/google/devtools/build/lib/exec/local/PosixLocalEnvProviderTest.java
@@ -28,7 +28,7 @@
 
   private static Map<String, String> rewriteEnv(
       PosixLocalEnvProvider p, ImmutableMap<String, String> env) {
-    return p.rewriteLocalEnv(env, null, null, null);
+    return p.rewriteLocalEnv(env, null, null);
   }
 
   /** Should use the client environment's TMPDIR envvar if specified. */
diff --git a/src/test/java/com/google/devtools/build/lib/exec/local/WindowsLocalEnvProviderTest.java b/src/test/java/com/google/devtools/build/lib/exec/local/WindowsLocalEnvProviderTest.java
index 08881b1..646278e 100644
--- a/src/test/java/com/google/devtools/build/lib/exec/local/WindowsLocalEnvProviderTest.java
+++ b/src/test/java/com/google/devtools/build/lib/exec/local/WindowsLocalEnvProviderTest.java
@@ -28,12 +28,12 @@
 
   private static Map<String, String> rewriteEnv(
       WindowsLocalEnvProvider p, ImmutableMap<String, String> env) {
-    return p.rewriteLocalEnv(env, null, null, null);
+    return p.rewriteLocalEnv(env, null, null);
   }
 
   private static Map<String, String> rewriteEnv(
       WindowsLocalEnvProvider p, ImmutableMap<String, String> env, String fallback) {
-    return p.rewriteLocalEnv(env, null, fallback, null);
+    return p.rewriteLocalEnv(env, null, fallback);
   }
 
   /** Should use the client environment's TMP envvar if specified. */
diff --git a/src/test/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategyTest.java b/src/test/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategyTest.java
index bd5adbf..d2502f8 100644
--- a/src/test/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategyTest.java
+++ b/src/test/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategyTest.java
@@ -141,7 +141,6 @@
                         execRoot,
                         localExecutionOptions,
                         resourceManager,
-                        "mock-product-name",
                         LocalEnvProvider.UNMODIFIED))),
             ImmutableList.<ActionContextProvider>of());