Merge "BUG-1622 Fix handling of non-downloadable schemas from remote netconf device"
authorTony Tkacik <ttkacik@cisco.com>
Wed, 27 Aug 2014 15:12:23 +0000 (15:12 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 27 Aug 2014 15:12:23 +0000 (15:12 +0000)
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/schema/NetconfRemoteSchemaYangSourceProvider.java

index dc90fd3826a4204861a0e4dd69fcbd6436cec9ad..5a528bc418ea386a04b428e047c58fe7d47c74bb 100644 (file)
@@ -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<YangTextSchemaSource, SchemaSourceException> 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;
     }
 
     /**