Addressed PR comments

This commit is contained in:
Ryan Ernst 2015-07-06 10:02:53 -07:00
parent e83ae64ea9
commit 91e3cdb187
2 changed files with 6 additions and 2 deletions

View File

@ -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<String, String> 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<String, String> forcedUnderscoreSettings = null;
for (Map.Entry<String, String> entry : settings.entrySet()) {
String toUnderscoreCase = Strings.toUnderscoreCase(entry.getKey());

View File

@ -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;