From 6b2dce6710ed7d2429e0e3dc113c9bad622b8c4b Mon Sep 17 00:00:00 2001 From: brandjon Date: Wed, 9 Aug 2017 15:20:02 +0200 Subject: In the MutableList API, make an internal unsafe method public This method acts as an "escape hatch" for mutating a list regardless of Mutability. It should be avoided if at all possible. RELNOTES: None PiperOrigin-RevId: 164716286 --- .../com/google/devtools/build/lib/syntax/SkylarkList.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java index bab6df740a..1f90a65c51 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java @@ -335,8 +335,17 @@ public abstract class SkylarkList extends BaseMutableList ImmutableList.copyOf(contents), env == null ? null : env.mutability()); } - /** Appends the given elements to the end of the list, without calling {@link #checkMutable}. */ - private void addAllUnsafe(Iterable elements) { + /** + * Appends the given elements to the end of the list, without calling {@link #checkMutable}. + * + *

Warning: This method should never be used by a caller that cares about respecting + * mutability restrictions. Such callers should instead use the safe {@link #addAll(Iterable, + * Location, Mutability)} method below. This unsafe variant is only public in order to provide + * an "escape hatch" for when ordinary mutability restrictions are inapplicable, e.g. for + * constructing lists from outside a Skylark environment and where it's impossible for multiple + * threads to observe the value at once. + */ + public void addAllUnsafe(Iterable elements) { Iterables.addAll(contents, elements); } -- cgit v1.2.3