From 42cc2d9ffbabef51680bf09aaefae28f5a58953a Mon Sep 17 00:00:00 2001 From: hns Date: Sun, 31 Dec 2000 15:42:42 +0000 Subject: [PATCH] Fixed cache corruption when primary key is purged from cache but node is still cached with secondary key --- src/helma/objectmodel/db/NodeManager.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/helma/objectmodel/db/NodeManager.java b/src/helma/objectmodel/db/NodeManager.java index 3364e1f2..55e6de60 100644 --- a/src/helma/objectmodel/db/NodeManager.java +++ b/src/helma/objectmodel/db/NodeManager.java @@ -195,6 +195,10 @@ public final class NodeManager { if (node != null && node.getState() != Node.INVALID) { // tx.timer.endEvent ("getNode "+kstr); + // if we didn't fetch the node via its primary key, refresh the primary key in the cache. + // otherwise we risk cache corroption (duplicate node creation) if the node is fetched by its primary key + if (!rel.usesPrimaryKey ()) + cache.put (node.getKey (), node); return node; } @@ -224,8 +228,12 @@ public final class NodeManager { } // synchronized } - if (node != null) + if (node != null) { + // update primary key in cache, see above + if (!rel.usesPrimaryKey ()) + cache.put (node.getKey (), node); tx.visitCleanNode (node.getKey (), node); + } // tx.timer.endEvent ("getNode "+kstr); return node;