X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2Futil%2FCache.java;h=af88c88ea21dbd0104722a3cfc2c437509ea8c64;hb=ae0cd6164facf843cc136f52e3f78e3843191d61;hp=47f4faffe87242f14f2fee22e1f2b1564cd714da;hpb=3591b88b94a6bb378af3d4abe6eb5233ce583104;p=org.ibex.core.git diff --git a/src/org/ibex/util/Cache.java b/src/org/ibex/util/Cache.java index 47f4faf..af88c88 100644 --- a/src/org/ibex/util/Cache.java +++ b/src/org/ibex/util/Cache.java @@ -5,6 +5,35 @@ // the portion of clause 6a after the semicolon (aka the "obnoxious // relink clause") +/* + +Bug report from a user: + +I looked at your Cache.java and tried to make good use of it, but I was +out of luck - it wouldn't run here. Digging deeper into the code, I came +across something that might be considered a bug. But maybe it's just a +feature :-) + + +Starting with an empty cache, Cache.put() immediately followed by +Cache.get() on same keys / same object will set Node lru back to null in +Node.remove() which is called in get(). + +Assuming this put()-get() sequence is fixed, it will fill the cache, but +lru will remain null. + +When cache is filled 100%, we have, at the end of the get(), where +size>maxSize is checked, a state that mru == lru == n (from +if(lru==null) thus deleteting the newly inserted object. Oops. + + +Hope I made this clear enough. Maybe it's not a problem in xwt due to a +different usage scheme of the cache. + + + +*/ + package org.ibex.util; // FIXME needs to be a weak hash