We do not really need them, so let's replace them where we can.
Change-Id: I06dd05d60018a814fb0610096aa8fe5709669980
JIRA: MDSAL-229
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
try {
return (InstanceIdentifier<? extends TreeNode>) handle.invokeExact(obj);
} catch (final Throwable e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
}
\ No newline at end of file
}
return null;
} catch (final Throwable e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
}
delegate.onDataTreeFailed(bindingCauses);
}
- private DataTreeListeningException mapException(final DOMDataTreeListeningException cause) {
+ private static DataTreeListeningException mapException(final DOMDataTreeListeningException cause) {
// FIXME: Extend logic
return new DataTreeListeningException(cause.getMessage(), cause);
}
try {
invoker.invokeExact(impl, input);
} catch (final Throwable e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
}
try {
return (Future<RpcResult<?>>) handle.invokeExact(args);
} catch (final Throwable e) {
- throw Throwables.propagate(e);
+ Throwables.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
}
import com.google.common.annotations.Beta;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.MoreExecutors;
import javax.annotation.Nonnull;
import org.opendaylight.mdsal.binding.javav2.dom.codec.impl.BindingToNormalizedNodeCodec;
import org.opendaylight.mdsal.binding.javav2.spec.base.TreeNode;
import org.opendaylight.mdsal.common.api.AsyncTransaction;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.common.api.MappingCheckedFuture;
-import org.opendaylight.mdsal.common.api.ReadFailedException;
import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
import org.opendaylight.yangtools.concepts.Delegator;
import org.opendaylight.yangtools.concepts.Identifiable;
return codec;
}
- protected final <D extends TreeNode> CheckedFuture<Optional<D>, ReadFailedException> doRead(
+ protected final <D extends TreeNode> FluentFuture<Optional<D>> doRead(
final DOMDataTreeReadTransaction readTx, final LogicalDatastoreType store,
final InstanceIdentifier<D> path) {
Preconditions.checkArgument(!path.isWildcarded(), "Invalid read of wildcarded path %s", path);
- return MappingCheckedFuture.create(readTx.read(store, codec.toYangInstanceIdentifierBlocking(path))
+ return readTx.read(store, codec.toYangInstanceIdentifierBlocking(path))
.transform(Optional::fromJavaUtil, MoreExecutors.directExecutor())
- .transform(codec.deserializeFunction(path), MoreExecutors.directExecutor()), ReadFailedException.MAPPER);
+ .transform(codec.deserializeFunction(path), MoreExecutors.directExecutor());
}
}
mockSchemaService.changeSchema(getContext(moduleInfos));
}
- private SchemaContext getContext(final ImmutableSet<YangModuleInfo> moduleInfos) {
+ private static SchemaContext getContext(final ImmutableSet<YangModuleInfo> moduleInfos) {
final ModuleInfoBackedContext ctx = ModuleInfoBackedContext.create();
ctx.addModuleInfos(moduleInfos);
return ctx.tryToCreateSchemaContext().get();
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
}
}
- private boolean isLocalAugment(final AugmentationTarget container, final AugmentationSchemaNode augment) {
+ private static boolean isLocalAugment(final AugmentationTarget container, final AugmentationSchemaNode augment) {
Preconditions.checkState(container instanceof SchemaNode);
final QName root = ((SchemaNode) container).getPath().getPathFromRoot().iterator().next();
// findFirst makes no sense but just pick up one child to judge whether the target node is
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.base.Optional;
import com.google.common.io.ByteSource;
-import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.WeakReference;
return registration;
}
- @Override public CheckedFuture<? extends YangTextSchemaSource, SchemaSourceException> getSource(
+ @Override
+ public ListenableFuture<? extends YangTextSchemaSource> getSource(
final SourceIdentifier sourceIdentifier) {
final YangModuleInfo yangModuleInfo = sourceIdentifierToModuleInfo.get(sourceIdentifier);
if (yangModuleInfo == null) {
- LOG.debug("Unknown schema source requested: {}, available sources: {}", sourceIdentifier, sourceIdentifierToModuleInfo.keySet());
- return Futures
- .immediateFailedCheckedFuture(new SchemaSourceException("Unknown schema source: " + sourceIdentifier));
+ LOG.debug("Unknown schema source requested: {}, available sources: {}", sourceIdentifier,
+ sourceIdentifierToModuleInfo.keySet());
+ return Futures.immediateFailedFuture(new SchemaSourceException("Unknown schema source: "
+ + sourceIdentifier));
}
- return Futures
- .immediateCheckedFuture(YangTextSchemaSource.delegateForByteSource(sourceIdentifier, new ByteSource() {
- @Override public InputStream openStream() throws IOException {
- return yangModuleInfo.getModuleSourceStream();
- }
- }));
+ return Futures.immediateFuture(YangTextSchemaSource.delegateForByteSource(sourceIdentifier, new ByteSource() {
+ @Override
+ public InputStream openStream() throws IOException {
+ return yangModuleInfo.getModuleSourceStream();
+ }
+ }));
}
private static class YangModuleInfoRegistration extends AbstractObjectRegistration<YangModuleInfo> {
*/
package org.opendaylight.mdsal.dom.broker;
-import static com.google.common.util.concurrent.Futures.immediateFailedCheckedFuture;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
+import org.opendaylight.yangtools.util.concurrent.FluentFutures;
public class CommitCoordinationTaskTest {
@Test(expected = TransactionCommitFailedException.class)
public void canCommitBlockingWithFail() throws Exception {
- doReturn(Futures.immediateCheckedFuture(null)).when(cohort).abort();
+ doReturn(FluentFutures.immediateNullFluentFuture()).when(cohort).abort();
- doReturn(Futures.immediateCheckedFuture(Boolean.FALSE)).when(cohort).canCommit();
+ doReturn(FluentFutures.immediateFalseFluentFuture()).when(cohort).canCommit();
task.call();
}
@Test(expected = TransactionCommitFailedException.class)
public void canCommitBlockingWithFailException() throws Exception {
- doReturn(Futures.immediateCheckedFuture(null)).when(cohort).abort();
+ doReturn(FluentFutures.immediateNullFluentFuture()).when(cohort).abort();
- doReturn(immediateFailedCheckedFuture(new InterruptedException())).when(cohort).canCommit();
+ doReturn(Futures.immediateFailedFuture(new InterruptedException())).when(cohort).canCommit();
task.call();
}
@Test(expected = TransactionCommitFailedException.class)
public void preCommitBlockingWithFail() throws Exception {
- doReturn(Futures.immediateCheckedFuture(Boolean.TRUE)).when(cohort).canCommit();
- doReturn(Futures.immediateCheckedFuture(null)).when(cohort).abort();
+ doReturn(FluentFutures.immediateTrueFluentFuture()).when(cohort).canCommit();
+ doReturn(FluentFutures.immediateNullFluentFuture()).when(cohort).abort();
- doReturn(immediateFailedCheckedFuture(new InterruptedException())).when(cohort).preCommit();
+ doReturn(Futures.immediateFailedFuture(new InterruptedException())).when(cohort).preCommit();
task.call();
}
@Test(expected = TransactionCommitFailedException.class)
public void commitBlockingWithFail() throws Exception {
- doReturn(Futures.immediateCheckedFuture(Boolean.TRUE)).when(cohort).canCommit();
- doReturn(Futures.immediateCheckedFuture(null)).when(cohort).preCommit();
- doReturn(Futures.immediateCheckedFuture(null)).when(cohort).abort();
+ doReturn(FluentFutures.immediateTrueFluentFuture()).when(cohort).canCommit();
+ doReturn(FluentFutures.immediateNullFluentFuture()).when(cohort).preCommit();
+ doReturn(FluentFutures.immediateNullFluentFuture()).when(cohort).abort();
- doReturn(immediateFailedCheckedFuture(new InterruptedException())).when(cohort).commit();
+ doReturn(Futures.immediateFailedFuture(new InterruptedException())).when(cohort).commit();
task.call();
}
}
\ No newline at end of file
import static org.mockito.Mockito.verify;
import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL;
-import com.google.common.util.concurrent.Futures;
import org.junit.Test;
+import org.opendaylight.mdsal.common.api.CommitInfo;
import org.opendaylight.mdsal.common.api.TransactionChainListener;
import org.opendaylight.mdsal.dom.api.DOMDataTreeCursorAwareTransaction;
import org.opendaylight.mdsal.dom.api.DOMDataTreeProducer;
verify(cursor).delete(any());
doNothing().when(cursor).close();
- doReturn(Futures.immediateCheckedFuture(null)).when(transaction).commit();
+ doReturn(CommitInfo.emptyFluentFuture()).when(transaction).commit();
doReturn(true).when(transaction).cancel();
assertTrue(writeTransaction.cancel());
transactionChainAdapter.closeWriteTransaction(FluentFutures.immediateNullFluentFuture());
- transactionChainAdapter =
- new ShardedDOMTransactionChainAdapter(identifier, dataTreeService, chainListener);
+ transactionChainAdapter = new ShardedDOMTransactionChainAdapter(identifier, dataTreeService, chainListener);
writeTransaction = transactionChainAdapter.newWriteOnlyTransaction();
writeTransaction.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
assertNotNull(writeTransaction.commit());
import static org.mockito.Mockito.verify;
import com.google.common.util.concurrent.FluentFuture;
-import com.google.common.util.concurrent.Futures;
import org.junit.Test;
import org.opendaylight.mdsal.common.api.CommitInfo;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
verify(readTransaction).close();
verify(chainAdapter).closeReadTransaction();
- doReturn(Futures.immediateCheckedFuture(null)).when(readTransaction).read(any(), any());
+ doReturn(FluentFutures.immediateNullFluentFuture()).when(readTransaction).read(any(), any());
assertNotNull(transactionChainReadTransaction.exists(
LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY));
transactionChainReadTransaction.read(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY);
verify(readTransaction, atLeastOnce()).read(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY);
- doReturn(Futures.immediateFailedCheckedFuture(
+ doReturn(FluentFutures.immediateFailedFluentFuture(
new NullPointerException())).when(readTransaction).read(any(), any());
doNothing().when(chainAdapter).transactionFailed(any(), any());
assertNotNull(transactionChainReadTransaction.read(