Skip to content

Commit f0df8b6

Browse files
author
Vladimir Kotal
authored
avoid returning null objects from getIndexSearcher() (#2701)
fixes #2700
1 parent f98c36a commit f0df8b6

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/RuntimeEnvironment.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,27 +1715,21 @@ public void maybeRefreshIndexSearchers() {
17151715
* to the SearcherManager. This is done with returnIndexSearcher().
17161716
* The return of the IndexSearcher should happen only after the search result data are read fully.
17171717
*
1718-
* @param proj project
1718+
* @param projectName project
17191719
* @return SearcherManager for given project
17201720
* @throws IOException I/O exception
17211721
*/
1722-
public SuperIndexSearcher getIndexSearcher(String proj) throws IOException {
1723-
SearcherManager mgr = searcherManagerMap.get(proj);
1724-
SuperIndexSearcher searcher = null;
1722+
public SuperIndexSearcher getIndexSearcher(String projectName) throws IOException {
1723+
SearcherManager mgr = searcherManagerMap.get(projectName);
1724+
SuperIndexSearcher searcher;
17251725

17261726
if (mgr == null) {
17271727
File indexDir = new File(getDataRootPath(), IndexDatabase.INDEX_DIR);
1728-
1729-
try {
1730-
Directory dir = FSDirectory.open(new File(indexDir, proj).toPath());
1731-
mgr = new SearcherManager(dir, new ThreadpoolSearcherFactory());
1732-
searcherManagerMap.put(proj, mgr);
1733-
searcher = (SuperIndexSearcher) mgr.acquire();
1734-
searcher.setSearcherManager(mgr);
1735-
} catch (IOException ex) {
1736-
LOGGER.log(Level.SEVERE,
1737-
"cannot construct IndexSearcher for project " + proj, ex);
1738-
}
1728+
Directory dir = FSDirectory.open(new File(indexDir, projectName).toPath());
1729+
mgr = new SearcherManager(dir, new ThreadpoolSearcherFactory());
1730+
searcherManagerMap.put(projectName, mgr);
1731+
searcher = (SuperIndexSearcher) mgr.acquire();
1732+
searcher.setSearcherManager(mgr);
17391733
} else {
17401734
searcher = (SuperIndexSearcher) mgr.acquire();
17411735
searcher.setSearcherManager(mgr);

opengrok-indexer/src/main/java/org/opengrok/indexer/web/SearchHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ public List<Suggestion> getSuggestions() {
503503
}
504504
} catch (IOException e) {
505505
LOGGER.log(Level.WARNING, "Got exception while getting "
506-
+ "spelling suggestions: ", e);
506+
+ "spelling suggestions for project " + proj + ":", e);
507507
} finally {
508508
if (ir != null && closeOnDestroy) {
509509
try {

0 commit comments

Comments
 (0)