- if (!datastoreData.isPresent() && iterator.hasNext()) {
- rwTx.merge(store, currentPath, currentOp.createDefault(currentArg));
+ boolean exists = rwTx.exists(store, currentPath).checkedGet();
+ if (!exists && iterator.hasNext()) {
+ rwTx.merge(store, currentPath, currentOp.createDefault(currentArg));
+ }
+ } catch (ReadFailedException e) {
+ LOG.error("Failed to read pre-existing data from store {} path {}", store, currentPath, e);
+ throw new RestconfDocumentedException("Failed to read pre-existing data", e);