From c575c0657f610838c543712f7aa11959d54f5e96 Mon Sep 17 00:00:00 2001 From: Googler Date: Tue, 20 Feb 2024 13:44:24 -0800 Subject: [PATCH] Sandboxes: cleanup: Hide Set implementation detail for "dirsToCreate" The LinkedHashSet implementation detail needs to only be known at construction time. All further users can just rely on the interface definition. PiperOrigin-RevId: 608724381 Change-Id: I816cdb6344236250a55c951f8edb7cad6a02ee71 --- .../lib/sandbox/AbstractContainerizingSandboxedSpawn.java | 4 ++-- .../com/google/devtools/build/lib/sandbox/SandboxHelpers.java | 3 +-- .../devtools/build/lib/sandbox/SymlinkedSandboxedSpawn.java | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/AbstractContainerizingSandboxedSpawn.java b/src/main/java/com/google/devtools/build/lib/sandbox/AbstractContainerizingSandboxedSpawn.java index 19f1bbc01b334f..3b2930118f43ca 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/AbstractContainerizingSandboxedSpawn.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/AbstractContainerizingSandboxedSpawn.java @@ -114,7 +114,7 @@ public void createFileSystem() throws IOException, InterruptedException { // First compute all the inputs and directories that we need. This is based only on // `workerFiles`, `inputs` and `outputs` and won't do any I/O. Set inputsToCreate = new LinkedHashSet<>(); - LinkedHashSet dirsToCreate = new LinkedHashSet<>(); + Set dirsToCreate = new LinkedHashSet<>(); Set writableSandboxDirs = writableDirs.stream() .filter(p -> p.startsWith(sandboxExecRoot)) @@ -145,7 +145,7 @@ public void createFileSystem() throws IOException, InterruptedException { } protected void filterInputsAndDirsToCreate( - Set inputsToCreate, LinkedHashSet dirsToCreate) + Set inputsToCreate, Set dirsToCreate) throws IOException, InterruptedException {} /** diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/SandboxHelpers.java b/src/main/java/com/google/devtools/build/lib/sandbox/SandboxHelpers.java index 7da606a5a1bd3a..ac7187e78de01a 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/SandboxHelpers.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/SandboxHelpers.java @@ -55,7 +55,6 @@ import java.io.IOException; import java.util.HashMap; import java.util.HashSet; -import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -262,7 +261,7 @@ static Optional getExpectedSymlinkDestination( public static void populateInputsAndDirsToCreate( Set writableDirs, Set inputsToCreate, - LinkedHashSet dirsToCreate, + Set dirsToCreate, Iterable inputFiles, SandboxOutputs outputs) { // Add all worker files, input files, and the parent directories. diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/SymlinkedSandboxedSpawn.java b/src/main/java/com/google/devtools/build/lib/sandbox/SymlinkedSandboxedSpawn.java index c0ebcb294c5004..a29c0223433da1 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/SymlinkedSandboxedSpawn.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/SymlinkedSandboxedSpawn.java @@ -26,7 +26,6 @@ import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; import java.io.IOException; -import java.util.LinkedHashSet; import java.util.Optional; import java.util.Set; import javax.annotation.Nullable; @@ -73,7 +72,7 @@ public SymlinkedSandboxedSpawn( @Override public void filterInputsAndDirsToCreate( - Set inputsToCreate, LinkedHashSet dirsToCreate) + Set inputsToCreate, Set dirsToCreate) throws IOException, InterruptedException { boolean gotStash = SandboxStash.takeStashedSandbox(sandboxPath, mnemonic, getEnvironment(), outputs);