From: Robert Varga Date: Mon, 26 Aug 2019 12:48:01 +0000 (+0200) Subject: Fix schema source registrations not being cleared X-Git-Tag: release/neon-sr3~13 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=netconf.git;a=commitdiff_plain;h=01e6f6d0f907f710db3a1606ee0632cf8eb28476 Fix schema source registrations not being cleared When a device goes down, we need to clear the registration list, so we do not touch them multiple times. Change-Id: Ic2e67cd21d05a413882f1d3d37b33c5dfabe2261 Signed-off-by: Robert Varga (cherry picked from commit a9faa75d0972a634d9c2b6dca4ead4232c4a343d) --- diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfDevice.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfDevice.java index 451fb057c4..a6865ba6dd 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfDevice.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfDevice.java @@ -67,7 +67,6 @@ import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactory; import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository; import org.opendaylight.yangtools.yang.model.repo.api.SchemaResolutionException; -import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation; import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier; import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource; @@ -90,8 +89,7 @@ public class NetconfDevice protected final SchemaSourceRegistry schemaRegistry; protected final SchemaRepository schemaRepository; - protected final List> sourceRegistrations = - new ArrayList<>(); + protected final List> sourceRegistrations = new ArrayList<>(); private final RemoteDeviceHandler salFacade; private final ListeningExecutorService processingExecutor; @@ -301,10 +299,8 @@ public class NetconfDevice notificationHandler.onRemoteSchemaDown(); salFacade.onDeviceDisconnected(); - for (final SchemaSourceRegistration sourceRegistration - : sourceRegistrations) { - sourceRegistration.close(); - } + sourceRegistrations.forEach(SchemaSourceRegistration::close); + sourceRegistrations.clear(); resetMessageTransformer(); }