import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.base.Throwables;
+import java.util.Optional;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
+import javax.annotation.Nullable;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
// FIXME: Add checked exception
} catch (Exception e) {
LOG.error("Tx: {}, failed to write {}:{} in {}", getIdentifier(), path, data, tree, e);
- // Rethrow original ones if they are subclasses of RuntimeException
- // or Error
- Throwables.propagateIfPossible(e);
+ // Rethrow original ones if they are subclasses of RuntimeException or Error
+ Throwables.throwIfUnchecked(e);
// FIXME: Introduce proper checked exception
throw new IllegalArgumentException("Illegal input data.", e);
}
// FIXME: Add checked exception
} catch (Exception e) {
LOG.error("Tx: {}, failed to write {}:{} in {}", getIdentifier(), path, data, tree, e);
- // Rethrow original ones if they are subclasses of RuntimeException
- // or Error
- Throwables.propagateIfPossible(e);
+ // Rethrow original ones if they are subclasses of RuntimeException or Error
+ Throwables.throwIfUnchecked(e);
// FIXME: Introduce proper checked exception
throw new IllegalArgumentException("Illegal input data.", e);
}
// FIXME: Add checked exception
} catch (Exception e) {
LOG.error("Tx: {}, failed to delete {} in {}", getIdentifier(), path, tree, e);
- // Rethrow original ones if they are subclasses of RuntimeException
- // or Error
- Throwables.propagateIfPossible(e);
+ // Rethrow original ones if they are subclasses of RuntimeException or Error
+ Throwables.throwIfUnchecked(e);
// FIXME: Introduce proper checked exception
throw new IllegalArgumentException("Illegal path to delete.", e);
}
"Transaction %s is no longer open. No further modifications allowed.", getIdentifier());
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
@Override
public DOMStoreThreePhaseCommitCohort ready() {
@SuppressWarnings("unchecked")
final DataTreeModification tree = mutableTree;
TREE_UPDATER.lazySet(this, null);
- tree.ready();
- return wasReady.transactionReady(this, tree);
+ try {
+ tree.ready();
+ return wasReady.transactionReady(this, tree, null);
+ } catch (RuntimeException e) {
+ LOG.debug("Store transaction: {}: unexpected failure when readying", getIdentifier(), e);
+ return wasReady.transactionReady(this, tree, e);
+ }
}
@Override
* Transaction on which ready was invoked.
* @param tree
* Modified data tree which has been constructed.
+ * @param readyError
+ * Any error that has already happened when readying.
* @return DOMStoreThreePhaseCommitCohort associated with transaction
*/
- protected abstract DOMStoreThreePhaseCommitCohort transactionReady(
- SnapshotBackedWriteTransaction<T> tx, DataTreeModification tree);
+ protected abstract DOMStoreThreePhaseCommitCohort transactionReady(SnapshotBackedWriteTransaction<T> tx,
+ DataTreeModification tree,
+ @Nullable Exception readyError);
}
}