[hibernate-issues] [Hibernate-JIRA] Resolved: (HSEARCH-21) NPE in SearchFactory while using different threads
Emmanuel Bernard (JIRA)
noreply at atlassian.com
Sat Feb 24 18:45:31 EST 2007
[ http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-21?page=all ]
Emmanuel Bernard resolved HSEARCH-21:
-------------------------------------
Assign To: Emmanuel Bernard
Resolution: Fixed
Fix Version: FIRST
Fixed,
But it really should not be used by the application.
ContextHelper.getSessionFactory(Session) should be used instead.
> NPE in SearchFactory while using different threads
> --------------------------------------------------
>
> Key: HSEARCH-21
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-21
> Project: Hibernate Search
> Type: Bug
> Components: engine
> Reporter: Sylvain Vieujot
> Assignee: Emmanuel Bernard
> Fix For: FIRST
>
> Original Estimate: 3 minutes
> Remaining: 3 minutes
>
> java.lang.NullPointerException
> at org.hibernate.search.SearchFactory.getSearchFactory(SearchFactory.java:120)
> at com.seanergie.persistence.SessionsManager.getSearchFactory(SessionsManager.java:374)
> ...
> The contexts ThreadLocal is missing a get method. it is initialized by the first thread that uses it by the static statement, but for the next Thread it hasn't been initialized, and so it contexts.get() returns null.
> Simple fix : add the get method as follows :
> public class SearchFactory {
> private static ThreadLocal<WeakHashMap<Configuration, SearchFactory>> contexts =
> new ThreadLocal<WeakHashMap<Configuration, SearchFactory>>(){
> @Override
> public WeakHashMap<Configuration,SearchFactory> get() {
> return new WeakHashMap<Configuration, SearchFactory>(2);
> }
> };
> static {
> Version.touch();
> contexts.set( new WeakHashMap<Configuration, SearchFactory>(2) );
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list