BUG-5504: use Object.toString() without overrides in precondition
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / tree / InMemoryDataTree.java
index 13070428ec896c1722f01454bdd2841a4b25fcab..6e389699294b1decde70ce35484ae0d3efcd2a05 100644 (file)
@@ -113,13 +113,21 @@ final class InMemoryDataTree extends AbstractDataTreeTip implements TipProducing
             LOG.debug("Updating datastore from {} to {}", currentRoot, newRoot);
 
             final TreeNode oldRoot = c.getBeforeRoot();
-            Preconditions.checkState(oldRoot == currentRoot, "Store tree %s and candidate base %s differ.", currentRoot, oldRoot);
+            if (oldRoot != currentRoot) {
+                final String oldStr = simpleToString(oldRoot);
+                final String currentStr = simpleToString(currentRoot);
+                throw new IllegalStateException("Store tree " + currentStr + " and candidate base " + oldStr + " differ.");
+            }
 
             newState = currentState.withRoot(newRoot);
             LOG.trace("Updated state from {} to {}", currentState, newState);
         } while (!STATE_UPDATER.compareAndSet(this, currentState, newState));
     }
 
+    private static String simpleToString(final Object o) {
+        return o.getClass().getName() + "@" + Integer.toHexString(o.hashCode());
+    }
+
     @Override
     public YangInstanceIdentifier getRootPath() {
         return rootPath;