BUG-1622 Fix handling of non-downloadable schemas from remote netconf device 74/10374/1
authorMaros Marsalek <mmarsale@cisco.com>
Wed, 27 Aug 2014 13:10:44 +0000 (15:10 +0200)
committerMaros Marsalek <mmarsale@cisco.com>
Wed, 27 Aug 2014 13:13:51 +0000 (15:13 +0200)
Change-Id: I1b7a5b379e7d25fcbceba105dce6354dfa49c8af
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
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 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;
 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));
 
                 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);
         // (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;
     }
 
     /**
     }
 
     /**