geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [5/6] incubator-geode git commit: GEODE-1557: Not logging BucketNotFoundException
Date Tue, 21 Jun 2016 16:37:50 GMT
GEODE-1557: Not logging BucketNotFoundException

Not logging BucketNotFoundException as an error in LuceneEventLister and added
a test shouldIgnoreBucketNotFoundException to verify it

This closes #168


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

Branch: refs/heads/feature/GEODE-1565
Commit: 83c7c661648c9fd7b0dac054dde60e2ae1ef12cd
Parents: 2df8674
Author: Aparna Dharmakkan <adharmakkan@pivotal.io>
Authored: Thu Jun 16 16:07:04 2016 -0700
Committer: nabarun <nnag@pivotal.io>
Committed: Mon Jun 20 16:51:34 2016 -0700

----------------------------------------------------------------------
 .../lucene/internal/LuceneEventListener.java    | 10 +++++++---
 .../internal/LuceneEventListenerJUnitTest.java  | 21 ++++++++++++++++++++
 2 files changed, 28 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/83c7c661/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneEventListener.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneEventListener.java
b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneEventListener.java
index ca8077d..a7150c0 100644
--- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneEventListener.java
+++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneEventListener.java
@@ -36,6 +36,7 @@ import com.gemstone.gemfire.cache.lucene.internal.repository.IndexRepository;
 import com.gemstone.gemfire.cache.query.internal.DefaultQuery;
 import com.gemstone.gemfire.internal.cache.BucketNotFoundException;
 import com.gemstone.gemfire.internal.cache.CacheObserverHolder;
+import com.gemstone.gemfire.internal.cache.partitioned.Bucket;
 import com.gemstone.gemfire.internal.cache.tier.sockets.CacheClientProxy.TestHook;
 import com.gemstone.gemfire.internal.logging.LogService;
 
@@ -68,7 +69,7 @@ public class LuceneEventListener implements AsyncEventListener {
         Region region = event.getRegion();
         Object key = event.getKey();
         Object callbackArgument = event.getCallbackArgument();
-        
+
         IndexRepository repository = repositoryManager.getRepository(region, key, callbackArgument);
 
         Operation op = event.getOperation();
@@ -86,12 +87,15 @@ public class LuceneEventListener implements AsyncEventListener {
         }
         affectedRepos.add(repository);
       }
-      
+
       for(IndexRepository repo : affectedRepos) {
         repo.commit();
       }
       return true;
-    } catch(IOException | BucketNotFoundException e) {
+    } catch(BucketNotFoundException e) {
+      logger.debug("Bucket not found while saving to lucene index: " + e.getMessage());
+      return false;
+    } catch(IOException e) {
       logger.error("Unable to save to lucene index", e);
       return false;
     } finally {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/83c7c661/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneEventListenerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneEventListenerJUnitTest.java
b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneEventListenerJUnitTest.java
index 53c9db1..86ed481 100644
--- a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneEventListenerJUnitTest.java
+++ b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneEventListenerJUnitTest.java
@@ -18,13 +18,17 @@
  */
 package com.gemstone.gemfire.cache.lucene.internal;
 
+import static org.junit.Assert.*;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.*;
 
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.mockito.Mockito;
@@ -34,7 +38,9 @@ import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.asyncqueue.AsyncEvent;
 import com.gemstone.gemfire.cache.lucene.internal.repository.IndexRepository;
 import com.gemstone.gemfire.cache.lucene.internal.repository.RepositoryManager;
+import com.gemstone.gemfire.internal.cache.BucketNotFoundException;
 import com.gemstone.gemfire.test.junit.categories.UnitTest;
+import org.apache.logging.log4j.Logger;
 
 /**
  * Unit test that async event listener dispatched the events
@@ -99,4 +105,19 @@ public class LuceneEventListenerJUnitTest {
     verify(repo1, times(1)).commit();
     verify(repo2, times(1)).commit();
   }
+
+  @Test
+  public void shouldHandleBucketNotFoundExceptionWithoutLoggingError() throws BucketNotFoundException
{
+    RepositoryManager manager = Mockito.mock(RepositoryManager.class);
+    Logger log=Mockito.mock(Logger.class);
+    Mockito.when(manager.getRepository(any(), any(), any()))
+      .thenThrow(BucketNotFoundException.class);
+
+    LuceneEventListener listener = new LuceneEventListener(manager);
+    listener.logger = log;
+    AsyncEvent event = Mockito.mock(AsyncEvent.class);
+    boolean result = listener.processEvents(Arrays.asList(new AsyncEvent[] {event}));
+    assertFalse(result);
+    verify(log, never()).error(anyString(), any(Exception.class));
+  }
 }


Mime
View raw message