Community
Participate
Working Groups
Build Identifier: I20080617-2000 Searching from my local machine with locally hostet infocenter on tomcat works. When I try to search from an rcp application running on another computer I get the following error: Während "Lokale Hilfe" ist ein interner Fehler aufgetreten. java.lang.NullPointerException at org.eclipse.help.internal.util.URLCoder.encode(URLCoder.java:20) at org.eclipse.help.internal.search.SearchResults.addHits(SearchResults.java:51) at org.eclipse.help.internal.search.SearchManager$BufferedSearchHitCollector.flush(SearchManager.java:183) at org.eclipse.help.internal.search.SearchManager.searchLocalAndRemote(SearchManager.java:122) at org.eclipse.help.internal.search.SearchManager.search(SearchManager.java:78) at org.eclipse.help.internal.search.federated.LocalHelp.run(LocalHelp.java:54) at org.eclipse.help.internal.search.federated.FederatedSearchJob.run(FederatedSearchJob.java:38) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) The problem is on the client side. Reproducible: Always Steps to Reproduce: 1. Connect to remote Infocenter hosted on tomcat (not the same machine) 2. Use the search function
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