https://issues.apache.org/bugzilla/show_bug.cgi?id=46962
Alexis Giotis <alex.gio...@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #27495|0 |1 is obsolete| | --- Comment #15 from Alexis Giotis <alex.gio...@gmail.com> 2012-03-02 16:21:57 UTC --- Created attachment 28412 --> https://issues.apache.org/bugzilla/attachment.cgi?id=28412 Patch update to fix NPE on JDK5 Added a lock on the PropertyCache that prevents concurrent cleanup of the cached objects. There is no reason to concurrently cleanup the cache but most importantly it protects from an NullPointerException occuring on Sun JDK5 http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6312056 This issue was reported by Vincent. The updated patch does not include the tests added by Mehdi for the following reasons: - Make clear my contribution. - There were some cleanups requested by Vincent that I did not fully understand and I don't wish to delay it's processing. - I don't think we get added value by testing the hashCode() & equals() implementations. The tests don't protect from future changes in the tested classes (e.g. adding a new field) and don't protect if in the future another class is added in the cache. - To find broken hashCode() implementation of cached instances, the PropertyCache counts the number of collisions and reports it in the log if it exceeds a number. Of course anyone is welcomed to add tests, if he wishes so. For completeness, below is Vincent's test that reveals the JDK5 bug: private final PropertyCache<Integer> cache = new PropertyCache<Integer>(); private class CacheFiller implements Runnable { private final int start; CacheFiller(int start) { this.start = start; } public void run() { for (int i = 0; i < 1000000; i++) { cache.fetch(new Integer(start + i)); } } } public void testCleanUp() throws InterruptedException { Thread t1 = new Thread(new CacheFiller(0)); Thread t2 = new Thread(new CacheFiller(10000)); t1.start(); t2.start(); t1.join(); t2.join(); } -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug.