From bbc7fb6ce14c4b16f06eded3ca96cf1bfb9a4fbe Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Thu, 19 Dec 2024 19:29:07 +0100 Subject: [PATCH] Remove unused deprecation loggers It's in the title, just noticed a bunch of these have become unused over time. --- .../common/StemmerTokenFilterFactory.java | 4 +--- .../common/SynonymTokenFilterFactory.java | 3 --- .../action/get/MultiGetRequest.java | 2 -- .../elasticsearch/index/get/GetResult.java | 2 -- .../index/mapper/CompletionFieldMapper.java | 3 --- .../admin/cluster/RestNodesStatsAction.java | 3 --- .../admin/indices/RestIndicesStatsAction.java | 5 ----- .../admin/indices/RestPutMappingAction.java | 4 ---- .../indices/RestValidateQueryAction.java | 3 --- .../search/aggregations/InternalOrder.java | 2 -- .../DateHistogramAggregatorFactory.java | 2 -- .../bucket/histogram/DateIntervalWrapper.java | 4 ---- .../graph/rest/action/RestGraphAction.java | 5 ----- .../ldap/ActiveDirectorySessionFactory.java | 19 +++++++++++-------- .../authc/ldap/support/SessionFactory.java | 2 -- 15 files changed, 12 insertions(+), 51 deletions(-) diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/StemmerTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/StemmerTokenFilterFactory.java index a6e9fccd9d09c..362192ed40df3 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/StemmerTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/StemmerTokenFilterFactory.java @@ -89,8 +89,6 @@ public class StemmerTokenFilterFactory extends AbstractTokenFilterFactory { private final String language; - private static final DeprecationLogger DEPRECATION_LOGGER = DeprecationLogger.getLogger(StemmerTokenFilterFactory.class); - StemmerTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) throws IOException { super(name); this.language = Strings.capitalize(settings.get("language", settings.get("name", "porter"))); @@ -192,7 +190,7 @@ public boolean incrementToken() { } else if ("german".equalsIgnoreCase(language)) { return new SnowballFilter(tokenStream, new GermanStemmer()); } else if ("german2".equalsIgnoreCase(language)) { - DEPRECATION_LOGGER.critical( + deprecationLogger.critical( DeprecationCategory.ANALYSIS, "german2_stemmer_deprecation", "The 'german2' stemmer has been deprecated and folded into the 'german' Stemmer. " diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/SynonymTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/SynonymTokenFilterFactory.java index cb5c01621f45f..04481515384a8 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/SynonymTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/SynonymTokenFilterFactory.java @@ -13,7 +13,6 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.synonym.SynonymFilter; import org.apache.lucene.analysis.synonym.SynonymMap; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexService.IndexCreationContext; @@ -130,8 +129,6 @@ public static SynonymsSource fromSettings(Settings settings) { } } - private static final DeprecationLogger DEPRECATION_LOGGER = DeprecationLogger.getLogger(SynonymTokenFilterFactory.class); - private final String format; private final boolean expand; private final boolean lenient; diff --git a/server/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java b/server/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java index 22537f1f51216..e6469ab75299e 100644 --- a/server/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java +++ b/server/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java @@ -23,7 +23,6 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.lucene.uid.Versions; import org.elasticsearch.core.Nullable; import org.elasticsearch.index.VersionType; @@ -52,7 +51,6 @@ public class MultiGetRequest extends ActionRequest CompositeIndicesRequest, RealtimeRequest, ToXContentObject { - private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(MultiGetRequest.class); private static final ParseField DOCS = new ParseField("docs"); private static final ParseField INDEX = new ParseField("_index"); diff --git a/server/src/main/java/org/elasticsearch/index/get/GetResult.java b/server/src/main/java/org/elasticsearch/index/get/GetResult.java index 3c504d400c7c6..49e0ccffa17cd 100644 --- a/server/src/main/java/org/elasticsearch/index/get/GetResult.java +++ b/server/src/main/java/org/elasticsearch/index/get/GetResult.java @@ -18,7 +18,6 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.index.mapper.IgnoredFieldMapper; import org.elasticsearch.index.mapper.IgnoredSourceFieldMapper; @@ -42,7 +41,6 @@ import static org.elasticsearch.index.seqno.SequenceNumbers.UNASSIGNED_SEQ_NO; public class GetResult implements Writeable, Iterable, ToXContentObject { - private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(GetResult.class); public static final String _INDEX = "_index"; public static final String _ID = "_id"; diff --git a/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java index bb229c795a83e..00c2a872010c7 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java @@ -18,7 +18,6 @@ import org.apache.lucene.search.suggest.document.RegexCompletionQuery; import org.apache.lucene.search.suggest.document.SuggestField; import org.elasticsearch.common.ParsingException; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.unit.Fuzziness; import org.elasticsearch.common.util.Maps; import org.elasticsearch.index.IndexVersion; @@ -156,8 +155,6 @@ public static class Builder extends FieldMapper.Builder { private final NamedAnalyzer defaultAnalyzer; private final IndexVersion indexVersionCreated; - private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(Builder.class); - /** * @param name of the completion field to build */ diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesStatsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesStatsAction.java index c2848781bc7a7..1ed9317c790b8 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesStatsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesStatsAction.java @@ -16,7 +16,6 @@ import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags.Flag; import org.elasticsearch.client.internal.node.NodeClient; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.Scope; @@ -39,8 +38,6 @@ @ServerlessScope(Scope.INTERNAL) public class RestNodesStatsAction extends BaseRestHandler { - private final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestNodesStatsAction.class); - private static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in nodes stats requests is deprecated."; @Override public List routes() { diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndicesStatsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndicesStatsAction.java index b5050eb8007a8..822d9c7151ecf 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndicesStatsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndicesStatsAction.java @@ -16,14 +16,12 @@ import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.internal.node.NodeClient; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.Scope; import org.elasticsearch.rest.ServerlessScope; import org.elasticsearch.rest.action.RestCancellableNodeClient; import org.elasticsearch.rest.action.RestRefCountedChunkedToXContentListener; -import org.elasticsearch.rest.action.document.RestMultiTermVectorsAction; import java.io.IOException; import java.util.Collections; @@ -39,9 +37,6 @@ @ServerlessScope(Scope.INTERNAL) public class RestIndicesStatsAction extends BaseRestHandler { - private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestMultiTermVectorsAction.class); - private static final String TYPES_DEPRECATION_MESSAGE = "[types removal] " - + "Specifying types in indices stats requests is deprecated."; @Override public List routes() { diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutMappingAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutMappingAction.java index ee11f7f520463..f9689cf0d06ac 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutMappingAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutMappingAction.java @@ -13,7 +13,6 @@ import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.internal.node.NodeClient; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; @@ -34,9 +33,6 @@ @ServerlessScope(Scope.PUBLIC) public class RestPutMappingAction extends BaseRestHandler { - public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in put mapping request is deprecated. " - + "Use typeless api instead"; - private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestPutMappingAction.class); @Override public List routes() { diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestValidateQueryAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestValidateQueryAction.java index 8bc7e9aa76551..84f68eceb7c39 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestValidateQueryAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestValidateQueryAction.java @@ -16,7 +16,6 @@ import org.elasticsearch.client.internal.node.NodeClient; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestChannel; import org.elasticsearch.rest.RestRequest; @@ -36,8 +35,6 @@ @ServerlessScope(Scope.PUBLIC) public class RestValidateQueryAction extends BaseRestHandler { - private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestValidateQueryAction.class); - static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in validate query requests is deprecated."; @Override public List routes() { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/InternalOrder.java b/server/src/main/java/org/elasticsearch/search/aggregations/InternalOrder.java index 3593eb5adf7e4..afeeaa9bd6752 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/InternalOrder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/InternalOrder.java @@ -12,7 +12,6 @@ import org.elasticsearch.common.io.stream.DelayableWriteable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.search.aggregations.Aggregator.BucketComparator; import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation.Bucket; import org.elasticsearch.search.aggregations.bucket.terms.BucketAndOrd; @@ -559,7 +558,6 @@ public static void writeHistogramOrder(BucketOrder order, StreamOutput out) thro * Contains logic for parsing a {@link BucketOrder} from a {@link XContentParser}. */ public static class Parser { - private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(Parser.class); /** * Parse a {@link BucketOrder} from {@link XContent}. diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregatorFactory.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregatorFactory.java index 4d0f58756b11c..ce6e97e822b8d 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregatorFactory.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregatorFactory.java @@ -11,7 +11,6 @@ import org.elasticsearch.ElasticsearchStatusException; import org.elasticsearch.common.Rounding; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.AggregatorFactories; @@ -30,7 +29,6 @@ import java.util.Map; public final class DateHistogramAggregatorFactory extends ValuesSourceAggregatorFactory { - private static final DeprecationLogger DEPRECATION_LOGGER = DeprecationLogger.getLogger(DateHistogramAggregatorFactory.class); public static void registerAggregators(ValuesSourceRegistry.Builder builder) { builder.register( diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateIntervalWrapper.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateIntervalWrapper.java index 6886b0e22c20a..752ea46b4da02 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateIntervalWrapper.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateIntervalWrapper.java @@ -15,7 +15,6 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.core.TimeValue; import org.elasticsearch.xcontent.ObjectParser; import org.elasticsearch.xcontent.ParseField; @@ -34,9 +33,6 @@ * - Provides a variety of helper methods to interpret the intervals as different types, depending on caller's need */ public class DateIntervalWrapper implements ToXContentFragment, Writeable { - private static final DeprecationLogger DEPRECATION_LOGGER = DeprecationLogger.getLogger(DateHistogramAggregationBuilder.class); - private static final String DEPRECATION_TEXT = "[interval] on [date_histogram] is deprecated, use [fixed_interval] or " - + "[calendar_interval] in the future."; private static final ParseField FIXED_INTERVAL_FIELD = new ParseField("fixed_interval"); private static final ParseField CALENDAR_INTERVAL_FIELD = new ParseField("calendar_interval"); diff --git a/x-pack/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java b/x-pack/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java index 973151e73d8dc..78870cbb9530b 100644 --- a/x-pack/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java +++ b/x-pack/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java @@ -11,7 +11,6 @@ import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.internal.node.NodeClient; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.core.TimeValue; import org.elasticsearch.protocol.xpack.graph.GraphExploreRequest; import org.elasticsearch.protocol.xpack.graph.GraphExploreRequest.TermBoost; @@ -42,10 +41,6 @@ @ServerlessScope(Scope.PUBLIC) public class RestGraphAction extends BaseRestHandler { - private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestGraphAction.class); - public static final String TYPES_DEPRECATION_MESSAGE = "[types removal]" + " Specifying types in graph requests is deprecated."; - private static final String URI_BASE = "/_xpack"; - public static final ParseField TIMEOUT_FIELD = new ParseField("timeout"); public static final ParseField SIGNIFICANCE_FIELD = new ParseField("use_significance"); public static final ParseField RETURN_DETAILED_INFO = new ParseField("return_detailed_stats"); diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactory.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactory.java index 12f51e0ec7912..57911737cd232 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactory.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactory.java @@ -698,7 +698,6 @@ private boolean usingGlobalCatalog(LDAPConnection ldapConnection) { */ static class UpnADAuthenticator extends ADAuthenticator { static final String UPN_USER_FILTER = "(&(objectClass=user)(userPrincipalName={1}))"; - private final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(logger.getName()); UpnADAuthenticator( RealmConfig config, @@ -725,13 +724,17 @@ static class UpnADAuthenticator extends ADAuthenticator { bindRequestSupplier ); if (userSearchFilter.contains("{0}")) { - deprecationLogger.warn( - DeprecationCategory.SECURITY, - "ldap_settings", - "The use of the account name variable {0} in the setting [" - + RealmSettings.getFullSettingKey(config, ActiveDirectorySessionFactorySettings.AD_UPN_USER_SEARCH_FILTER_SETTING) - + "] has been deprecated and will be removed in a future version!" - ); + DeprecationLogger.getLogger(logger.getName()) + .warn( + DeprecationCategory.SECURITY, + "ldap_settings", + "The use of the account name variable {0} in the setting [" + + RealmSettings.getFullSettingKey( + config, + ActiveDirectorySessionFactorySettings.AD_UPN_USER_SEARCH_FILTER_SETTING + ) + + "] has been deprecated and will be removed in a future version!" + ); } } diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactory.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactory.java index 2a8625b2d93fb..b5e1343382b05 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactory.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactory.java @@ -56,7 +56,6 @@ public abstract class SessionFactory implements Closeable, ReloadableSecurityCom private static final Pattern STARTS_WITH_LDAP = Pattern.compile("^ldap:.*", Pattern.CASE_INSENSITIVE); protected final Logger logger; - protected final DeprecationLogger deprecationLogger; protected final RealmConfig config; protected final TimeValue timeout; protected final SSLService sslService; @@ -71,7 +70,6 @@ public abstract class SessionFactory implements Closeable, ReloadableSecurityCom protected SessionFactory(RealmConfig config, SSLService sslService, ThreadPool threadPool) { this.config = config; this.logger = LogManager.getLogger(getClass()); - this.deprecationLogger = DeprecationLogger.getLogger(logger.getName()); TimeValue searchTimeout = config.getSetting( SessionFactorySettings.TIMEOUT_LDAP_SETTING, () -> SessionFactorySettings.TIMEOUT_DEFAULT