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 1f099f354ab..6b41c011591 100644 --- a/core/src/main/java/org/elasticsearch/common/settings/Settings.java +++ b/core/src/main/java/org/elasticsearch/common/settings/Settings.java @@ -21,7 +21,6 @@ package org.elasticsearch.common.settings; import com.google.common.base.Charsets; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSortedMap; import org.elasticsearch.Version; import org.elasticsearch.common.Booleans; import org.elasticsearch.common.Strings; @@ -71,13 +70,12 @@ public final class Settings implements ToXContent { return settingsRequireUnits; } - private ImmutableMap settings; + private SortedMap settings; private final ImmutableMap forcedUnderscoreSettings; Settings(Map settings) { // we use a sorted map for consistent serialization when using getAsMap() - // TODO: use Collections.unmodifiableMap with a TreeMap - this.settings = ImmutableSortedMap.copyOf(settings); + this.settings = Collections.unmodifiableSortedMap(new TreeMap<>(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/DocumentMapperParser.java b/core/src/main/java/org/elasticsearch/index/mapper/DocumentMapperParser.java index 188dc8023c7..bb991ef2603 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/DocumentMapperParser.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/DocumentMapperParser.java @@ -20,7 +20,6 @@ package org.elasticsearch.index.mapper; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSortedMap; import org.elasticsearch.Version; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.ParseFieldMatcher; @@ -36,33 +35,10 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.analysis.AnalysisService; -import org.elasticsearch.index.mapper.core.BinaryFieldMapper; -import org.elasticsearch.index.mapper.core.BooleanFieldMapper; -import org.elasticsearch.index.mapper.core.ByteFieldMapper; -import org.elasticsearch.index.mapper.core.CompletionFieldMapper; -import org.elasticsearch.index.mapper.core.DateFieldMapper; -import org.elasticsearch.index.mapper.core.DoubleFieldMapper; -import org.elasticsearch.index.mapper.core.FloatFieldMapper; -import org.elasticsearch.index.mapper.core.IntegerFieldMapper; -import org.elasticsearch.index.mapper.core.LongFieldMapper; -import org.elasticsearch.index.mapper.core.ShortFieldMapper; -import org.elasticsearch.index.mapper.core.StringFieldMapper; -import org.elasticsearch.index.mapper.core.TokenCountFieldMapper; -import org.elasticsearch.index.mapper.core.TypeParsers; +import org.elasticsearch.index.mapper.core.*; import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper; import org.elasticsearch.index.mapper.geo.GeoShapeFieldMapper; -import org.elasticsearch.index.mapper.internal.AllFieldMapper; -import org.elasticsearch.index.mapper.internal.FieldNamesFieldMapper; -import org.elasticsearch.index.mapper.internal.IdFieldMapper; -import org.elasticsearch.index.mapper.internal.IndexFieldMapper; -import org.elasticsearch.index.mapper.internal.ParentFieldMapper; -import org.elasticsearch.index.mapper.internal.RoutingFieldMapper; -import org.elasticsearch.index.mapper.internal.SourceFieldMapper; -import org.elasticsearch.index.mapper.internal.TTLFieldMapper; -import org.elasticsearch.index.mapper.internal.TimestampFieldMapper; -import org.elasticsearch.index.mapper.internal.TypeFieldMapper; -import org.elasticsearch.index.mapper.internal.UidFieldMapper; -import org.elasticsearch.index.mapper.internal.VersionFieldMapper; +import org.elasticsearch.index.mapper.internal.*; import org.elasticsearch.index.mapper.ip.IpFieldMapper; import org.elasticsearch.index.mapper.object.ObjectMapper; import org.elasticsearch.index.mapper.object.RootObjectMapper; @@ -71,11 +47,7 @@ import org.elasticsearch.index.similarity.SimilarityLookupService; import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptService; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; import static org.elasticsearch.index.mapper.MapperBuilders.doc; @@ -96,7 +68,7 @@ public class DocumentMapperParser { private volatile ImmutableMap typeParsers; private volatile ImmutableMap rootTypeParsers; - private volatile ImmutableMap additionalRootMappers; + private volatile SortedMap additionalRootMappers; public DocumentMapperParser(@IndexSettings Settings indexSettings, MapperService mapperService, AnalysisService analysisService, SimilarityLookupService similarityLookupService, ScriptService scriptService) { @@ -145,7 +117,7 @@ public class DocumentMapperParser { .put(IdFieldMapper.NAME, new IdFieldMapper.TypeParser()) .put(FieldNamesFieldMapper.NAME, new FieldNamesFieldMapper.TypeParser()) .immutableMap(); - additionalRootMappers = ImmutableSortedMap.of(); + additionalRootMappers = Collections.emptySortedMap(); indexVersionCreated = Version.indexCreated(indexSettings); } @@ -162,10 +134,10 @@ public class DocumentMapperParser { rootTypeParsers = new MapBuilder<>(rootTypeParsers) .put(type, typeParser) .immutableMap(); - additionalRootMappers = ImmutableSortedMap.naturalOrder() - .putAll(additionalRootMappers) - .put(type, typeParser) - .build(); + SortedMap newAdditionalRootMappers = new TreeMap<>(); + newAdditionalRootMappers.putAll(additionalRootMappers); + newAdditionalRootMappers.put(type, typeParser); + additionalRootMappers = Collections.unmodifiableSortedMap(newAdditionalRootMappers); } } diff --git a/dev-tools/src/main/resources/forbidden/all-signatures.txt b/dev-tools/src/main/resources/forbidden/all-signatures.txt index 03f59a6f599..e50f672850c 100644 --- a/dev-tools/src/main/resources/forbidden/all-signatures.txt +++ b/dev-tools/src/main/resources/forbidden/all-signatures.txt @@ -106,3 +106,4 @@ com.google.common.util.concurrent.ListenableFuture com.google.common.util.concurrent.SettableFuture com.google.common.util.concurrent.Futures com.google.common.util.concurrent.MoreExecutors +com.google.common.collect.ImmutableSortedMap