Skip to content

Commit

Permalink
Lowercase static final DeprecationLogger instance names (#34887)
Browse files Browse the repository at this point in the history
After discussing on the team's FixItFriday, we concluded that
static final instance variables that are mutable should be lowercased.

Historically, DeprecationLogger was uppercased more frequently than lowercased.
  • Loading branch information
talevy authored Oct 26, 2018
1 parent 3cde135 commit e1fdd00
Showing 37 changed files with 101 additions and 100 deletions.
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@

package org.elasticsearch.analysis.common;

import org.apache.logging.log4j.LogManager;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.CharArraySet;
import org.apache.lucene.analysis.LowerCaseFilter;
@@ -115,7 +116,6 @@
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
import org.elasticsearch.env.Environment;
@@ -151,7 +151,7 @@

public class CommonAnalysisPlugin extends Plugin implements AnalysisPlugin, ScriptPlugin {

private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(Loggers.getLogger(CommonAnalysisPlugin.class));
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(CommonAnalysisPlugin.class));

private final SetOnce<ScriptService> scriptService = new SetOnce<>();

@@ -376,7 +376,7 @@ public List<PreConfiguredCharFilter> getPreConfiguredCharFilters() {
filters.add(PreConfiguredCharFilter.singleton("html_strip", false, HTMLStripCharFilter::new));
filters.add(PreConfiguredCharFilter.singletonWithVersion("htmlStrip", false, (reader, version) -> {
if (version.onOrAfter(org.elasticsearch.Version.V_6_3_0)) {
DEPRECATION_LOGGER.deprecatedAndMaybeLog("htmlStrip_deprecation",
deprecationLogger.deprecatedAndMaybeLog("htmlStrip_deprecation",
"The [htmpStrip] char filter name is deprecated and will be removed in a future version. "
+ "Please change the filter name to [html_strip] instead.");
}
@@ -414,7 +414,7 @@ public List<PreConfiguredTokenFilter> getPreConfiguredTokenFilters() {
new EdgeNGramTokenFilter(input, 1)));
filters.add(PreConfiguredTokenFilter.singletonWithVersion("edgeNGram", false, (reader, version) -> {
if (version.onOrAfter(org.elasticsearch.Version.V_6_4_0)) {
DEPRECATION_LOGGER.deprecatedAndMaybeLog("edgeNGram_deprecation",
deprecationLogger.deprecatedAndMaybeLog("edgeNGram_deprecation",
"The [edgeNGram] token filter name is deprecated and will be removed in a future version. "
+ "Please change the filter name to [edge_ngram] instead.");
}
@@ -438,7 +438,7 @@ public List<PreConfiguredTokenFilter> getPreConfiguredTokenFilters() {
filters.add(PreConfiguredTokenFilter.singleton("ngram", false, reader -> new NGramTokenFilter(reader, 1, 2, false)));
filters.add(PreConfiguredTokenFilter.singletonWithVersion("nGram", false, (reader, version) -> {
if (version.onOrAfter(org.elasticsearch.Version.V_6_4_0)) {
DEPRECATION_LOGGER.deprecatedAndMaybeLog("nGram_deprecation",
deprecationLogger.deprecatedAndMaybeLog("nGram_deprecation",
"The [nGram] token filter name is deprecated and will be removed in a future version. "
+ "Please change the filter name to [ngram] instead.");
}
Original file line number Diff line number Diff line change
@@ -19,16 +19,16 @@

package org.elasticsearch.analysis.common;

import org.apache.logging.log4j.LogManager;
import org.elasticsearch.Version;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.IndexSettings;

public class LegacyDelimitedPayloadTokenFilterFactory extends DelimitedPayloadTokenFilterFactory {
private static final DeprecationLogger DEPRECATION_LOGGER =
new DeprecationLogger(Loggers.getLogger(LegacyDelimitedPayloadTokenFilterFactory.class));
private static final DeprecationLogger deprecationLogger =
new DeprecationLogger(LogManager.getLogger(LegacyDelimitedPayloadTokenFilterFactory.class));

LegacyDelimitedPayloadTokenFilterFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) {
super(indexSettings, env, name, settings);
@@ -37,7 +37,7 @@ public class LegacyDelimitedPayloadTokenFilterFactory extends DelimitedPayloadTo
"[delimited_payload_filter] is not supported for new indices, use [delimited_payload] instead");
}
if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_6_2_0)) {
DEPRECATION_LOGGER.deprecated("Deprecated [delimited_payload_filter] used, replaced by [delimited_payload]");
deprecationLogger.deprecated("Deprecated [delimited_payload_filter] used, replaced by [delimited_payload]");
}
}
}
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@

package org.elasticsearch.percolator;

import org.apache.logging.log4j.LogManager;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.DelegatingAnalyzerWrapper;
import org.apache.lucene.index.BinaryDocValues;
@@ -54,7 +55,6 @@
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
import org.elasticsearch.common.xcontent.XContent;
@@ -95,7 +95,7 @@
public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBuilder> {
public static final String NAME = "percolate";

private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(Loggers.getLogger(ParseField.class));
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(ParseField.class));

static final ParseField DOCUMENT_FIELD = new ParseField("document");
static final ParseField DOCUMENTS_FIELD = new ParseField("documents");
@@ -577,7 +577,7 @@ protected Query doToQuery(QueryShardContext context) throws IOException {
final MapperService mapperService = context.getMapperService();
String type = mapperService.documentMapper().type();
if (documentType != null) {
DEPRECATION_LOGGER.deprecated("[document_type] parameter has been deprecated because types have been deprecated");
deprecationLogger.deprecated("[document_type] parameter has been deprecated because types have been deprecated");
if (documentType.equals(type) == false) {
throw new IllegalArgumentException("specified document_type [" + documentType +
"] is not equal to the actual type [" + type + "]");
Original file line number Diff line number Diff line change
@@ -77,7 +77,7 @@ final class Ec2ClientSettings {

private static final Logger logger = Loggers.getLogger(Ec2ClientSettings.class);

private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(logger);
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);

/** Credentials to authenticate with ec2. */
final AWSCredentials credentials;
@@ -135,11 +135,11 @@ static AWSCredentials loadCredentials(Settings settings) {
return null;
} else {
if (key.length() == 0) {
DEPRECATION_LOGGER.deprecated("Setting [{}] is set but [{}] is not, which will be unsupported in future",
deprecationLogger.deprecated("Setting [{}] is set but [{}] is not, which will be unsupported in future",
SECRET_KEY_SETTING.getKey(), ACCESS_KEY_SETTING.getKey());
}
if (secret.length() == 0) {
DEPRECATION_LOGGER.deprecated("Setting [{}] is set but [{}] is not, which will be unsupported in future",
deprecationLogger.deprecated("Setting [{}] is set but [{}] is not, which will be unsupported in future",
ACCESS_KEY_SETTING.getKey(), SECRET_KEY_SETTING.getKey());
}

Original file line number Diff line number Diff line change
@@ -19,12 +19,12 @@

package org.elasticsearch.http;

import org.apache.logging.log4j.LogManager;
import org.apache.lucene.search.Query;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.lucene.search.Queries;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
@@ -41,7 +41,8 @@
public class TestDeprecatedQueryBuilder extends AbstractQueryBuilder<TestDeprecatedQueryBuilder> {
public static final String NAME = "deprecated_match_all";

private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(Loggers.getLogger(TestDeprecatedQueryBuilder.class));
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(
LogManager.getLogger(TestDeprecatedQueryBuilder.class));

public TestDeprecatedQueryBuilder() {
// nothing to do
@@ -79,7 +80,7 @@ public String getWriteableName() {

@Override
protected Query doToQuery(QueryShardContext context) throws IOException {
DEPRECATION_LOGGER.deprecated("[{}] query is deprecated, but used on [{}] index", NAME, context.index().getName());
deprecationLogger.deprecated("[{}] query is deprecated, but used on [{}] index", NAME, context.index().getName());

return Queries.newMatchAllQuery();
}
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@
*/
public class PutIndexTemplateRequest extends MasterNodeRequest<PutIndexTemplateRequest> implements IndicesRequest, ToXContent {

private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(LogManager.getLogger(PutIndexTemplateRequest.class));
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(PutIndexTemplateRequest.class));

private String name;

@@ -313,7 +313,7 @@ public PutIndexTemplateRequest source(Map<String, Object> templateSource) {
if (name.equals("template")) {
// This is needed to allow for bwc (beats, logstash) with pre-5.0 templates (#21009)
if(entry.getValue() instanceof String) {
DEPRECATION_LOGGER.deprecated("Deprecated field [template] used, replaced by [index_patterns]");
deprecationLogger.deprecated("Deprecated field [template] used, replaced by [index_patterns]");
patterns(Collections.singletonList((String) entry.getValue()));
}
} else if (name.equals("index_patterns")) {
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@

public class IndexTemplateMetaData extends AbstractDiffable<IndexTemplateMetaData> {

private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(LogManager.getLogger(IndexTemplateMetaData.class));
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(IndexTemplateMetaData.class));

private final String name;

@@ -451,7 +451,7 @@ public static IndexTemplateMetaData fromXContent(XContentParser parser, String t
} else if (token.isValue()) {
// Prior to 5.1.0, elasticsearch only supported a single index pattern called `template` (#21009)
if("template".equals(currentFieldName)) {
DEPRECATION_LOGGER.deprecated("Deprecated field [template] used, replaced by [index_patterns]");
deprecationLogger.deprecated("Deprecated field [template] used, replaced by [index_patterns]");
builder.patterns(Collections.singletonList(parser.text()));
} else if ("order".equals(currentFieldName)) {
builder.order(parser.intValue());
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ public static DateTimeZone zoneIdToDateTimeZone(ZoneId zoneId) {
return DateTimeZone.forID(zoneId.getId());
}

private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(LogManager.getLogger(DateFormatters.class));
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(DateFormatters.class));
// pkg private for tests
static final Map<String, String> DEPRECATED_SHORT_TIMEZONES;
static {
@@ -61,7 +61,7 @@ public static ZoneId dateTimeZoneToZoneId(DateTimeZone timeZone) {

String deprecatedId = DEPRECATED_SHORT_TIMEZONES.get(timeZone.getID());
if (deprecatedId != null) {
DEPRECATION_LOGGER.deprecatedAndMaybeLog("timezone",
deprecationLogger.deprecatedAndMaybeLog("timezone",
"Use of short timezone id " + timeZone.getID() + " is deprecated. Use " + deprecatedId + " instead");
return ZoneId.of(deprecatedId);
}
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@

public class ByteSizeValue implements Writeable, Comparable<ByteSizeValue>, ToXContentFragment {

private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(LogManager.getLogger(ByteSizeValue.class));
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(ByteSizeValue.class));

public static final ByteSizeValue ZERO = new ByteSizeValue(0, ByteSizeUnit.BYTES);

@@ -237,7 +237,7 @@ private static ByteSizeValue parse(final String initialInput, final String norma
} catch (final NumberFormatException e) {
try {
final double doubleValue = Double.parseDouble(s);
DEPRECATION_LOGGER.deprecated(
deprecationLogger.deprecated(
"Fractional bytes values are deprecated. Use non-fractional bytes values instead: [{}] found for setting [{}]",
initialInput, settingName);
return new ByteSizeValue((long) (doubleValue * unit.toBytes(1)));
Original file line number Diff line number Diff line change
@@ -42,19 +42,19 @@ public class LoggingDeprecationHandler implements DeprecationHandler {
* Changing that will require some research to make super duper
* sure it is safe.
*/
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(LogManager.getLogger(ParseField.class));
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(ParseField.class));

private LoggingDeprecationHandler() {
// Singleton
}

@Override
public void usedDeprecatedName(String usedName, String modernName) {
DEPRECATION_LOGGER.deprecated("Deprecated field [{}] used, expected [{}] instead", usedName, modernName);
deprecationLogger.deprecated("Deprecated field [{}] used, expected [{}] instead", usedName, modernName);
}

@Override
public void usedDeprecatedField(String usedName, String replacedWith) {
DEPRECATION_LOGGER.deprecated("Deprecated field [{}] used, replaced by [{}]", usedName, replacedWith);
deprecationLogger.deprecated("Deprecated field [{}] used, replaced by [{}]", usedName, replacedWith);
}
}
4 changes: 2 additions & 2 deletions server/src/main/java/org/elasticsearch/http/HttpInfo.java
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@

public class HttpInfo implements Writeable, ToXContentFragment {

private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(LogManager.getLogger(HttpInfo.class));
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(HttpInfo.class));

/** Whether to add hostname to publish host field when serializing. */
private static final boolean CNAME_IN_PUBLISH_HOST =
@@ -86,7 +86,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
if (cnameInPublishHost) {
publishAddressString = hostString + '/' + publishAddress.toString();
} else {
DEPRECATION_LOGGER.deprecated(
deprecationLogger.deprecated(
"[http.publish_host] was printed as [ip:port] instead of [hostname/ip:port]. "
+ "This format is deprecated and will change to [hostname/ip:port] in a future version. "
+ "Use -Des.http.cname_in_publish_address=true to enforce non-deprecated formatting."
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@

public class DynamicTemplate implements ToXContentObject {

private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(LogManager.getLogger(DynamicTemplate.class));
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(DynamicTemplate.class));

public enum MatchType {
SIMPLE {
@@ -208,7 +208,7 @@ public static DynamicTemplate parse(String name, Map<String, Object> conf,
if (indexVersionCreated.onOrAfter(Version.V_6_0_0_alpha1)) {
throw e;
} else {
DEPRECATION_LOGGER.deprecated("match_mapping_type [" + matchMappingType + "] is invalid and will be ignored: "
deprecationLogger.deprecated("match_mapping_type [" + matchMappingType + "] is invalid and will be ignored: "
+ e.getMessage());
// this template is on an unknown type so it will never match anything
// null indicates that the template should be ignored
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@
*/
public class FieldNamesFieldMapper extends MetadataFieldMapper {

private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(
LogManager.getLogger(FieldNamesFieldMapper.class));

public static final String NAME = "_field_names";
@@ -184,7 +184,7 @@ public Query termQuery(Object value, QueryShardContext context) {
if (isEnabled() == false) {
throw new IllegalStateException("Cannot run [exists] queries if the [_field_names] field is disabled");
}
DEPRECATION_LOGGER.deprecated(
deprecationLogger.deprecated(
"terms query on the _field_names field is deprecated and will be removed, use exists query instead");
return super.termQuery(value, context);
}
Original file line number Diff line number Diff line change
@@ -117,7 +117,7 @@ public enum MergeReason {
"_size", "_timestamp", "_ttl", IgnoredFieldMapper.NAME
);

private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(LogManager.getLogger(MapperService.class));
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(MapperService.class));

private final IndexAnalyzers indexAnalyzers;

@@ -408,7 +408,7 @@ private synchronized Map<String, DocumentMapper> internalMerge(@Nullable Documen
throw new IllegalArgumentException("The [default] mapping cannot be updated on index [" + index().getName() +
"]: defaults mappings are not useful anymore now that indices can have at most one type.");
} else if (reason == MergeReason.MAPPING_UPDATE) { // only log in case of explicit mapping updates
DEPRECATION_LOGGER.deprecated("[_default_] mapping is deprecated since it is not useful anymore now that indexes " +
deprecationLogger.deprecated("[_default_] mapping is deprecated since it is not useful anymore now that indexes " +
"cannot have more than one type");
}
assert defaultMapper.type().equals(DEFAULT_MAPPING);
Loading

0 comments on commit e1fdd00

Please sign in to comment.