diff options
author | 2018-03-19 10:26:07 -0700 | |
---|---|---|
committer | 2018-03-19 10:28:57 -0700 | |
commit | e6af9f9178e731a45e552b1d249ded90124945ba (patch) | |
tree | 35b1295422c1ceccea26fb54330b6811815a3e41 /src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSetCodec.java | |
parent | 6d4386064edbd09b39b5bf5664c0f976713c0fec (diff) |
Add behavior to NestedSetCodec to prevent it from running during testing.
PiperOrigin-RevId: 189602622
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSetCodec.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSetCodec.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSetCodec.java b/src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSetCodec.java index 255456139a..a4954ab740 100644 --- a/src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSetCodec.java +++ b/src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSetCodec.java @@ -19,6 +19,7 @@ import com.google.common.hash.HashingOutputStream; import com.google.devtools.build.lib.skyframe.serialization.DeserializationContext; import com.google.devtools.build.lib.skyframe.serialization.EnumCodec; import com.google.devtools.build.lib.skyframe.serialization.ObjectCodec; +import com.google.devtools.build.lib.skyframe.serialization.SerializationConstants; import com.google.devtools.build.lib.skyframe.serialization.SerializationContext; import com.google.devtools.build.lib.skyframe.serialization.SerializationException; import com.google.protobuf.ByteString; @@ -54,6 +55,11 @@ public class NestedSetCodec<T> implements ObjectCodec<NestedSet<T>> { @Override public void serialize(SerializationContext context, NestedSet<T> obj, CodedOutputStream codedOut) throws SerializationException, IOException { + if (!SerializationConstants.shouldSerializeNestedSet) { + // Don't perform NestedSet serialization in testing + return; + } + // Topo sort the nested set to ensure digests are available for children at time of writing Collection<Object> topoSortedChildren = getTopologicallySortedChildren(obj); Map<Object, byte[]> childToDigest = new IdentityHashMap<>(); @@ -67,6 +73,11 @@ public class NestedSetCodec<T> implements ObjectCodec<NestedSet<T>> { @Override public NestedSet<T> deserialize(DeserializationContext context, CodedInputStream codedIn) throws SerializationException, IOException { + if (!SerializationConstants.shouldSerializeNestedSet) { + // Don't perform NestedSet deserialization in testing + return NestedSetBuilder.emptySet(Order.STABLE_ORDER); + } + Map<ByteString, Object> digestToChild = new HashMap<>(); int nestedSetCount = codedIn.readInt32(); Preconditions.checkState( |