From 91e3cdb1874301857576dbd9070a15174c1ac355 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Mon, 6 Jul 2015 10:02:53 -0700 Subject: [PATCH] Addressed PR comments --- .../java/org/elasticsearch/common/settings/Settings.java | 5 ++++- .../elasticsearch/index/mapper/core/AbstractFieldMapper.java | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/common/settings/Settings.java b/core/src/main/java/org/elasticsearch/common/settings/Settings.java index d0145c6dfbe..b3a55fd3245 100644 --- a/core/src/main/java/org/elasticsearch/common/settings/Settings.java +++ b/core/src/main/java/org/elasticsearch/common/settings/Settings.java @@ -22,6 +22,7 @@ package org.elasticsearch.common.settings; import com.google.common.base.Charsets; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -81,7 +82,9 @@ public final class Settings implements ToXContent { private transient ClassLoader classLoader; Settings(Map settings, ClassLoader classLoader) { - this.settings = ImmutableMap.copyOf(new TreeMap<>(settings)); + // we use a sorted map for consistent serialization when using getAsMap() + // TODO: use Collections.unmodifiableMap with a TreeMap + this.settings = ImmutableSortedMap.copyOf(settings); Map forcedUnderscoreSettings = null; for (Map.Entry entry : settings.entrySet()) { String toUnderscoreCase = Strings.toUnderscoreCase(entry.getKey()); diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java index 9393a4944e0..8aac83388e3 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java @@ -292,7 +292,8 @@ public abstract class AbstractFieldMapper extends FieldMapper { super(simpleName); assert indexSettings != null; this.indexCreatedBefore2x = Version.indexCreated(indexSettings).before(Version.V_2_0_0); - this.fieldTypeRef = new MappedFieldTypeReference(fieldType); + this.fieldTypeRef = new MappedFieldTypeReference(fieldType); // the reference ctor freezes the field type + defaultFieldType.freeze(); this.defaultFieldType = defaultFieldType; this.multiFields = multiFields; this.copyTo = copyTo;