geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dschnei...@apache.org
Subject [20/51] [abbrv] geode git commit: GEODE-2545: NPE during lucene query execution when cache is closing or region is destroyed
Date Tue, 07 Mar 2017 19:21:43 GMT
GEODE-2545: NPE during lucene query execution when cache is closing or region is destroyed

* Throw an InternalFunctionTargetInvocationException if executing a query while cache is closing


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/c4a5ab28
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/c4a5ab28
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/c4a5ab28

Branch: refs/heads/feature/GEM-1195
Commit: c4a5ab284baba371418cb7a389cb0f327d8becdc
Parents: 8ff2fd4
Author: Jason Huynh <huynhja@gmail.com>
Authored: Mon Feb 27 10:02:23 2017 -0800
Committer: Jason Huynh <huynhja@gmail.com>
Committed: Mon Feb 27 10:02:23 2017 -0800

----------------------------------------------------------------------
 .../distributed/LuceneQueryFunction.java        |  4 ++++
 .../LuceneQueryFunctionJUnitTest.java           | 25 +++++++++-----------
 2 files changed, 15 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/c4a5ab28/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java
index e0a0a22..dd70480 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java
@@ -75,6 +75,10 @@ public class LuceneQueryFunction implements Function, InternalEntity {
     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();
 

http://git-wip-us.apache.org/repos/asf/geode/blob/c4a5ab28/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunctionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunctionJUnitTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunctionJUnitTest.java
index 0d06cab..6a9af9b 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunctionJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunctionJUnitTest.java
@@ -208,20 +208,17 @@ public class LuceneQueryFunctionJUnitTest {
     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 {


Mime
View raw message