geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [31/45] geode git commit: GEODE-2288: Handle null values in the lucene serializer
Date Wed, 11 Jan 2017 00:00:31 GMT
GEODE-2288: Handle null values in the lucene serializer


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

Branch: refs/heads/feature/GEODE-1930-2
Commit: 05d4e8fe849e206bdec62ece6e47ee3887622d8f
Parents: 40c828a
Author: Dan Smith <upthewaterspout@apache.org>
Authored: Fri Jan 6 17:05:18 2017 -0800
Committer: Dan Smith <upthewaterspout@apache.org>
Committed: Mon Jan 9 17:28:24 2017 -0800

----------------------------------------------------------------------
 .../serializer/HeterogeneousLuceneSerializer.java |  4 ++++
 .../LuceneIndexMaintenanceIntegrationTest.java    | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/05d4e8fe/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/serializer/HeterogeneousLuceneSerializer.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/serializer/HeterogeneousLuceneSerializer.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/serializer/HeterogeneousLuceneSerializer.java
index 180e8ee..b0a98a1 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/serializer/HeterogeneousLuceneSerializer.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/repository/serializer/HeterogeneousLuceneSerializer.java
@@ -74,6 +74,10 @@ public class HeterogeneousLuceneSerializer implements LuceneSerializer
{
   @Override
   public void toDocument(Object value, Document doc) {
 
+    if (value == null) {
+      return;
+    }
+
     LuceneSerializer mapper = getFieldMapper(value);
 
     mapper.toDocument(value, doc);

http://git-wip-us.apache.org/repos/asf/geode/blob/05d4e8fe/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexMaintenanceIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexMaintenanceIntegrationTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexMaintenanceIntegrationTest.java
index d7156c9..1feba06 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexMaintenanceIntegrationTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexMaintenanceIntegrationTest.java
@@ -164,6 +164,24 @@ public class LuceneIndexMaintenanceIntegrationTest extends LuceneIntegrationTest
   }
 
   @Test
+  public void nullValuesShouldNotCauseAnException() throws Exception {
+    luceneService.createIndex(INDEX_NAME, REGION_NAME, "title", "description");
+
+    // Configure PR with expiration operation set to destroy
+    Region region = cache.createRegionFactory(RegionShortcut.PARTITION).create(REGION_NAME);
+    region.create(0, null);
+    region.put(113, new TestObject("hello world", "hello world"));
+    LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
+    // Wait for events to be flushed from AEQ.
+    index.waitUntilFlushed(WAIT_FOR_FLUSH_TIME);
+    // Execute query to fetch all the values for "description" field.
+    LuceneQuery query = luceneService.createLuceneQueryFactory().create(INDEX_NAME, REGION_NAME,
+        "description:\"hello world\"", DEFAULT_FIELD);
+    PageableLuceneQueryResults<Integer, TestObject> results = query.findPages();
+    assertEquals(1, results.size());
+  }
+
+  @Test
   public void entriesFlushedToIndexAfterWaitForFlushCalled() {
     luceneService.createIndex(INDEX_NAME, REGION_NAME, "title", "description");
 


Mime
View raw message