From 3dcaa12d55eb087636e5ba1996279f0e035663dd Mon Sep 17 00:00:00 2001 From: Maros Marsalek Date: Wed, 27 Aug 2014 15:10:44 +0200 Subject: [PATCH] BUG-1622 Fix handling of non-downloadable schemas from remote netconf device Change-Id: I1b7a5b379e7d25fcbceba105dce6354dfa49c8af Signed-off-by: Maros Marsalek --- .../NetconfRemoteSchemaYangSourceProvider.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/schema/NetconfRemoteSchemaYangSourceProvider.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/schema/NetconfRemoteSchemaYangSourceProvider.java index dc90fd3826..5a528bc418 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/schema/NetconfRemoteSchemaYangSourceProvider.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/schema/NetconfRemoteSchemaYangSourceProvider.java @@ -16,7 +16,6 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import java.io.IOException; import java.io.InputStream; -import java.util.concurrent.ExecutionException; import org.apache.commons.io.IOUtils; import org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil; import org.opendaylight.controller.sal.connect.util.RemoteDeviceId; @@ -97,18 +96,18 @@ public final class NetconfRemoteSchemaYangSourceProvider implements SchemaSource rpc.invokeRpc(GET_SCHEMA_QNAME, getSchemaRequest), new ResultToYangSourceTransformer(id, sourceIdentifier, moduleName, revision)); - // FIXME remove this get, it is only present to wait until source is retrieved + final CheckedFuture checked = Futures.makeChecked(transformed, MAPPER); + + // / FIXME remove this get, it is only present to wait until source is retrieved // (goal is to limit concurrent schema download, since NetconfDevice listener does not handle concurrent messages properly) try { logger.trace("{}: Blocking for {}", id, sourceIdentifier); - transformed.get(); - } catch (final InterruptedException e) { - throw new RuntimeException(e); - } catch (final ExecutionException e) { - throw new IllegalStateException(id + ": Failed while getting source: " + sourceIdentifier, e); + checked.checkedGet(); + } catch (final SchemaSourceException e) { + return Futures.immediateFailedCheckedFuture(e); } - return Futures.makeChecked(transformed, MAPPER); + return checked; } /** -- 2.36.6