*/
package org.opendaylight.controller.md.sal.binding.impl;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.MoreExecutors;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
BindingDOMTransactionChainAdapter(final DOMDataBroker chainFactory,
final BindingToNormalizedNodeCodec codec, final TransactionChainListener listener) {
- Preconditions.checkNotNull(chainFactory, "DOM Transaction chain factory must not be null");
this.domListener = new DelegateChainListener();
this.bindingListener = listener;
- this.delegate = chainFactory.createTransactionChain(domListener);
+ this.delegate = requireNonNull(chainFactory, "DOM Transaction chain factory must not be null")
+ .createTransactionChain(domListener);
this.codec = codec;
}
};
}
+ @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "https://github.com/spotbugs/spotbugs/issues/811")
private FluentFuture<? extends CommitInfo> listenForFailure(
final WriteTransaction tx, final FluentFuture<? extends CommitInfo> future) {
future.addCallback(new FutureCallback<CommitInfo>() {
return future;
}
+ @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "https://github.com/spotbugs/spotbugs/issues/811")
private void failTransactionChain(final WriteTransaction tx, final Throwable ex) {
/*
* We asume correct state change for underlaying transaction
}
private final class DelegateChainListener implements TransactionChainListener {
-
@Override
public void onTransactionChainFailed(final TransactionChain<?, ?> chain,
final AsyncTransaction<?, ?> transaction, final Throwable cause) {
- Preconditions.checkState(delegate.equals(chain),
- "Illegal state - listener for %s was invoked for incorrect chain %s.", delegate, chain);
+ checkChain(chain);
/*
* Intentionally NOOP, callback for failure, since we
* are also listening on each transaction future for failure,
* of this transaction chain), instead of DOM transaction
* which is known only to this chain, binding transaction implementation
* and underlying transaction chain.
- *
*/
LOG.debug("Transaction chain {} failed. Failed DOM Transaction {}",this,transaction,cause);
}
@Override
public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
- Preconditions.checkState(delegate.equals(chain),
- "Illegal state - listener for %s was invoked for incorrect chain %s.", delegate, chain);
+ checkChain(chain);
bindingListener.onTransactionChainSuccessful(BindingDOMTransactionChainAdapter.this);
}
+
+ private void checkChain(final TransactionChain<?, ?> chain) {
+ checkState(delegate.equals(chain), "Illegal state - listener for %s was invoked for incorrect chain %s.",
+ delegate, chain);
+ }
}
}