From: Robin Rosenberg Date: Mon, 12 Mar 2007 17:51:15 GMT Subject: [PATCH] Distignuish between commit id and key in commit cache Message-ID: <20070312175115.10884.87646.stgit@lathund.dewire.com> See WeakHashMap documentation. If the key is the same object as the objectid the keys can never be collected. Signed-off-by: Robin Rosenberg --- .../src/org/spearce/jgit/lib/Repository.java | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java index f7c470d..8b1f42c 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java @@ -199,7 +199,9 @@ public class Repository { final byte[] raw = or.getBytes(); if (Constants.TYPE_COMMIT.equals(or.getType())) { ret = new Commit(this, id, raw); - cache.put(id, ret); + // The key must not be the referenced strongly + // by the value in WeakHashMaps + cache.put(new ObjectId(id.getBytes()), ret); return ret; } throw new IncorrectObjectTypeException(id, Constants.TYPE_COMMIT);