"Incorrect usage of JIRA/lucene search API" for SearchService.search in JIRA server 8.0.0-m0021/EAP07

jira-software
eap
jira
jira-80
jira-server

#1

Calls to SearchService.search(), where searchService is of type com.atlassian.jira.bc.issue.search.SearchService, fail with this exception/stacktrace:

[INFO] [talledLocalContainer] java.lang.IllegalStateException: Incorrect usage of JIRA/lucene search API. You can only create/use: ManagedIndexSearcher inside a context (request or Jira-Thread-Local). Check: JiraThreadLocalUtils for details.
[INFO] [talledLocalContainer] at com.atlassian.jira.index.ManagedIndexSearcherFactory.createFrom(ManagedIndexSearcherFactory.java:15)
[INFO] [talledLocalContainer] at com.atlassian.jira.issue.index.ThreadLocalSearcherCache$Cache.retrieveEntitySearcher(ThreadLocalSearcherCache.java:80)
[INFO] [talledLocalContainer] at com.atlassian.jira.issue.index.ThreadLocalSearcherCache.getSearcher(ThreadLocalSearcherCache.java:33)
[INFO] [talledLocalContainer] at com.atlassian.jira.issue.index.DefaultIndexManager.getEntitySearcher(DefaultIndexManager.java:888)
[INFO] [talledLocalContainer] at com.atlassian.jira.issue.index.DefaultIndexManager.getIssueSearcher(DefaultIndexManager.java:865)
[INFO] [talledLocalContainer] at sun.reflect.GeneratedMethodAccessor837.invoke(Unknown Source)
[INFO] [talledLocalContainer] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO] [talledLocalContainer] at java.lang.reflect.Method.invoke(Method.java:498)
[INFO] [talledLocalContainer] at com.atlassian.jira.config.component.SwitchingInvocationHandler.invoke(SwitchingInvocationHandler.java:38)
[INFO] [talledLocalContainer] at com.sun.proxy.$Proxy8.getIssueSearcher(Unknown Source)
[INFO] [talledLocalContainer] at com.atlassian.jira.issue.search.SearchProviderFactoryImpl.getSearcher(SearchProviderFactoryImpl.java:17)
[INFO] [talledLocalContainer] at com.atlassian.jira.issue.search.providers.LuceneSearchProvider.getIssueSearcher(LuceneSearchProvider.java:129)
[INFO] [talledLocalContainer] at com.atlassian.jira.issue.search.providers.LuceneSearchProvider.searchDocuments(LuceneSearchProvider.java:457)
[INFO] [talledLocalContainer] at com.atlassian.jira.issue.search.providers.LuceneSearchProvider.runSearch(LuceneSearchProvider.java:452)
[INFO] [talledLocalContainer] at com.atlassian.jira.issue.search.providers.LuceneSearchProvider.getHits(LuceneSearchProvider.java:219)
[INFO] [talledLocalContainer] at com.atlassian.jira.issue.search.providers.LuceneSearchProvider.search(LuceneSearchProvider.java:374)
[INFO] [talledLocalContainer] at com.atlassian.jira.issue.search.providers.LuceneSearchProvider.search(LuceneSearchProvider.java:134)
[INFO] [talledLocalContainer] at com.atlassian.jira.issue.search.providers.LuceneSearchProvider.search(LuceneSearchProvider.java:139)
[INFO] [talledLocalContainer] at com.atlassian.jira.bc.issue.search.DefaultSearchService.search(DefaultSearchService.java:117)

The Lucene Upgrade document mentions the following changes:

Now we have 2 new classes:

  • com.atlassian.jira.index.ManagedIndexSearcher that does not need to be closed manually
  • com.atlassian.jira.index.UnmanagedIndexSearcher which has to be closed by its user

However there is no information explaining how to choose between the two classes, or if it’s even possible.

At run-time, an instance of class DefaultSearchService is created, and it is passed an object of type LuceneSearchProvider into it’s constructor.

Is there a way to use the UnmanagedIndexSearcher instead? Would that solve the issue?

Or should the call to SearchService.search() be wrapped with calls to using JiraThreadLocalUtil? i.e. .preCall() and .postCall()

Regards,
Robert.


#2

Have you get any solution for this ? we are facing same issue with JIRA EAP 8.0.

we have tried
SearchService.search() be wrapped with calls to using JiraThreadLocalUtil ? i.e. .preCall() and .postCall()… But Is there any other solution ?


#3

Hi Vinit,

I’m not aware of any other solution. Wrapping the SearchService.search() call with JiraThreadLocalUtil solved the issue for me so that’s what I used

Regards,
Robert.