- checkState(stableSnapshot != null, "Transaction is closed");
- return Futures.immediateFuture(stableSnapshot.readNode(path));
+
+ final DataTreeSnapshot snapshot = stableSnapshot;
+ if (snapshot == null) {
+ return Futures.immediateFailedCheckedFuture(new ReadFailedException("Transaction is closed"));
+ }
+
+ try {
+ return Futures.immediateCheckedFuture(snapshot.readNode(path));
+ } catch (Exception e) {
+ LOG.error("Tx: {} Failed Read of {}", getIdentifier(), path, e);
+ return Futures.immediateFailedCheckedFuture(new ReadFailedException("Read failed",e));
+ }
+ }
+
+ @Override
+ public CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
+ LOG.debug("Tx: {} Exists: {}", getIdentifier(), path);
+ checkNotNull(path, "Path must not be null.");
+
+ try {
+ return Futures.immediateCheckedFuture(
+ read(path).checkedGet().isPresent());
+ } catch (ReadFailedException e) {
+ return Futures.immediateFailedCheckedFuture(e);
+ }