Project:
View Revisions: Issue #24421 | [ All Revisions ] [ Back to Issue ] | ||
Summary | 0024421: ApplicationDictionaryCachedStructures is not thread safe | ||
Revision | 2013-07-29 12:36 by alostale | ||
Description | ApplicationDictionaryCachedStructures with @SessionScoped has some potential issues when it is accessed concurrently by several threads: 1. It caches BaseOBObject with uninitialized proxies. BaseOBObject are attached to the Hibernate session of the thread that did the request. In case Thread-1 caches one of these objects and closes it's session, and later Thread-2 gets this object and touches any of its uninitialized proxies, org.hibernate.LazyInitializationException exception is thrown, causing FIC not to work properly, user can perceive this by hieratical behavior when working in Opebravo (such as not loading default values when creating new records...) 2. In case Thread-2 gets the object before Thread-1 is done, the object's session is still alive. If at this point, the 2 threads try to concurrently load any of the proxied properties (even they are different ones). Different errors can happen, mainly due to StatefulPersistenceContext using non synchronized HashMap, these error can be NPE, org.hibernate.AssertionFailure: possible non-threadsafe access to the session, java.util.ConcurrentModificationException, org.hibernate.LazyInitializationException: illegal access to loading collection or even to get a processor stuck with 100% CPU usage in HashMap.put or HashMap.get caused by trying to access to an inconsistent Map [1][2]. 3. (This case is theoretical as it has not been seen/reported so far). ApplicationDictionaryCachedStructures keeps cache in non synchronized HashMaps which can lead to similar consequences than described in issue 2, in case they are concurrently structurally modified [3]. Note this to happen requires to have concurrent threads in the same session calling FIC. [1] https://hibernate.atlassian.net/browse/HHH-6414 [^] [2] https://forum.hibernate.org/viewtopic.php?f=1&t=980460 [^] [3] http://docs.oracle.com/javase/6/docs/api/java/util/HashMap.html [^] |
||
Revision | 2013-07-29 12:31 by alostale | ||
Description | ApplicationDictionaryCachedStructures with @SessionScoped has two issues when it is accessed concurrently by several threads: 1. It caches BaseOBObject with uninitialized proxies. BaseOBObject are attached to the Hibernate session of the thread that did the request. In case Thread-1 caches one of these objects and closes it's session, and later Thread-2 gets this object and touches any of its uninitialized proxies, org.hibernate.LazyInitializationException exception is thrown, causing FIC not to work properly, user can perceive this by hieratical behavior when working in Opebravo (such as not loading default values when creating new records...) 2. In case Thread-2 gets the object before Thread-1 is done, the object's session is still alive. If at this point, the 2 threads try to concurrently load any of the proxied properties (even they are different ones). Different errors can happen, mainly due to StatefulPersistenceContext using non synchronized HashMap, these error can be NPE, org.hibernate.AssertionFailure: possible non-threadsafe access to the session, java.util.ConcurrentModificationException, org.hibernate.LazyInitializationException: illegal access to loading collection or even to get a processor stuck with 100% CPU usage in HashMap.put or HashMap.get caused by trying to access to an inconsistent Map. Note this to happen requires to have concurrent threads in the same session calling FIC. |
Copyright © 2000 - 2009 MantisBT Group |