BUG-9043: Remove use of CheckedFuture from YANG components
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / repo / SharedSchemaContextFactory.java
index c5c6bdec5d6065b8ceb3398bc96b59e4eb021589..e31305a79341a8be353d45c11ccb4014da517bbc 100644 (file)
@@ -16,7 +16,6 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Maps;
 import com.google.common.util.concurrent.AsyncFunction;
-import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -71,16 +70,14 @@ final class SharedSchemaContextFactory implements SchemaContextFactory {
     }
 
     @Override
-    public CheckedFuture<SchemaContext, SchemaResolutionException> createSchemaContext(
-            final Collection<SourceIdentifier> requiredSources, final StatementParserMode statementParserMode,
-            final Set<QName> supportedFeatures) {
+    public ListenableFuture<SchemaContext> createSchemaContext(final Collection<SourceIdentifier> requiredSources,
+            final StatementParserMode statementParserMode, final Set<QName> supportedFeatures) {
         return createSchemaContext(requiredSources,
                 statementParserMode == StatementParserMode.SEMVER_MODE ? this.semVerCache : this.cache,
                 new AssembleSources(Optional.ofNullable(supportedFeatures), statementParserMode));
     }
 
-    private CheckedFuture<SchemaContext, SchemaResolutionException> createSchemaContext(
-            final Collection<SourceIdentifier> requiredSources,
+    private ListenableFuture<SchemaContext> createSchemaContext(final Collection<SourceIdentifier> requiredSources,
             final Cache<Collection<SourceIdentifier>, SchemaContext> cache,
             final AsyncFunction<List<ASTSchemaSource>, SchemaContext> assembleSources) {
         // Make sources unique
@@ -89,7 +86,7 @@ final class SharedSchemaContextFactory implements SchemaContextFactory {
         final SchemaContext existing = cache.getIfPresent(uniqueSourceIdentifiers);
         if (existing != null) {
             LOG.debug("Returning cached context {}", existing);
-            return Futures.immediateCheckedFuture(existing);
+            return Futures.immediateFuture(existing);
         }
 
         // Request all sources be loaded
@@ -119,7 +116,7 @@ final class SharedSchemaContextFactory implements SchemaContextFactory {
             }
         }, MoreExecutors.directExecutor());
 
-        return Futures.makeChecked(cf, MAPPER);
+        return cf;
     }
 
     private ListenableFuture<ASTSchemaSource> requestSource(final SourceIdentifier identifier) {
@@ -215,7 +212,10 @@ final class SharedSchemaContextFactory implements SchemaContextFactory {
             }
 
             final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(
-                statementParserMode, supportedFeatures);
+                statementParserMode);
+            if (supportedFeatures.isPresent()) {
+                reactor.setSupportedFeatures(supportedFeatures.get());
+            }
 
             for (final Entry<SourceIdentifier, ASTSchemaSource> e : srcs.entrySet()) {
                 final ASTSchemaSource ast = e.getValue();
@@ -234,7 +234,7 @@ final class SharedSchemaContextFactory implements SchemaContextFactory {
                 throw new SchemaResolutionException("Failed to resolve required models", ex.getSourceIdentifier(), ex);
             }
 
-            return Futures.immediateCheckedFuture(schemaContext);
+            return Futures.immediateFuture(schemaContext);
         }
     }
 }