Do not use Optional in returns
[yangtools.git] / data / yang-data-tree-ri / src / main / java / org / opendaylight / yangtools / yang / data / tree / impl / AbstractDataTreeTip.java
index 5d54527db44a4e84071179c226fabece31669b16..64384421e4d7228f2770a921d30602c949b0c64a 100644 (file)
@@ -42,9 +42,11 @@ abstract class AbstractDataTreeTip implements DataTreeTip {
             return new NoopDataTreeCandidate(YangInstanceIdentifier.of(), root, currentRoot);
         }
 
-        final var newRoot = m.getStrategy().apply(m.getRootModification(), currentRoot, m.getVersion())
-            .orElseThrow(() -> new IllegalStateException(
-                "Apply strategy failed to produce root node for modification " + modification));
+        final var newRoot = m.getStrategy().apply(m.getRootModification(), currentRoot, m.getVersion());
+        if (newRoot == null) {
+            throw new IllegalStateException("Apply strategy failed to produce root node for modification "
+                + modification);
+        }
         return new InMemoryDataTreeCandidate(YangInstanceIdentifier.of(), root, currentRoot, newRoot);
     }