import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
-import javax.annotation.CheckReturnValue;
import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.controller.md.sal.common.api.MappingCheckedFuture;
import org.opendaylight.mdsal.common.api.CommitInfo;
import org.opendaylight.yangtools.concepts.Path;
+import org.opendaylight.yangtools.util.concurrent.ExceptionMapper;
/**
* Write transaction provides mutation capabilities for a data tree.
* ({@link AsyncConfigurationCommitHandler}) if the transaction changes the data tree.
*
* <p>
- * The effects of a successful commit of data depends on data change listeners
- * ({@link AsyncDataChangeListener}) and commit participants
+ * The effects of a successful commit of data depends on data tree change listeners and commit participants
* ({@link AsyncConfigurationCommitHandler}) that are registered with the data broker.
*
* <h3>Example usage:</h3>
* @deprecated Use {@link #commit()} instead.
*/
@Deprecated
- CheckedFuture<Void,TransactionCommitFailedException> submit();
+ default CheckedFuture<Void, TransactionCommitFailedException> submit() {
+ return MappingCheckedFuture.create(commit().transform(ignored -> null, MoreExecutors.directExecutor()),
+ SUBMIT_EXCEPTION_MAPPER);
+ }
/**
* Submits this transaction to be asynchronously applied to update the logical data tree. The returned
* {@link TransactionCommitFailedException} or an exception derived from TransactionCommitFailedException.
* @throws IllegalStateException if the transaction is already committed or was canceled.
*/
- @CheckReturnValue
- default @NonNull FluentFuture<? extends @NonNull CommitInfo> commit() {
- return FluentFuture.from(submit()).transformAsync(ignored -> CommitInfo.emptyFluentFuture(),
- MoreExecutors.directExecutor());
- }
+ @NonNull FluentFuture<? extends @NonNull CommitInfo> commit();
+
+ /**
+ * This only exists for reuse by the deprecated {@link #submit} method and is not intended for general use.
+ */
+ @Deprecated
+ ExceptionMapper<TransactionCommitFailedException> SUBMIT_EXCEPTION_MAPPER =
+ new ExceptionMapper<TransactionCommitFailedException>("submit", TransactionCommitFailedException.class) {
+ @Override
+ protected TransactionCommitFailedException newWithCause(final String message, final Throwable cause) {
+ return new TransactionCommitFailedException(message, cause);
+ }
+ };
}