Skip to content

Commit

Permalink
GEODE-2545: NPE during lucene query execution when cache is closing o…
Browse files Browse the repository at this point in the history
…r region is destroyed

* Throw an InternalFunctionTargetInvocationException if executing a query while cache is closing
  • Loading branch information
jhuynh1 committed Feb 27, 2017
1 parent 8ff2fd4 commit c4a5ab2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public void execute(FunctionContext context) {
LuceneService service = LuceneServiceProvider.get(region.getCache());
LuceneIndexImpl index =
(LuceneIndexImpl) service.getIndex(searchContext.getIndexName(), region.getFullPath());
if (index == null) {
throw new InternalFunctionInvocationTargetException(
"Index for Region:" + region.getFullPath() + " was not found");
}
RepositoryManager repoManager = index.getRepositoryManager();
LuceneIndexStats stats = index.getIndexStats();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,20 +208,17 @@ public void testIndexRepoQueryFails() throws Exception {
function.execute(mockContext);
}

// Disabled currently as we are retrying the function if a bucket is not found
// @Test(expected = FunctionException.class)
// public void testBucketNotFound() throws Exception {
// when(mockContext.getDataSet()).thenReturn(mockRegion);
// when(mockContext.getArguments()).thenReturn(searchArgs);
// when(mockContext.<TopEntriesCollector>getResultSender()).thenReturn(mockResultSender);
// when(mockRepoManager.getRepositories(eq(mockContext)))
// .thenThrow(new BucketNotFoundException(""));
// LuceneQueryFunction function = new LuceneQueryFunction();
//
// function.execute(mockContext);
//
// verify(mockResultSender).sendException(any(BucketNotFoundException.class));
// }
@Test(expected = FunctionException.class)
public void whenServiceReturnsNullIndexDuringQueryExecutionFunctionExceptionShouldBeThrown()
throws Exception {
when(mockContext.getDataSet()).thenReturn(mockRegion);
when(mockContext.getArguments()).thenReturn(searchArgs);
LuceneQueryFunction function = new LuceneQueryFunction();

when(mockService.getIndex(eq("indexName"), eq(regionPath))).thenReturn(null);

function.execute(mockContext);
}

@Test(expected = FunctionException.class)
public void testReduceError() throws Exception {
Expand Down

0 comments on commit c4a5ab2

Please sign in to comment.