Bug 6979 - yang.model.util.EffectiveAugmentationSchema is mutable 66/47666/2
authorFilip Gregor <fgregor@cisco.com>
Tue, 25 Oct 2016 11:10:34 +0000 (13:10 +0200)
committerRobert Varga <nite@hq.sk>
Fri, 28 Oct 2016 22:43:21 +0000 (22:43 +0000)
fixed leak of mutable set

Change-Id: Iaa0dac93e3521a9a091feb7ea0c78e9c6b0e20e5
Signed-off-by: Filip Gregor <fgregor@cisco.com>
(cherry picked from commit e16dd0836ee7375d8c710f1ae9247f4d258f4760)

yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/EffectiveAugmentationSchema.java

index 88d356ee9772a34dc633fdf131ca776526e7c81f..fd8bb1bc1e88a106280a2abac6b375d09e352802 100644 (file)
@@ -8,7 +8,9 @@
 package org.opendaylight.yangtools.yang.model.util;
 
 import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -27,18 +29,17 @@ import org.opendaylight.yangtools.yang.model.api.UsesNode;
 /**
  * Proxy for AugmentationSchema. Child node schemas are replaced with actual schemas from parent.
  *
- * FIXME: Make this class final, once derived deprecated class is removed.
  */
-public class EffectiveAugmentationSchema implements AugmentationSchema {
+public final class EffectiveAugmentationSchema implements AugmentationSchema {
     private final AugmentationSchema delegate;
     private final Set<DataSchemaNode> realChildSchemas;
     private final Map<QName, DataSchemaNode> mappedChildSchemas;
 
     public EffectiveAugmentationSchema(final AugmentationSchema augmentSchema, final Set<DataSchemaNode> realChildSchemas) {
-        this.delegate = augmentSchema;
-        this.realChildSchemas = realChildSchemas;
+        this.delegate = Preconditions.checkNotNull(augmentSchema);
+        this.realChildSchemas = ImmutableSet.copyOf(realChildSchemas);
 
-        final Map<QName, DataSchemaNode> m = new HashMap<>(realChildSchemas.size());
+        final Map<QName, DataSchemaNode> m = new HashMap<>(realChildSchemas.size());;
         for (DataSchemaNode realChildSchema : realChildSchemas) {
             m.put(realChildSchema.getQName(), realChildSchema);
         }