From: Filip Gregor Date: Tue, 25 Oct 2016 11:10:34 +0000 (+0200) Subject: Bug 6979 - yang.model.util.EffectiveAugmentationSchema is mutable X-Git-Tag: release/boron-sr1~23 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;ds=sidebyside;h=bbde9e23036db9c5cf029ab9da8d01042ef48446;p=yangtools.git Bug 6979 - yang.model.util.EffectiveAugmentationSchema is mutable fixed leak of mutable set Change-Id: Iaa0dac93e3521a9a091feb7ea0c78e9c6b0e20e5 Signed-off-by: Filip Gregor (cherry picked from commit e16dd0836ee7375d8c710f1ae9247f4d258f4760) --- diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/EffectiveAugmentationSchema.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/EffectiveAugmentationSchema.java index 88d356ee97..fd8bb1bc1e 100644 --- a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/EffectiveAugmentationSchema.java +++ b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/EffectiveAugmentationSchema.java @@ -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 realChildSchemas; private final Map mappedChildSchemas; public EffectiveAugmentationSchema(final AugmentationSchema augmentSchema, final Set realChildSchemas) { - this.delegate = augmentSchema; - this.realChildSchemas = realChildSchemas; + this.delegate = Preconditions.checkNotNull(augmentSchema); + this.realChildSchemas = ImmutableSet.copyOf(realChildSchemas); - final Map m = new HashMap<>(realChildSchemas.size()); + final Map m = new HashMap<>(realChildSchemas.size());; for (DataSchemaNode realChildSchema : realChildSchemas) { m.put(realChildSchema.getQName(), realChildSchema); }