We can use a precondition to make the code flow
more obvious.
Change-Id: Iaddfcfd4d49a91b6875a6f4803fed744ada63a85
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit
bf69b6948754f6b1a7de124cc54bbe88b3532772)
- throw new IllegalArgumentException(String.format("Path %s is not accessible from transaction %s",
- prefix, this));
public synchronized DOMDataTreeWriteCursor createCursor(final DOMDataTreeIdentifier prefix) {
Preconditions.checkState(!closed, "Transaction is closed already");
Preconditions.checkState(openCursor == null, "There is still a cursor open");
public synchronized DOMDataTreeWriteCursor createCursor(final DOMDataTreeIdentifier prefix) {
Preconditions.checkState(!closed, "Transaction is closed already");
Preconditions.checkState(openCursor == null, "There is still a cursor open");
final DOMDataTreeShardWriteTransaction lookup = lookup(prefix);
final DOMDataTreeShardWriteTransaction lookup = lookup(prefix);
+ Preconditions.checkArgument(lookup != null, "Path %s is not accessible from transaction %s", prefix, this);
+
openCursor = new DelegatingCursor(lookup.createCursor(prefix), prefix);
return openCursor;
}
openCursor = new DelegatingCursor(lookup.createCursor(prefix), prefix);
return openCursor;
}