geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ladyva...@apache.org
Subject [geode] 01/01: GEODE-3953: Incorrect use of .equals() for comparison of fieldname arrays GEODE-3954: Misleading Exception message with mismatched fieldAnalyzers
Date Fri, 03 Nov 2017 23:25:25 GMT
This is an automated email from the ASF dual-hosted git repository.

ladyvader pushed a commit to branch feature/GEODE-3953
in repository https://gitbox.apache.org/repos/asf/geode.git

commit c4697445a400d5bc2d7b490c475471e2f3226a93
Author: Lynn Hughes-Godfrey <lhughesgodfrey@pivotal.io>
AuthorDate: Fri Nov 3 14:59:55 2017 -0700

    GEODE-3953: Incorrect use of .equals() for comparison of fieldname arrays
    GEODE-3954: Misleading Exception message with mismatched fieldAnalyzers
    
    - corrected equals comparisons of fieldname arrays
    - corrected Exception message for mismatched fieldAnalyzers to refer to field analyzers
(vs. fieldnames) when remote and local fieldAnalyzers are different sizes
    - corrected Exception message to display fieldAnalyzers vs. fieldnames when remote and
local fieldAnalyzer maps are different sizes
---
 .../geode/cache/lucene/internal/LuceneIndexCreationProfile.java  | 9 +++++----
 .../lucene/internal/LuceneIndexCreationProfileJUnitTest.java     | 7 +++++++
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexCreationProfile.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexCreationProfile.java
index e88045d..0adc927 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexCreationProfile.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexCreationProfile.java
@@ -103,7 +103,8 @@ public class LuceneIndexCreationProfile implements CacheServiceProfile,
Versione
     LuceneIndexCreationProfile remoteProfile = (LuceneIndexCreationProfile) profile;
 
     // Verify fields are the same
-    if (!Arrays.equals(remoteProfile.getFieldNames(), getFieldNames())) {
+    if ((getFieldNames().length != remoteProfile.getFieldNames().length) || (!Arrays
+        .asList(getFieldNames()).containsAll(Arrays.asList(remoteProfile.getFieldNames()))))
{
       return LocalizedStrings.LuceneService_CANNOT_CREATE_INDEX_0_ON_REGION_1_WITH_FIELDS_2_BECAUSE_ANOTHER_MEMBER_DEFINES_THE_SAME_INDEX_WITH_FIELDS_3
           .toString(getIndexName(), regionPath, Arrays.toString(getFieldNames()),
               Arrays.toString(remoteProfile.getFieldNames()));
@@ -128,10 +129,10 @@ public class LuceneIndexCreationProfile implements CacheServiceProfile,
Versione
     // since its a transient object.
     if (!getFieldAnalyzers().equals(remoteProfile.getFieldAnalyzers())) {
       if (getFieldAnalyzers().size() != remoteProfile.getFieldAnalyzers().size()) {
-        return LocalizedStrings.LuceneService_CANNOT_CREATE_INDEX_0_ON_REGION_1_WITH_FIELDS_2_BECAUSE_ANOTHER_MEMBER_DEFINES_THE_SAME_INDEX_WITH_FIELDS_3
+        return LocalizedStrings.LuceneService_CANNOT_CREATE_INDEX_0_ON_REGION_1_WITH_FIELD_ANALYZERS_2_BECAUSE_ANOTHER_MEMBER_DEFINES_THE_SAME_INDEX_WITH_FIELD_ANALYZERS_3
             .toString(getIndexName(), regionPath,
-                Arrays.toString(getFieldAnalyzers().keySet().toArray()),
-                Arrays.toString(remoteProfile.getFieldAnalyzers().keySet().toArray()));
+                Arrays.toString(getFieldAnalyzers().values().toArray()),
+                Arrays.toString(remoteProfile.getFieldAnalyzers().values().toArray()));
       }
       // now the 2 maps should have the same size
       for (String field : getFieldAnalyzers().keySet()) {
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexCreationProfileJUnitTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexCreationProfileJUnitTest.java
index 5ecca42..eb0b330 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexCreationProfileJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexCreationProfileJUnitTest.java
@@ -111,6 +111,8 @@ public class LuceneIndexCreationProfileJUnitTest {
     return $(
         new Object[] {getOneFieldLuceneIndexCreationProfile(),
             getTwoFieldLuceneIndexCreationProfile(), CANNOT_CREATE_LUCENE_INDEX_DIFFERENT_FIELDS},
+        new Object[] {getTwoFieldLuceneIndexCreationProfile(),
+            getReverseFieldsLuceneIndexCreationProfile(), null},
         new Object[] {getTwoAnalyzersLuceneIndexCreationProfile(),
             getOneAnalyzerLuceneIndexCreationProfile(new KeywordAnalyzer()),
             CANNOT_CREATE_LUCENE_INDEX_DIFFERENT_ANALYZERS},
@@ -142,6 +144,11 @@ public class LuceneIndexCreationProfileJUnitTest {
         new String[] {"field1", "field2"}, new StandardAnalyzer(), null, null);
   }
 
+  private LuceneIndexCreationProfile getReverseFieldsLuceneIndexCreationProfile() {
+    return new LuceneIndexCreationProfile(INDEX_NAME, REGION_NAME,
+        new String[] {"field2", "field1"}, new StandardAnalyzer(), null, null);
+  }
+
   private LuceneIndexCreationProfile getOneAnalyzerLuceneIndexCreationProfile(Analyzer analyzer)
{
     Map<String, Analyzer> fieldAnalyzers = new HashMap<>();
     fieldAnalyzers.put("field1", analyzer);

-- 
To stop receiving notification emails like this one, please contact
"commits@geode.apache.org" <commits@geode.apache.org>.

Mime
View raw message