From: Robert Varga Date: Thu, 10 Oct 2019 12:05:49 +0000 (+0200) Subject: Remove CheckedFuture from RemoteSchemaProvider X-Git-Tag: release/magnesium~54 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=c4f581509e3d98b6dc065da793a3051bf2b4a2d3;hp=41c10e8423c8f0fa88a7f7180dfbb582fabcbb8b Remove CheckedFuture from RemoteSchemaProvider The API contract we are implementing is defined in terms of ListenableFuture, hence we can drop the use of CheckedFuture. Change-Id: I9d99b2e42c3995c4c11b44e595a81a93b2b31b7e Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/impl/RemoteSchemaProvider.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/impl/RemoteSchemaProvider.java index 3208e390a4..88e58421c1 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/impl/RemoteSchemaProvider.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/impl/RemoteSchemaProvider.java @@ -10,12 +10,9 @@ package org.opendaylight.controller.cluster.schema.provider.impl; import akka.dispatch.OnComplete; import com.google.common.annotations.Beta; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; import org.opendaylight.controller.cluster.schema.provider.RemoteYangTextSourceProvider; -import org.opendaylight.yangtools.util.concurrent.ExceptionMapper; -import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException; 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.SchemaSourceProvider; @@ -29,27 +26,19 @@ import scala.concurrent.Future; */ @Beta public class RemoteSchemaProvider implements SchemaSourceProvider { - private static final Logger LOG = LoggerFactory.getLogger(RemoteSchemaProvider.class); private final RemoteYangTextSourceProvider remoteRepo; private final ExecutionContext executionContext; - private static final ExceptionMapper MAPPER = new ExceptionMapper( - "schemaDownload", SchemaSourceException.class) { - @Override - protected SchemaSourceException newWithCause(final String message, final Throwable throwable) { - return new SchemaSourceException(message, throwable); - } - }; - - public RemoteSchemaProvider(RemoteYangTextSourceProvider remoteRepo, ExecutionContext executionContext) { + public RemoteSchemaProvider(final RemoteYangTextSourceProvider remoteRepo, + final ExecutionContext executionContext) { this.remoteRepo = remoteRepo; this.executionContext = executionContext; } @Override - public CheckedFuture getSource(SourceIdentifier sourceIdentifier) { + public ListenableFuture getSource(final SourceIdentifier sourceIdentifier) { LOG.trace("Getting yang schema source for {}", sourceIdentifier.getName()); Future result = remoteRepo.getYangTextSchemaSource(sourceIdentifier); @@ -57,8 +46,8 @@ public class RemoteSchemaProvider implements SchemaSourceProvider res = SettableFuture.create(); result.onComplete(new OnComplete() { @Override - public void onComplete(Throwable throwable, - YangTextSchemaSourceSerializationProxy yangTextSchemaSourceSerializationProxy) { + public void onComplete(final Throwable throwable, + final YangTextSchemaSourceSerializationProxy yangTextSchemaSourceSerializationProxy) { if (yangTextSchemaSourceSerializationProxy != null) { res.set(yangTextSchemaSourceSerializationProxy.getRepresentation()); } @@ -66,9 +55,8 @@ public class RemoteSchemaProvider implements SchemaSourceProvider sourceFuture = remoteSchemaProvider.getSource(ID); + ListenableFuture sourceFuture = remoteSchemaProvider.getSource(ID); assertTrue(sourceFuture.isDone()); - sourceFuture.checkedGet(); + try { + sourceFuture.get(); + fail("Expected a failure to occur"); + } catch (ExecutionException e) { + assertThat(e.getCause(), instanceOf(SchemaSourceException.class)); + } } }