X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-model-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fmodel%2Frepo%2Futil%2FAbstractSchemaRepository.java;h=2413c6fc9679891a49d3a80ab25119b7aadf619c;hb=98ac2b04a469af0b0d69d17ef66799fb46a9c4ed;hp=d6058292afb5ad4646d0fc6e31ca96673e207195;hpb=8c1ac2024eb319b2b914c2510192bda06a1bf03e;p=yangtools.git diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/repo/util/AbstractSchemaRepository.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/repo/util/AbstractSchemaRepository.java index d6058292af..2413c6fc96 100644 --- a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/repo/util/AbstractSchemaRepository.java +++ b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/repo/util/AbstractSchemaRepository.java @@ -3,7 +3,7 @@ * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/eplv10.html + * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.yangtools.yang.model.repo.util; @@ -65,7 +65,7 @@ public abstract class AbstractSchemaRepository implements SchemaRepository, Sche @GuardedBy("this") private final Collection listeners = new ArrayList<>(); - private static final CheckedFuture fetchSource(final SourceIdentifier id, final Iterator> it) { + private static CheckedFuture fetchSource(final SourceIdentifier id, final Iterator> it) { final AbstractSchemaSourceRegistration reg = it.next(); @SuppressWarnings("unchecked") @@ -87,13 +87,18 @@ public abstract class AbstractSchemaRepository implements SchemaRepository, Sche @Override public CheckedFuture getSchemaSource(final SourceIdentifier id, final Class representation) { - final ListMultimap, AbstractSchemaSourceRegistration> srcs = sources.get(id); - if (srcs == null) { - return Futures.immediateFailedCheckedFuture(new MissingSchemaSourceException("No providers registered for source" + id, id)); + final ArrayList> sortedSchemaSourceRegistrations; + + synchronized (this) { + final ListMultimap, AbstractSchemaSourceRegistration> srcs = sources.get(id); + if (srcs == null) { + return Futures.immediateFailedCheckedFuture(new MissingSchemaSourceException("No providers registered for source" + id, id)); + } + + sortedSchemaSourceRegistrations = Lists.newArrayList(srcs.get(representation)); } // TODO, remove and make sources keep sorted multimap (e.g. ArrayListMultimap with SortedLists) - final ArrayList> sortedSchemaSourceRegistrations = Lists.newArrayList(srcs.get(representation)); Collections.sort(sortedSchemaSourceRegistrations, SchemaProviderCostComparator.INSTANCE); final Iterator> regs = sortedSchemaSourceRegistrations.iterator();