From 9c8e1b0cd23fed1e3f883e85e54a42c603c48c2c Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 16 Mar 2016 13:57:17 +0100 Subject: [PATCH 1/1] BUG-5504: use Object.toString() without overrides in precondition The precondition check could end up using a lot of memory due to dump of the data tree. Implement a simpler version and use that in the message. Change-Id: I494cb92c7f4691d235e8ffac6f79c696e4ea0f48 Signed-off-by: Robert Varga (cherry picked from commit 414ea232f11da87dbdfbb1a7a10155b93e93b853) --- .../yang/data/impl/schema/tree/InMemoryDataTree.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTree.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTree.java index 13070428ec..6e38969929 100644 --- a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTree.java +++ b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTree.java @@ -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; -- 2.36.6