Skip to content

Commit

Permalink
Make TestEnvironmentInfo members immutable
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Mar 16, 2022
1 parent 3b0d95e commit 83dc606
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package com.google.devtools.build.lib.analysis.test;

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.packages.BuiltinProvider;
import com.google.devtools.build.lib.packages.NativeInfo;
Expand All @@ -30,13 +32,14 @@ public final class TestEnvironmentInfo extends NativeInfo implements TestEnviron
public static final BuiltinProvider<TestEnvironmentInfo> PROVIDER =
new BuiltinProvider<TestEnvironmentInfo>("TestEnvironment", TestEnvironmentInfo.class) {};

private final Map<String, String> environment;
private final List<String> inheritedEnvironment;
private final ImmutableMap<String, String> environment;
private final ImmutableList<String> inheritedEnvironment;

/** Constructs a new provider with the given fixed and inherited environment variables. */
public TestEnvironmentInfo(Map<String, String> environment, List<String> inheritedEnvironment) {
this.environment = Preconditions.checkNotNull(environment);
this.inheritedEnvironment = Preconditions.checkNotNull(inheritedEnvironment);
this.environment = ImmutableMap.copyOf(Preconditions.checkNotNull(environment));
this.inheritedEnvironment = ImmutableList.copyOf(
Preconditions.checkNotNull(inheritedEnvironment));
}

@Override
Expand Down

0 comments on commit 83dc606

Please sign in to comment.