Mark collection of expanded tree artifacts in `ArtifactExpander` immutable.
The collection of expanded tree artifacts in `ArtifactExpander` is immutable
for each tree artifact (`ImmutableSet`). Change the type to reflect that.
PiperOrigin-RevId: 337542025
diff --git a/src/main/java/com/google/devtools/build/lib/actions/Artifact.java b/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
index 9b7deac..d592ab2 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
@@ -23,6 +23,7 @@
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.collect.Streams;
@@ -255,12 +256,12 @@
/** Implementation of {@link ArtifactExpander} */
public static class ArtifactExpanderImpl implements ArtifactExpander {
- private final Map<Artifact, Collection<Artifact>> expandedInputs;
+ private final Map<Artifact, ImmutableCollection<Artifact>> expandedInputs;
private final Map<SpecialArtifact, ArchivedTreeArtifact> archivedTreeArtifacts;
private final Map<Artifact, ImmutableList<FilesetOutputSymlink>> expandedFilesets;
public ArtifactExpanderImpl(
- Map<Artifact, Collection<Artifact>> expandedInputs,
+ Map<Artifact, ImmutableCollection<Artifact>> expandedInputs,
Map<SpecialArtifact, ArchivedTreeArtifact> archivedTreeArtifacts,
Map<Artifact, ImmutableList<FilesetOutputSymlink>> expandedFilesets) {
this.expandedInputs = expandedInputs;
@@ -272,7 +273,7 @@
public void expand(Artifact artifact, Collection<? super Artifact> output) {
Preconditions.checkState(
artifact.isMiddlemanArtifact() || artifact.isTreeArtifact(), artifact);
- Collection<Artifact> result = expandedInputs.get(artifact);
+ ImmutableCollection<Artifact> result = expandedInputs.get(artifact);
if (result != null) {
output.addAll(result);
}
diff --git a/src/main/java/com/google/devtools/build/lib/actions/CompletionContext.java b/src/main/java/com/google/devtools/build/lib/actions/CompletionContext.java
index 94580d9..8d54f8f 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/CompletionContext.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/CompletionContext.java
@@ -17,6 +17,7 @@
import static com.google.devtools.build.lib.actions.FilesetManifest.RelativeSymlinkBehavior.RESOLVE_FULLY;
import com.google.auto.value.AutoValue;
+import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.actions.Artifact.ArchivedTreeArtifact;
import com.google.devtools.build.lib.actions.Artifact.ArtifactExpander;
@@ -28,7 +29,6 @@
import com.google.devtools.build.lib.vfs.PathFragment;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
@@ -58,7 +58,7 @@
public abstract Path execRoot();
public static CompletionContext create(
- Map<Artifact, Collection<Artifact>> expandedArtifacts,
+ Map<Artifact, ImmutableCollection<Artifact>> expandedArtifacts,
Map<SpecialArtifact, ArchivedTreeArtifact> archivedTreeArtifacts,
Map<Artifact, ImmutableList<FilesetOutputSymlink>> expandedFilesets,
boolean expandFilesets,
@@ -143,7 +143,7 @@
public interface PathResolverFactory {
ArtifactPathResolver createPathResolverForArtifactValues(
ActionInputMap actionInputMap,
- Map<Artifact, Collection<Artifact>> expandedArtifacts,
+ Map<Artifact, ImmutableCollection<Artifact>> expandedArtifacts,
Map<Artifact, ImmutableList<FilesetOutputSymlink>> filesets,
String workspaceName)
throws IOException;
diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteOutputService.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteOutputService.java
index 15c0e1f..957af4e 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/RemoteOutputService.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteOutputService.java
@@ -15,6 +15,7 @@
package com.google.devtools.build.lib.remote;
import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.actions.Action;
import com.google.devtools.build.lib.actions.ActionInputMap;
@@ -30,7 +31,6 @@
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.lib.vfs.Root;
-import java.util.Collection;
import java.util.Map;
import java.util.UUID;
import javax.annotation.Nullable;
@@ -133,7 +133,7 @@
FileSystem fileSystem,
ImmutableList<Root> pathEntries,
ActionInputMap actionInputMap,
- Map<Artifact, Collection<Artifact>> expandedArtifacts,
+ Map<Artifact, ImmutableCollection<Artifact>> expandedArtifacts,
Map<Artifact, ImmutableList<FilesetOutputSymlink>> filesets) {
FileSystem remoteFileSystem =
new RemoteActionFileSystem(
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java
index 0f1564c..6952240 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java
@@ -17,6 +17,7 @@
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@@ -921,7 +922,7 @@
private DiscoveredState addDiscoveredInputs(
ActionInputMap inputData,
- Map<Artifact, Collection<Artifact>> expandedArtifacts,
+ Map<Artifact, ImmutableCollection<Artifact>> expandedArtifacts,
Map<SpecialArtifact, ArchivedTreeArtifact> archivedTreeArtifacts,
Iterable<Artifact> discoveredInputs,
Environment env,
@@ -1035,7 +1036,7 @@
/** Metadata about Artifacts consumed by this Action. */
private final ActionInputMap actionInputMap;
/** Artifact expansion mapping for Runfiles tree and tree artifacts. */
- private final Map<Artifact, Collection<Artifact>> expandedArtifacts;
+ private final Map<Artifact, ImmutableCollection<Artifact>> expandedArtifacts;
/** Archived representations for tree artifacts. */
private final Map<SpecialArtifact, ArchivedTreeArtifact> archivedTreeArtifacts;
/** Artifact expansion mapping for Filesets embedded in Runfiles. */
@@ -1046,7 +1047,7 @@
CheckInputResults(
ActionInputMap actionInputMap,
- Map<Artifact, Collection<Artifact>> expandedArtifacts,
+ Map<Artifact, ImmutableCollection<Artifact>> expandedArtifacts,
Map<SpecialArtifact, ArchivedTreeArtifact> archivedTreeArtifacts,
Map<Artifact, ImmutableList<FilesetOutputSymlink>> filesetsInsideRunfiles,
Map<Artifact, ImmutableList<FilesetOutputSymlink>> topLevelFilesets) {
@@ -1061,7 +1062,7 @@
private interface AccumulateInputResultsFactory<S extends ActionInputMapSink, R> {
R create(
S actionInputMapSink,
- Map<Artifact, Collection<Artifact>> expandedArtifacts,
+ Map<Artifact, ImmutableCollection<Artifact>> expandedArtifacts,
Map<SpecialArtifact, ArchivedTreeArtifact> archivedTreeArtifacts,
Map<Artifact, ImmutableList<FilesetOutputSymlink>> filesetsInsideRunfiles,
Map<Artifact, ImmutableList<FilesetOutputSymlink>> topLevelFilesets);
@@ -1156,7 +1157,7 @@
ImmutableList<Artifact> allInputsList = allInputs.toList();
S inputArtifactData =
actionInputMapSinkFactory.apply(populateInputData ? allInputsList.size() : 0);
- Map<Artifact, Collection<Artifact>> expandedArtifacts =
+ Map<Artifact, ImmutableCollection<Artifact>> expandedArtifacts =
Maps.newHashMapWithExpectedSize(populateInputData ? 128 : 0);
Map<SpecialArtifact, ArchivedTreeArtifact> archivedTreeArtifacts =
Maps.newHashMapWithExpectedSize(128);
@@ -1337,7 +1338,8 @@
Map<Artifact, ImmutableList<FilesetOutputSymlink>> topLevelFilesets =
Maps.newHashMapWithExpectedSize(0);
S inputArtifactData = actionInputMapSinkFactory.apply(allInputsList.size());
- Map<Artifact, Collection<Artifact>> expandedArtifacts = Maps.newHashMapWithExpectedSize(128);
+ Map<Artifact, ImmutableCollection<Artifact>> expandedArtifacts =
+ Maps.newHashMapWithExpectedSize(128);
Map<SpecialArtifact, ArchivedTreeArtifact> archivedTreeArtifacts =
Maps.newHashMapWithExpectedSize(128);
@@ -1446,7 +1448,7 @@
/** Mutable map containing metadata for known artifacts. */
ActionInputMap inputArtifactData = null;
- Map<Artifact, Collection<Artifact>> expandedArtifacts = null;
+ Map<Artifact, ImmutableCollection<Artifact>> expandedArtifacts = null;
Map<SpecialArtifact, ArchivedTreeArtifact> archivedTreeArtifacts = null;
ImmutableMap<Artifact, ImmutableList<FilesetOutputSymlink>> filesetsInsideRunfiles = null;
ImmutableMap<Artifact, ImmutableList<FilesetOutputSymlink>> topLevelFilesets = null;
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionInputMapHelper.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionInputMapHelper.java
index 38cf911..9fd9c34 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionInputMapHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionInputMapHelper.java
@@ -14,6 +14,7 @@
package com.google.devtools.build.lib.skyframe;
import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.actions.ActionAnalysisMetadata;
@@ -31,7 +32,6 @@
import com.google.devtools.build.lib.util.Pair;
import com.google.devtools.build.skyframe.SkyFunction.Environment;
import com.google.devtools.build.skyframe.SkyValue;
-import java.util.Collection;
import java.util.Map;
/** Static utilities for working with action inputs. */
@@ -45,7 +45,7 @@
*/
static void addToMap(
ActionInputMapSink inputMap,
- Map<Artifact, Collection<Artifact>> expandedArtifacts,
+ Map<Artifact, ImmutableCollection<Artifact>> expandedArtifacts,
Map<SpecialArtifact, ArchivedTreeArtifact> archivedTreeArtifacts,
Map<Artifact, ImmutableList<FilesetOutputSymlink>> filesetsInsideRunfiles,
Map<Artifact, ImmutableList<FilesetOutputSymlink>> topLevelFilesets,
@@ -164,7 +164,7 @@
private static void expandTreeArtifactAndPopulateArtifactData(
Artifact treeArtifact,
TreeArtifactValue value,
- Map<Artifact, Collection<Artifact>> expandedArtifacts,
+ Map<Artifact, ImmutableCollection<Artifact>> expandedArtifacts,
Map<SpecialArtifact, ArchivedTreeArtifact> archivedTreeArtifacts,
ActionInputMapSink inputMap,
Artifact depOwner) {
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/CompletionFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/CompletionFunction.java
index 1f3802b..a2cb5f2 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/CompletionFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/CompletionFunction.java
@@ -13,6 +13,7 @@
// limitations under the License.
package com.google.devtools.build.lib.skyframe;
+import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Streams;
@@ -49,7 +50,6 @@
import com.google.devtools.build.skyframe.SkyValue;
import com.google.devtools.build.skyframe.ValueOrException2;
import java.io.IOException;
-import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@@ -192,7 +192,7 @@
Artifact.keys(allArtifacts), ActionExecutionException.class, IOException.class);
ActionInputMap inputMap = new ActionInputMap(inputDeps.size());
- Map<Artifact, Collection<Artifact>> expandedArtifacts = new HashMap<>();
+ Map<Artifact, ImmutableCollection<Artifact>> expandedArtifacts = new HashMap<>();
Map<Artifact, ImmutableList<FilesetOutputSymlink>> expandedFilesets = new HashMap<>();
Map<SpecialArtifact, ArchivedTreeArtifact> archivedTreeArtifacts = new HashMap<>();
Map<Artifact, ImmutableList<FilesetOutputSymlink>> topLevelFilesets = new HashMap<>();
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
index c3a5964..ced863d2 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
@@ -26,6 +26,7 @@
import com.google.common.cache.CacheBuilder;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Collections2;
+import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
@@ -369,7 +370,7 @@
@Override
public ArtifactPathResolver createPathResolverForArtifactValues(
ActionInputMap actionInputMap,
- Map<Artifact, Collection<Artifact>> expandedArtifacts,
+ Map<Artifact, ImmutableCollection<Artifact>> expandedArtifacts,
Map<Artifact, ImmutableList<FilesetOutputSymlink>> filesets,
String workspaceName)
throws IOException {
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/OutputService.java b/src/main/java/com/google/devtools/build/lib/vfs/OutputService.java
index db2fa59..88a4cff 100644
--- a/src/main/java/com/google/devtools/build/lib/vfs/OutputService.java
+++ b/src/main/java/com/google/devtools/build/lib/vfs/OutputService.java
@@ -14,6 +14,7 @@
package com.google.devtools.build.lib.vfs;
+import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.lib.actions.Action;
@@ -31,7 +32,6 @@
import com.google.devtools.build.lib.util.AbruptExitException;
import com.google.devtools.build.skyframe.SkyFunction.Environment;
import java.io.IOException;
-import java.util.Collection;
import java.util.Map;
import java.util.UUID;
import javax.annotation.Nullable;
@@ -203,7 +203,7 @@
FileSystem fileSystem,
ImmutableList<Root> pathEntries,
ActionInputMap actionInputMap,
- Map<Artifact, Collection<Artifact>> expandedArtifacts,
+ Map<Artifact, ImmutableCollection<Artifact>> expandedArtifacts,
Map<Artifact, ImmutableList<FilesetOutputSymlink>> filesets)
throws IOException {
throw new IllegalStateException("Path resolver not supported by this class");