atos1990 / orika

Automatically exported from code.google.com/p/orika
0 stars 0 forks source link

Concurrent use of a non-threadsafe Map implementation #74

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Install/use the IBM JDK 6 on AIX or Windows
2. Create a classmap for a random object to object mapping
3. Use this classmap instance concurrently to map various objects

What is the expected output? What do you see instead?
The expected output is that the classmap 'keeps working'. Instead, a 
NullPointer inside the LinkedHashMap implementation of IBM is thrown (within 
the 'get' operation). This is because the superclass LinkedHashMap is not 
thread safe (note the spec doesn't state it should be threadsafe, so this is 
not really IBM's 'fault'!).

What version of the product are you using? On what operating system?
Orika 3.2.5 on AIX, IBM JDK 6.

Please provide any additional information below.
We temp-fixed it by putting our own version of CacheLRULinkedHashMap on the 
classpath, that adds the synchronized keyword to het get and put operations:

    @Override
    public synchronized V get(Object key) {
      return super.get(key);
    }

    @Override
    public synchronized V put(K key, V value) {
      return super.put(key, value);
    };

That solves the problem. Can you include this in the orika sources?

Original issue reported on code.google.com by vincent....@gmail.com on 23 Dec 2012 at 7:50

GoogleCodeExporter commented 9 years ago
Note that once the NPE is thrown, the classmap is and stays broken. Only an 
application restart fixes this!

Original comment by vincent....@gmail.com on 23 Dec 2012 at 7:51

GoogleCodeExporter commented 9 years ago
Also see http://code.google.com/p/google-gson/issues/detail?id=288

Original comment by vincent....@gmail.com on 23 Dec 2012 at 7:53

GoogleCodeExporter commented 9 years ago
And finally, version should be Orika 1.3.5, doh.

Original comment by vincent....@gmail.com on 23 Dec 2012 at 7:56

GoogleCodeExporter commented 9 years ago
Thanks

Original comment by elaat...@gmail.com on 27 Dec 2012 at 10:52

GoogleCodeExporter commented 9 years ago
A fix has been uploaded to the current master which uses the 
ConcurrentLinkedHashMap from google code as an alternative to the existing 
cache impl.
Please check it out when you get a chance and let us know if this corrects the 
issue for you...
(check out our downloads page for details on accessing latest snapshots: 
http://code.google.com/p/orika/wiki/Binaries ) 

Original comment by matt.deb...@gmail.com on 29 Dec 2012 at 7:33

GoogleCodeExporter commented 9 years ago
Thanks. I checked out the diff and it seems to me that this should fix our
problem.

I need some time to confirm the issue has disappeared, since we need to
upgrade to the latest version of Orika (some of our code is still on 1.2.2).

Thanks for the fix!

Original comment by vincent....@gmail.com on 3 Jan 2013 at 10:30

GoogleCodeExporter commented 9 years ago
Fixed in 1.4.1

Original comment by elaat...@gmail.com on 10 Feb 2013 at 12:14