| Summary: | [Help][Search] SearchManager and SearchServlet not re-entrant, causes Nullpointer exception on Infocenter help search (access from another pc in network with rcp application) | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | mgeritz | ||||||||
| Component: | User Assistance | Assignee: | Chris Goldthorpe <cgold> | ||||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||||
| Severity: | normal | ||||||||||
| Priority: | P3 | CC: | cgold | ||||||||
| Version: | 3.4 | ||||||||||
| Target Milestone: | 3.7 M4 | ||||||||||
| Hardware: | PC | ||||||||||
| OS: | Windows XP | ||||||||||
| Whiteboard: | |||||||||||
| Attachments: |
|
||||||||||
|
Description
mgeritz
I think I know what is happening. SearchManager has a local variable "wordsSearched" which is set when the search is started and reset to null at the end of the search. As a result a single instance of SearchManager is not thread safe and it is not safe to reuse it. The help system always uses the same instance of SearchManager - for example BaseHelpSystem.getSearchManager().search(query, collector, new NullProgressMonitor()); If two different threads called SearchManager.search() they could see the exception which you saw. There are a couple of options for solving the problem - either make the SearchManager class thread safe or create a new SearchManager object for every search. I'm not sure why this problem has not been reported before but it needs to be fixed. Created attachment 183055 [details]
JUnit test which illustrates the problem
Created attachment 183250 [details]
Patch which makes SearchManager reentrant
Created attachment 183270 [details]
Improved Patch
I added a test for accessing the SearchServlet in parallel and that showed up a bug in SearchServlet where it was using instance variables. This patch includes the fixes and new tests for the SearchServlet and the SearchManager.
Improved Patch committed to HEAD, Fixed |