Index: C:/Dev/FOP/main/xml-fop-temp/src/java/org/apache/fop/fo/properties/PropertyCache.java =================================================================== --- C:/Dev/FOP/main/xml-fop-temp/src/java/org/apache/fop/fo/properties/PropertyCache.java (revision 594856) +++ C:/Dev/FOP/main/xml-fop-temp/src/java/org/apache/fop/fo/properties/PropertyCache.java (working copy) @@ -76,6 +76,10 @@ this.ref = old.ref; this.hash = old.hash; } + + public boolean isCleared() { + return (ref == null || ref.get() == null); + } } @@ -116,10 +120,8 @@ int index = this.hash & (table.length - 1); CacheEntry first = table[index]; - WeakReference ref; for (CacheEntry e = first; e != null; e = e.next) { - ref = e.ref; - if (ref != null && ref.get() == null) { + if (e.isCleared()) { /* remove obsolete entry /* 1. clear value, cause interference for non-blocking get() */ e.ref = null; @@ -127,7 +129,9 @@ /* 2. clone the segment, without the obsolete entry */ CacheEntry head = e.next; for (CacheEntry c = first; c != e; c = c.next) { - head = new CacheEntry(c, head); + if (!c.isCleared()) { + head = new CacheEntry(c, head); + } } table[index] = head; segment.count--; @@ -177,7 +181,7 @@ /* launch cleanup in a separate thread, * so it acquires its own lock, and put() * can return immediately */ - Thread cleaner = new Thread(new CacheCleaner(hash)); + Thread cleaner = new Thread(new CacheCleaner(hash), "FOP PropertyCache Cleaner"); cleaner.start(); } }