ソースを参照

Fix shadowed vars pt3 (#80744)

Part of #19752. Fix more instances where local variable names were shadowing field names.
Rory Hunter 3 年 前
コミット
1d3b096374
29 ファイル変更149 行追加141 行削除
  1. 1 0
      build-tools-internal/src/main/resources/checkstyle.xml
  2. 32 32
      libs/nio/src/test/java/org/elasticsearch/nio/EventHandlerTests.java
  3. 6 6
      libs/nio/src/test/java/org/elasticsearch/nio/NioSelectorTests.java
  4. 9 9
      libs/nio/src/test/java/org/elasticsearch/nio/SocketChannelContextTests.java
  5. 4 4
      libs/nio/src/test/java/org/elasticsearch/nio/TestSelectionKey.java
  6. 3 3
      libs/x-content/src/main/java/org/elasticsearch/xcontent/XContentParserConfiguration.java
  7. 1 1
      libs/x-content/src/test/java/org/elasticsearch/xcontent/ConstructingObjectParserTests.java
  8. 6 6
      libs/x-content/src/test/java/org/elasticsearch/xcontent/ObjectParserTests.java
  9. 9 9
      modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/ArrayValuesSourceAggregationBuilder.java
  10. 2 2
      modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/stats/InternalMatrixStats.java
  11. 5 5
      modules/aggs-matrix-stats/src/test/java/org/elasticsearch/search/aggregations/matrix/stats/InternalMatrixStatsTests.java
  12. 1 0
      modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CJKBigramFilterFactory.java
  13. 4 4
      modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java
  14. 3 3
      modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/HtmlStripCharFilterFactory.java
  15. 3 3
      modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/MultiplexerTokenFilterFactory.java
  16. 8 8
      modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/PathHierarchyTokenizerFactory.java
  17. 1 0
      modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/WordDelimiterGraphTokenFilterFactory.java
  18. 1 0
      modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/WordDelimiterTokenFilterFactory.java
  19. 3 3
      modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/CsvParser.java
  20. 21 17
      modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/DotExpanderProcessor.java
  21. 2 2
      modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DotExpanderProcessorTests.java
  22. 2 2
      modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/ConfigDatabases.java
  23. 3 3
      modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/DatabaseNodeService.java
  24. 2 2
      modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/DatabaseReaderLazyLoader.java
  25. 1 1
      modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/GeoIpDownloader.java
  26. 1 1
      modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/stats/GeoIpDownloaderStats.java
  27. 1 1
      modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/stats/GeoIpDownloaderStatsSerializingTests.java
  28. 4 4
      modules/ingest-user-agent/src/main/java/org/elasticsearch/ingest/useragent/UserAgentParser.java
  29. 10 10
      modules/ingest-user-agent/src/test/java/org/elasticsearch/ingest/useragent/UserAgentProcessorTests.java

+ 1 - 0
build-tools-internal/src/main/resources/checkstyle.xml

@@ -114,6 +114,7 @@
         <property name="ignoreSetter" value="true" />
         <property name="setterCanReturnItsClass" value="true"/>
         <property name="ignoreFormat" value="^(threadPool)$"/>
+        <property name="ignoreAbstractMethods" value="true"/>
         <message key="hidden.field" value="''{0}'' hides a field." />
     </module>
     -->

+ 32 - 32
libs/nio/src/test/java/org/elasticsearch/nio/EventHandlerTests.java

@@ -83,18 +83,18 @@ public class EventHandlerTests extends ESTestCase {
     }
 
     public void testActiveNonServerAddsOP_CONNECTAndOP_READInterest() throws IOException {
-        SocketChannelContext context = mock(SocketChannelContext.class);
-        when(context.getSelectionKey()).thenReturn(new TestSelectionKey(0));
-        handler.handleActive(context);
-        assertEquals(SelectionKey.OP_READ | SelectionKey.OP_CONNECT, context.getSelectionKey().interestOps());
+        SocketChannelContext mockContext = mock(SocketChannelContext.class);
+        when(mockContext.getSelectionKey()).thenReturn(new TestSelectionKey(0));
+        handler.handleActive(mockContext);
+        assertEquals(SelectionKey.OP_READ | SelectionKey.OP_CONNECT, mockContext.getSelectionKey().interestOps());
     }
 
     public void testHandleServerActiveSetsOP_ACCEPTInterest() throws IOException {
-        ServerChannelContext serverContext = mock(ServerChannelContext.class);
-        when(serverContext.getSelectionKey()).thenReturn(new TestSelectionKey(0));
-        handler.handleActive(serverContext);
+        ServerChannelContext mockServerContext = mock(ServerChannelContext.class);
+        when(mockServerContext.getSelectionKey()).thenReturn(new TestSelectionKey(0));
+        handler.handleActive(mockServerContext);
 
-        assertEquals(SelectionKey.OP_ACCEPT, serverContext.getSelectionKey().interestOps());
+        assertEquals(SelectionKey.OP_ACCEPT, mockServerContext.getSelectionKey().interestOps());
     }
 
     public void testHandleAcceptAccept() throws IOException {
@@ -146,9 +146,9 @@ public class EventHandlerTests extends ESTestCase {
     }
 
     public void testHandleReadDelegatesToContext() throws IOException {
-        SocketChannelContext context = mock(SocketChannelContext.class);
-        handler.handleRead(context);
-        verify(context).read();
+        SocketChannelContext mockContext = mock(SocketChannelContext.class);
+        handler.handleRead(mockContext);
+        verify(mockContext).read();
     }
 
     public void testReadExceptionCallsExceptionHandler() {
@@ -165,53 +165,53 @@ public class EventHandlerTests extends ESTestCase {
 
     public void testPostHandlingCallWillCloseTheChannelIfReady() throws IOException {
         NioSocketChannel channel = mock(NioSocketChannel.class);
-        SocketChannelContext context = mock(SocketChannelContext.class);
+        SocketChannelContext mockContext = mock(SocketChannelContext.class);
 
-        when(channel.getContext()).thenReturn(context);
-        when(context.selectorShouldClose()).thenReturn(true);
-        handler.postHandling(context);
+        when(channel.getContext()).thenReturn(mockContext);
+        when(mockContext.selectorShouldClose()).thenReturn(true);
+        handler.postHandling(mockContext);
 
-        verify(context).closeFromSelector();
+        verify(mockContext).closeFromSelector();
     }
 
     public void testPostHandlingCallWillNotCloseTheChannelIfNotReady() throws IOException {
-        SocketChannelContext context = mock(SocketChannelContext.class);
-        when(context.getSelectionKey()).thenReturn(new TestSelectionKey(SelectionKey.OP_READ | SelectionKey.OP_WRITE));
-        when(context.selectorShouldClose()).thenReturn(false);
+        SocketChannelContext mockContext = mock(SocketChannelContext.class);
+        when(mockContext.getSelectionKey()).thenReturn(new TestSelectionKey(SelectionKey.OP_READ | SelectionKey.OP_WRITE));
+        when(mockContext.selectorShouldClose()).thenReturn(false);
 
         NioSocketChannel channel = mock(NioSocketChannel.class);
-        when(channel.getContext()).thenReturn(context);
+        when(channel.getContext()).thenReturn(mockContext);
 
-        handler.postHandling(context);
+        handler.postHandling(mockContext);
 
-        verify(context, times(0)).closeFromSelector();
+        verify(mockContext, times(0)).closeFromSelector();
     }
 
     public void testPostHandlingWillAddWriteIfNecessary() throws IOException {
         TestSelectionKey selectionKey = new TestSelectionKey(SelectionKey.OP_READ);
-        SocketChannelContext context = mock(SocketChannelContext.class);
-        when(context.getSelectionKey()).thenReturn(selectionKey);
-        when(context.readyForFlush()).thenReturn(true);
+        SocketChannelContext mockContext = mock(SocketChannelContext.class);
+        when(mockContext.getSelectionKey()).thenReturn(selectionKey);
+        when(mockContext.readyForFlush()).thenReturn(true);
 
         NioSocketChannel channel = mock(NioSocketChannel.class);
-        when(channel.getContext()).thenReturn(context);
+        when(channel.getContext()).thenReturn(mockContext);
 
         assertEquals(SelectionKey.OP_READ, selectionKey.interestOps());
-        handler.postHandling(context);
+        handler.postHandling(mockContext);
         assertEquals(SelectionKey.OP_READ | SelectionKey.OP_WRITE, selectionKey.interestOps());
     }
 
     public void testPostHandlingWillRemoveWriteIfNecessary() throws IOException {
         TestSelectionKey key = new TestSelectionKey(SelectionKey.OP_READ | SelectionKey.OP_WRITE);
-        SocketChannelContext context = mock(SocketChannelContext.class);
-        when(context.getSelectionKey()).thenReturn(key);
-        when(context.readyForFlush()).thenReturn(false);
+        SocketChannelContext mockContext = mock(SocketChannelContext.class);
+        when(mockContext.getSelectionKey()).thenReturn(key);
+        when(mockContext.readyForFlush()).thenReturn(false);
 
         NioSocketChannel channel = mock(NioSocketChannel.class);
-        when(channel.getContext()).thenReturn(context);
+        when(channel.getContext()).thenReturn(mockContext);
 
         assertEquals(SelectionKey.OP_READ | SelectionKey.OP_WRITE, key.interestOps());
-        handler.postHandling(context);
+        handler.postHandling(mockContext);
         assertEquals(SelectionKey.OP_READ, key.interestOps());
     }
 

+ 6 - 6
libs/nio/src/test/java/org/elasticsearch/nio/NioSelectorTests.java

@@ -85,12 +85,12 @@ public class NioSelectorTests extends ESTestCase {
 
     @SuppressWarnings({ "unchecked", "rawtypes" })
     public void testQueueChannelForClosed() throws IOException {
-        NioChannel channel = mock(NioChannel.class);
+        NioChannel mockChannel = mock(NioChannel.class);
         ChannelContext context = mock(ChannelContext.class);
-        when(channel.getContext()).thenReturn(context);
+        when(mockChannel.getContext()).thenReturn(context);
         when(context.getSelector()).thenReturn(selector);
 
-        selector.queueChannelClose(channel);
+        selector.queueChannelClose(mockChannel);
 
         selector.singleLoop();
 
@@ -100,12 +100,12 @@ public class NioSelectorTests extends ESTestCase {
     @SuppressWarnings({ "unchecked", "rawtypes" })
     public void testCloseException() throws IOException, InterruptedException {
         IOException ioException = new IOException();
-        NioChannel channel = mock(NioChannel.class);
+        NioChannel mockChannel = mock(NioChannel.class);
         ChannelContext context = mock(ChannelContext.class);
-        when(channel.getContext()).thenReturn(context);
+        when(mockChannel.getContext()).thenReturn(context);
         when(context.getSelector()).thenReturn(selector);
 
-        executeOnNewThread(() -> selector.queueChannelClose(channel));
+        executeOnNewThread(() -> selector.queueChannelClose(mockChannel));
 
         doThrow(ioException).when(eventHandler).handleClose(context);
 

+ 9 - 9
libs/nio/src/test/java/org/elasticsearch/nio/SocketChannelContextTests.java

@@ -126,8 +126,8 @@ public class SocketChannelContextTests extends ESTestCase {
             isAccepted
         );
         InboundChannelBuffer buffer = InboundChannelBuffer.allocatingInstance();
-        TestSocketChannelContext context = new TestSocketChannelContext(channel, selector, exceptionHandler, handler, buffer, config);
-        context.register();
+        TestSocketChannelContext testContext = new TestSocketChannelContext(channel, selector, exceptionHandler, handler, buffer, config);
+        testContext.register();
         if (isAccepted) {
             verify(rawChannel, times(0)).connect(any(InetSocketAddress.class));
         } else {
@@ -205,11 +205,11 @@ public class SocketChannelContextTests extends ESTestCase {
             false
         );
         InboundChannelBuffer buffer = InboundChannelBuffer.allocatingInstance();
-        TestSocketChannelContext context = new TestSocketChannelContext(channel, selector, exceptionHandler, handler, buffer, config);
+        TestSocketChannelContext testContext = new TestSocketChannelContext(channel, selector, exceptionHandler, handler, buffer, config);
         doThrow(new SocketException()).doNothing().when(rawSocket).setReuseAddress(tcpReuseAddress);
-        context.register();
+        testContext.register();
         when(rawChannel.finishConnect()).thenReturn(true);
-        context.connect();
+        testContext.connect();
 
         verify(rawSocket, times(2)).setReuseAddress(tcpReuseAddress);
         verify(rawSocket).setKeepAlive(tcpKeepAlive);
@@ -339,7 +339,7 @@ public class SocketChannelContextTests extends ESTestCase {
             when(channel.getRawChannel()).thenReturn(realChannel);
             when(channel.isOpen()).thenReturn(true);
             InboundChannelBuffer buffer = InboundChannelBuffer.allocatingInstance();
-            BytesChannelContext context = new BytesChannelContext(
+            BytesChannelContext bytesChannelContext = new BytesChannelContext(
                 channel,
                 selector,
                 mock(Config.Socket.class),
@@ -347,7 +347,7 @@ public class SocketChannelContextTests extends ESTestCase {
                 handler,
                 buffer
             );
-            context.closeFromSelector();
+            bytesChannelContext.closeFromSelector();
             verify(handler).close();
         }
     }
@@ -360,8 +360,8 @@ public class SocketChannelContextTests extends ESTestCase {
             IntFunction<Page> pageAllocator = (n) -> new Page(ByteBuffer.allocate(n), closer);
             InboundChannelBuffer buffer = new InboundChannelBuffer(pageAllocator);
             buffer.ensureCapacity(1);
-            TestSocketChannelContext context = new TestSocketChannelContext(channel, selector, exceptionHandler, handler, buffer);
-            context.closeFromSelector();
+            TestSocketChannelContext testContext = new TestSocketChannelContext(channel, selector, exceptionHandler, handler, buffer);
+            testContext.closeFromSelector();
             verify(closer).close();
         }
     }

+ 4 - 4
libs/nio/src/test/java/org/elasticsearch/nio/TestSelectionKey.java

@@ -15,11 +15,11 @@ import java.nio.channels.spi.AbstractSelectionKey;
 
 public class TestSelectionKey extends AbstractSelectionKey {
 
-    private int ops = 0;
+    private int interestOps = 0;
     private int readyOps;
 
     public TestSelectionKey(int ops) {
-        this.ops = ops;
+        this.interestOps = ops;
     }
 
     @Override
@@ -34,12 +34,12 @@ public class TestSelectionKey extends AbstractSelectionKey {
 
     @Override
     public int interestOps() {
-        return ops;
+        return interestOps;
     }
 
     @Override
     public SelectionKey interestOps(int ops) {
-        this.ops = ops;
+        this.interestOps = ops;
         return this;
     }
 

+ 3 - 3
libs/x-content/src/main/java/org/elasticsearch/xcontent/XContentParserConfiguration.java

@@ -93,13 +93,13 @@ public class XContentParserConfiguration {
     /**
      * Replace the configured filtering.
      */
-    public XContentParserConfiguration withFiltering(Set<String> includes, Set<String> excludes) {
+    public XContentParserConfiguration withFiltering(Set<String> includeStrings, Set<String> excludeStrings) {
         return new XContentParserConfiguration(
             registry,
             deprecationHandler,
             restApiVersion,
-            FilterPath.compile(includes),
-            FilterPath.compile(excludes)
+            FilterPath.compile(includeStrings),
+            FilterPath.compile(excludeStrings)
         );
     }
 

+ 1 - 1
libs/x-content/src/test/java/org/elasticsearch/xcontent/ConstructingObjectParserTests.java

@@ -380,7 +380,7 @@ public class ConstructingObjectParserTests extends ESTestCase {
         private static ConstructingObjectParser<HasCtorArguments, Void> buildParser(boolean animalRequired, boolean vegetableRequired) {
             ConstructingObjectParser<HasCtorArguments, Void> parser = new ConstructingObjectParser<>(
                 "has_required_arguments",
-                a -> new HasCtorArguments((String) a[0], (Integer) a[1])
+                args -> new HasCtorArguments((String) args[0], (Integer) args[1])
             );
             parser.declareString(animalRequired ? constructorArg() : optionalConstructorArg(), new ParseField("animal"));
             parser.declareInt(vegetableRequired ? constructorArg() : optionalConstructorArg(), new ParseField("vegetable"));

+ 6 - 6
libs/x-content/src/test/java/org/elasticsearch/xcontent/ObjectParserTests.java

@@ -167,7 +167,7 @@ public class ObjectParserTests extends ESTestCase {
                 this.name = name;
             }
 
-            public void setURI(URI uri) {
+            public void setUri(URI uri) {
                 this.uri = uri;
             }
         }
@@ -180,9 +180,9 @@ public class ObjectParserTests extends ESTestCase {
                 this.parser = parser;
             }
 
-            public URI parseURI(XContentParser parser) {
+            public URI parseURI(XContentParser xContentParser) {
                 try {
-                    return this.parser.parseURI(parser);
+                    return this.parser.parseURI(xContentParser);
                 } catch (IOException e) {
                     throw new UncheckedIOException(e);
                 }
@@ -194,7 +194,7 @@ public class ObjectParserTests extends ESTestCase {
         );
         ObjectParser<Foo, CustomParseContext> objectParser = new ObjectParser<>("foo");
         objectParser.declareString(Foo::setName, new ParseField("name"));
-        objectParser.declareObjectOrDefault(Foo::setURI, (p, s) -> s.parseURI(p), () -> null, new ParseField("url"));
+        objectParser.declareObjectOrDefault(Foo::setUri, (p, s) -> s.parseURI(p), () -> null, new ParseField("url"));
         Foo s = objectParser.parse(parser, new Foo(), new CustomParseContext(new ClassicParser()));
         assertEquals(s.uri.getHost(), "foobar");
         assertEquals(s.uri.getPort(), 80);
@@ -705,8 +705,8 @@ public class ObjectParserTests extends ESTestCase {
                 this.ints = ints;
             }
 
-            public void setArray(List<Object> testArray) {
-                this.testArray = testArray;
+            public void setArray(List<Object> array) {
+                this.testArray = array;
             }
         }
         ObjectParser<TestStruct, Void> objectParser = new ObjectParser<>("foo");

+ 9 - 9
modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/ArrayValuesSourceAggregationBuilder.java

@@ -130,11 +130,11 @@ public abstract class ArrayValuesSourceAggregationBuilder<AB extends ArrayValues
      * Sets the field to use for this aggregation.
      */
     @SuppressWarnings("unchecked")
-    public AB fields(List<String> fields) {
-        if (fields == null) {
+    public AB fields(List<String> fieldsArg) {
+        if (fieldsArg == null) {
             throw new IllegalArgumentException("[field] must not be null: [" + name + "]");
         }
-        this.fields = fields;
+        this.fields = fieldsArg;
         return (AB) this;
     }
 
@@ -149,11 +149,11 @@ public abstract class ArrayValuesSourceAggregationBuilder<AB extends ArrayValues
      * Sets the format to use for the output of the aggregation.
      */
     @SuppressWarnings("unchecked")
-    public AB format(String format) {
-        if (format == null) {
+    public AB format(String formatArg) {
+        if (formatArg == null) {
             throw new IllegalArgumentException("[format] must not be null: [" + name + "]");
         }
-        this.format = format;
+        this.format = formatArg;
         return (AB) this;
     }
 
@@ -169,11 +169,11 @@ public abstract class ArrayValuesSourceAggregationBuilder<AB extends ArrayValues
      * document
      */
     @SuppressWarnings("unchecked")
-    public AB missingMap(Map<String, Object> missingMap) {
-        if (missingMap == null) {
+    public AB missingMap(Map<String, Object> missingMapArg) {
+        if (missingMapArg == null) {
             throw new IllegalArgumentException("[missing] must not be null: [" + name + "]");
         }
-        this.missingMap = missingMap;
+        this.missingMap = missingMapArg;
         return (AB) this;
     }
 

+ 2 - 2
modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/stats/InternalMatrixStats.java

@@ -242,8 +242,8 @@ public class InternalMatrixStats extends InternalAggregation implements MatrixSt
         }
 
         if (reduceContext.isFinalReduce()) {
-            MatrixStatsResults results = new MatrixStatsResults(runningStats);
-            return new InternalMatrixStats(name, results.getDocCount(), runningStats, results, getMetadata());
+            MatrixStatsResults matrixStatsResults = new MatrixStatsResults(runningStats);
+            return new InternalMatrixStats(name, matrixStatsResults.getDocCount(), runningStats, matrixStatsResults, getMetadata());
         }
         return new InternalMatrixStats(name, runningStats.docCount, runningStats, null, getMetadata());
     }

+ 5 - 5
modules/aggs-matrix-stats/src/test/java/org/elasticsearch/search/aggregations/matrix/stats/InternalMatrixStatsTests.java

@@ -89,14 +89,14 @@ public class InternalMatrixStatsTests extends InternalAggregationTestCase<Intern
                 name += randomAlphaOfLength(5);
                 break;
             case 1:
-                String[] fields = Arrays.copyOf(this.fields, this.fields.length + 1);
-                fields[fields.length - 1] = "field_" + (fields.length - 1);
-                double[] values = new double[fields.length];
-                for (int i = 0; i < fields.length; i++) {
+                String[] fieldsCopy = Arrays.copyOf(this.fields, this.fields.length + 1);
+                fieldsCopy[fieldsCopy.length - 1] = "field_" + (fieldsCopy.length - 1);
+                double[] values = new double[fieldsCopy.length];
+                for (int i = 0; i < fieldsCopy.length; i++) {
                     values[i] = randomDouble() * 200;
                 }
                 runningStats = new RunningStats();
-                runningStats.add(fields, values);
+                runningStats.add(fieldsCopy, values);
                 break;
             case 2:
                 if (matrixStatsResults == null) {

+ 1 - 0
modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CJKBigramFilterFactory.java

@@ -41,6 +41,7 @@ public final class CJKBigramFilterFactory extends AbstractTokenFilterFactory {
     private final int flags;
     private final boolean outputUnigrams;
 
+    @SuppressWarnings("HiddenField")
     CJKBigramFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
         super(indexSettings, name, settings);
         outputUnigrams = settings.getAsBoolean("output_unigrams", false);

+ 4 - 4
modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java

@@ -148,7 +148,7 @@ public class CommonAnalysisPlugin extends Plugin implements AnalysisPlugin, Scri
 
     private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(CommonAnalysisPlugin.class);
 
-    private final SetOnce<ScriptService> scriptService = new SetOnce<>();
+    private final SetOnce<ScriptService> scriptServiceHolder = new SetOnce<>();
 
     @Override
     public Collection<Object> createComponents(
@@ -164,7 +164,7 @@ public class CommonAnalysisPlugin extends Plugin implements AnalysisPlugin, Scri
         IndexNameExpressionResolver expressionResolver,
         Supplier<RepositoriesService> repositoriesServiceSupplier
     ) {
-        this.scriptService.set(scriptService);
+        this.scriptServiceHolder.set(scriptService);
         return Collections.emptyList();
     }
 
@@ -236,7 +236,7 @@ public class CommonAnalysisPlugin extends Plugin implements AnalysisPlugin, Scri
         filters.put("common_grams", requiresAnalysisSettings(CommonGramsTokenFilterFactory::new));
         filters.put(
             "condition",
-            requiresAnalysisSettings((i, e, n, s) -> new ScriptedConditionTokenFilterFactory(i, n, s, scriptService.get()))
+            requiresAnalysisSettings((i, e, n, s) -> new ScriptedConditionTokenFilterFactory(i, n, s, scriptServiceHolder.get()))
         );
         filters.put("decimal_digit", DecimalDigitFilterFactory::new);
         filters.put("delimited_payload", DelimitedPayloadTokenFilterFactory::new);
@@ -312,7 +312,7 @@ public class CommonAnalysisPlugin extends Plugin implements AnalysisPlugin, Scri
         filters.put("porter_stem", PorterStemTokenFilterFactory::new);
         filters.put(
             "predicate_token_filter",
-            requiresAnalysisSettings((i, e, n, s) -> new PredicateTokenFilterScriptFactory(i, n, s, scriptService.get()))
+            requiresAnalysisSettings((i, e, n, s) -> new PredicateTokenFilterScriptFactory(i, n, s, scriptServiceHolder.get()))
         );
         filters.put("remove_duplicates", RemoveDuplicatesTokenFilterFactory::new);
         filters.put("reverse", ReverseTokenFilterFactory::new);

+ 3 - 3
modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/HtmlStripCharFilterFactory.java

@@ -26,9 +26,9 @@ public class HtmlStripCharFilterFactory extends AbstractCharFilterFactory {
 
     HtmlStripCharFilterFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) {
         super(indexSettings, name);
-        List<String> escapedTags = settings.getAsList("escaped_tags");
-        if (escapedTags.size() > 0) {
-            this.escapedTags = unmodifiableSet(newHashSet(escapedTags));
+        List<String> escapedTagsList = settings.getAsList("escaped_tags");
+        if (escapedTagsList.size() > 0) {
+            this.escapedTags = unmodifiableSet(newHashSet(escapedTagsList));
         } else {
             this.escapedTags = null;
         }

+ 3 - 3
modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/MultiplexerTokenFilterFactory.java

@@ -149,17 +149,17 @@ public class MultiplexerTokenFilterFactory extends AbstractTokenFilterFactory {
          */
         MultiplexTokenFilter(TokenStream input, List<Function<TokenStream, TokenStream>> filters) {
             super(input);
-            TokenStream source = new MultiplexerFilter(input);
+            TokenStream sourceFilter = new MultiplexerFilter(input);
             for (int i = 0; i < filters.size(); i++) {
                 final int slot = i;
-                source = new ConditionalTokenFilter(source, filters.get(i)) {
+                sourceFilter = new ConditionalTokenFilter(sourceFilter, filters.get(i)) {
                     @Override
                     protected boolean shouldFilter() {
                         return slot == selector;
                     }
                 };
             }
-            this.source = source;
+            this.source = sourceFilter;
             this.filterCount = filters.size();
             this.selector = filterCount - 1;
         }

+ 8 - 8
modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/PathHierarchyTokenizerFactory.java

@@ -28,22 +28,22 @@ public class PathHierarchyTokenizerFactory extends AbstractTokenizerFactory {
     PathHierarchyTokenizerFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
         super(indexSettings, settings, name);
         bufferSize = settings.getAsInt("buffer_size", 1024);
-        String delimiter = settings.get("delimiter");
-        if (delimiter == null) {
+        String delimiterString = settings.get("delimiter");
+        if (delimiterString == null) {
             this.delimiter = PathHierarchyTokenizer.DEFAULT_DELIMITER;
-        } else if (delimiter.length() != 1) {
+        } else if (delimiterString.length() != 1) {
             throw new IllegalArgumentException("delimiter must be a one char value");
         } else {
-            this.delimiter = delimiter.charAt(0);
+            this.delimiter = delimiterString.charAt(0);
         }
 
-        String replacement = settings.get("replacement");
-        if (replacement == null) {
+        String replacementString = settings.get("replacement");
+        if (replacementString == null) {
             this.replacement = this.delimiter;
-        } else if (replacement.length() != 1) {
+        } else if (replacementString.length() != 1) {
             throw new IllegalArgumentException("replacement must be a one char value");
         } else {
-            this.replacement = replacement.charAt(0);
+            this.replacement = replacementString.charAt(0);
         }
         this.skip = settings.getAsInt("skip", PathHierarchyTokenizer.DEFAULT_SKIP);
         this.reverse = settings.getAsBoolean("reverse", false);

+ 1 - 0
modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/WordDelimiterGraphTokenFilterFactory.java

@@ -41,6 +41,7 @@ public class WordDelimiterGraphTokenFilterFactory extends AbstractTokenFilterFac
     private final CharArraySet protoWords;
     private final boolean adjustOffsets;
 
+    @SuppressWarnings("HiddenField")
     public WordDelimiterGraphTokenFilterFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) {
         super(indexSettings, name, settings);
 

+ 1 - 0
modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/WordDelimiterTokenFilterFactory.java

@@ -44,6 +44,7 @@ public class WordDelimiterTokenFilterFactory extends AbstractTokenFilterFactory
     private final int flags;
     private final CharArraySet protoWords;
 
+    @SuppressWarnings("HiddenField")
     public WordDelimiterTokenFilterFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) {
         super(indexSettings, name, settings);
 

+ 3 - 3
modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/CsvParser.java

@@ -47,9 +47,9 @@ final class CsvParser {
         this.emptyValue = emptyValue;
     }
 
-    void process(String line) {
-        this.line = line;
-        length = line.length();
+    void process(String lineValue) {
+        this.line = lineValue;
+        length = lineValue.length();
         for (currentIndex = 0; currentIndex < length; currentIndex++) {
             switch (state) {
                 case START:

+ 21 - 17
modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/DotExpanderProcessor.java

@@ -38,59 +38,63 @@ public final class DotExpanderProcessor extends AbstractProcessor {
     @Override
     @SuppressWarnings("unchecked")
     public IngestDocument execute(IngestDocument ingestDocument) throws Exception {
-        String path;
+        String pathToExpand;
         Map<String, Object> map;
         if (this.path != null) {
-            path = this.path + "." + field;
+            pathToExpand = this.path + "." + field;
             map = ingestDocument.getFieldValue(this.path, Map.class);
         } else {
-            path = field;
+            pathToExpand = field;
             map = ingestDocument.getSourceAndMetadata();
         }
 
         if (this.field.equals("*")) {
             for (String key : new ArrayList<>(map.keySet())) {
                 if (key.indexOf('.') > 0) {
-                    path = this.path != null ? this.path + "." + key : key;
-                    expandDot(ingestDocument, path, key, map);
+                    pathToExpand = this.path != null ? this.path + "." + key : key;
+                    expandDot(ingestDocument, pathToExpand, key, map);
                 }
             }
         } else {
-            expandDot(ingestDocument, path, field, map);
+            expandDot(ingestDocument, pathToExpand, field, map);
         }
 
         return ingestDocument;
     }
 
-    private void expandDot(IngestDocument ingestDocument, String path, String field, Map<String, Object> map) {
-        if (map.containsKey(field)) {
-            if (ingestDocument.hasField(path)) {
-                Object value = map.remove(field);
+    private void expandDot(IngestDocument ingestDocument, String pathToExpand, String fieldName, Map<String, Object> map) {
+        if (map.containsKey(fieldName)) {
+            if (ingestDocument.hasField(pathToExpand)) {
+                Object value = map.remove(fieldName);
                 if (override) {
-                    ingestDocument.setFieldValue(path, value);
+                    ingestDocument.setFieldValue(pathToExpand, value);
                 } else {
-                    ingestDocument.appendFieldValue(path, value);
+                    ingestDocument.appendFieldValue(pathToExpand, value);
                 }
             } else {
                 // check whether we actually can expand the field in question into an object field.
                 // part of the path may already exist and if part of it would be a value field (string, integer etc.)
                 // then we can't override it with an object field and we should fail with a good reason.
                 // IngestDocument#setFieldValue(...) would fail too, but the error isn't very understandable
-                for (int index = path.indexOf('.'); index != -1; index = path.indexOf('.', index + 1)) {
-                    String partialPath = path.substring(0, index);
+                for (int index = pathToExpand.indexOf('.'); index != -1; index = pathToExpand.indexOf('.', index + 1)) {
+                    String partialPath = pathToExpand.substring(0, index);
                     if (ingestDocument.hasField(partialPath)) {
                         Object val = ingestDocument.getFieldValue(partialPath, Object.class);
                         if ((val instanceof Map) == false) {
                             throw new IllegalArgumentException(
-                                "cannot expend [" + path + "], because [" + partialPath + "] is not an object field, but a value field"
+                                "cannot expand ["
+                                    + pathToExpand
+                                    + "], because ["
+                                    + partialPath
+                                    + "] is not an object field, but a value field"
                             );
                         }
                     } else {
                         break;
                     }
                 }
-                Object value = map.remove(field);
-                ingestDocument.setFieldValue(path, value);
+                Object value = map.remove(fieldName);
+                ingestDocument.setFieldValue(pathToExpand, value);
             }
         }
     }

+ 2 - 2
modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DotExpanderProcessorTests.java

@@ -71,7 +71,7 @@ public class DotExpanderProcessorTests extends ESTestCase {
         Processor processor1 = new DotExpanderProcessor("_tag", null, null, "foo.bar");
         // foo already exists and if a leaf field and therefor can't be replaced by a map field:
         Exception e = expectThrows(IllegalArgumentException.class, () -> processor1.execute(document1));
-        assertThat(e.getMessage(), equalTo("cannot expend [foo.bar], because [foo] is not an object field, but a value field"));
+        assertThat(e.getMessage(), equalTo("cannot expand [foo.bar], because [foo] is not an object field, but a value field"));
 
         // so because foo is no branch field but a value field the `foo.bar` field can't be expanded
         // into [foo].[bar], so foo should be renamed first into `[foo].[bar]:
@@ -114,7 +114,7 @@ public class DotExpanderProcessorTests extends ESTestCase {
         IngestDocument document2 = new IngestDocument(source, Collections.emptyMap());
         Processor processor2 = new DotExpanderProcessor("_tag", null, null, "foo.bar.baz");
         e = expectThrows(IllegalArgumentException.class, () -> processor2.execute(document2));
-        assertThat(e.getMessage(), equalTo("cannot expend [foo.bar.baz], because [foo.bar] is not an object field, but a value field"));
+        assertThat(e.getMessage(), equalTo("cannot expand [foo.bar.baz], because [foo.bar] is not an object field, but a value field"));
     }
 
     public void testEscapeFields_path() throws Exception {

+ 2 - 2
modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/ConfigDatabases.java

@@ -53,7 +53,7 @@ final class ConfigDatabases implements Closeable {
     }
 
     void initialize(ResourceWatcherService resourceWatcher) throws IOException {
-        configDatabases.putAll(initConfigDatabases(geoipConfigDir));
+        configDatabases.putAll(initConfigDatabases());
 
         FileWatcher watcher = new FileWatcher(geoipConfigDir);
         watcher.addListener(new GeoipDirectoryListener());
@@ -91,7 +91,7 @@ final class ConfigDatabases implements Closeable {
         }
     }
 
-    Map<String, DatabaseReaderLazyLoader> initConfigDatabases(Path geoipConfigDir) throws IOException {
+    Map<String, DatabaseReaderLazyLoader> initConfigDatabases() throws IOException {
         Map<String, DatabaseReaderLazyLoader> databases = new HashMap<>();
 
         if (geoipConfigDir != null && Files.exists(geoipConfigDir)) {

+ 3 - 3
modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/DatabaseNodeService.java

@@ -110,7 +110,7 @@ public final class DatabaseNodeService implements Closeable {
         this.genericExecutor = genericExecutor;
     }
 
-    public void initialize(String nodeId, ResourceWatcherService resourceWatcher, IngestService ingestService) throws IOException {
+    public void initialize(String nodeId, ResourceWatcherService resourceWatcher, IngestService ingestServiceArg) throws IOException {
         configDatabases.initialize(resourceWatcher);
         geoipTmpDirectory = geoipTmpBaseDirectory.resolve(nodeId);
         Files.walkFileTree(geoipTmpDirectory, new FileVisitor<>() {
@@ -147,8 +147,8 @@ public final class DatabaseNodeService implements Closeable {
             Files.createDirectories(geoipTmpDirectory);
         }
         LOGGER.info("initialized database registry, using geoip-databases directory [{}]", geoipTmpDirectory);
-        ingestService.addIngestClusterStateListener(this::checkDatabases);
-        this.ingestService = ingestService;
+        ingestServiceArg.addIngestClusterStateListener(this::checkDatabases);
+        this.ingestService = ingestServiceArg;
     }
 
     public DatabaseReaderLazyLoader getDatabase(String name) {

+ 2 - 2
modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/DatabaseReaderLazyLoader.java

@@ -210,8 +210,8 @@ class DatabaseReaderLazyLoader implements Closeable {
         return md5;
     }
 
-    public void close(boolean deleteDatabaseFileOnClose) throws IOException {
-        this.deleteDatabaseFileOnClose = deleteDatabaseFileOnClose;
+    public void close(boolean shouldDeleteDatabaseFileOnClose) throws IOException {
+        this.deleteDatabaseFileOnClose = shouldDeleteDatabaseFileOnClose;
         close();
     }
 

+ 1 - 1
modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/GeoIpDownloader.java

@@ -163,7 +163,7 @@ public class GeoIpDownloader extends AllocatedPersistentTask {
             if (lastChunk > firstChunk) {
                 state = state.put(name, new Metadata(start, firstChunk, lastChunk - 1, md5, start));
                 updateTaskState();
-                stats = stats.successfulDownload(System.currentTimeMillis() - start).count(state.getDatabases().size());
+                stats = stats.successfulDownload(System.currentTimeMillis() - start).databasesCount(state.getDatabases().size());
                 logger.info("updated geoip database [" + name + "]");
                 deleteOldChunks(name, firstChunk);
             }

+ 1 - 1
modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/stats/GeoIpDownloaderStats.java

@@ -135,7 +135,7 @@ public class GeoIpDownloaderStats implements Task.Status {
         );
     }
 
-    public GeoIpDownloaderStats count(int databasesCount) {
+    public GeoIpDownloaderStats databasesCount(int databasesCount) {
         return new GeoIpDownloaderStats(
             successfulDownloads,
             failedDownloads,

+ 1 - 1
modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/stats/GeoIpDownloaderStatsSerializingTests.java

@@ -32,7 +32,7 @@ public class GeoIpDownloaderStatsSerializingTests extends AbstractSerializingTes
     }
 
     static GeoIpDownloaderStats createRandomInstance() {
-        GeoIpDownloaderStats stats = GeoIpDownloaderStats.EMPTY.count(randomInt(1000));
+        GeoIpDownloaderStats stats = GeoIpDownloaderStats.EMPTY.databasesCount(randomInt(1000));
         int successes = randomInt(20);
         for (int i = 0; i < successes; i++) {
             stats = stats.successfulDownload(randomLongBetween(0, 3000));

+ 4 - 4
modules/ingest-user-agent/src/main/java/org/elasticsearch/ingest/useragent/UserAgentParser.java

@@ -190,12 +190,12 @@ final class UserAgentParser {
     }
 
     private VersionedName findMatch(List<UserAgentSubpattern> possiblePatterns, String agentString) {
-        VersionedName name;
+        VersionedName versionedName;
         for (UserAgentSubpattern pattern : possiblePatterns) {
-            name = pattern.match(agentString);
+            versionedName = pattern.match(agentString);
 
-            if (name != null) {
-                return name;
+            if (versionedName != null) {
+                return versionedName;
             }
         }
 

+ 10 - 10
modules/ingest-user-agent/src/test/java/org/elasticsearch/ingest/useragent/UserAgentProcessorTests.java

@@ -52,7 +52,7 @@ public class UserAgentProcessorTests extends ESTestCase {
     }
 
     public void testNullValueWithIgnoreMissing() throws Exception {
-        UserAgentProcessor processor = new UserAgentProcessor(
+        UserAgentProcessor userAgentProcessor = new UserAgentProcessor(
             randomAlphaOfLength(10),
             null,
             "source_field",
@@ -67,12 +67,12 @@ public class UserAgentProcessorTests extends ESTestCase {
             Collections.singletonMap("source_field", null)
         );
         IngestDocument ingestDocument = new IngestDocument(originalIngestDocument);
-        processor.execute(ingestDocument);
+        userAgentProcessor.execute(ingestDocument);
         assertIngestDocument(originalIngestDocument, ingestDocument);
     }
 
     public void testNonExistentWithIgnoreMissing() throws Exception {
-        UserAgentProcessor processor = new UserAgentProcessor(
+        UserAgentProcessor userAgentProcessor = new UserAgentProcessor(
             randomAlphaOfLength(10),
             null,
             "source_field",
@@ -84,12 +84,12 @@ public class UserAgentProcessorTests extends ESTestCase {
         );
         IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap());
         IngestDocument ingestDocument = new IngestDocument(originalIngestDocument);
-        processor.execute(ingestDocument);
+        userAgentProcessor.execute(ingestDocument);
         assertIngestDocument(originalIngestDocument, ingestDocument);
     }
 
     public void testNullWithoutIgnoreMissing() throws Exception {
-        UserAgentProcessor processor = new UserAgentProcessor(
+        UserAgentProcessor userAgentProcessor = new UserAgentProcessor(
             randomAlphaOfLength(10),
             null,
             "source_field",
@@ -104,12 +104,12 @@ public class UserAgentProcessorTests extends ESTestCase {
             Collections.singletonMap("source_field", null)
         );
         IngestDocument ingestDocument = new IngestDocument(originalIngestDocument);
-        Exception exception = expectThrows(Exception.class, () -> processor.execute(ingestDocument));
+        Exception exception = expectThrows(Exception.class, () -> userAgentProcessor.execute(ingestDocument));
         assertThat(exception.getMessage(), equalTo("field [source_field] is null, cannot parse user-agent."));
     }
 
     public void testNonExistentWithoutIgnoreMissing() throws Exception {
-        UserAgentProcessor processor = new UserAgentProcessor(
+        UserAgentProcessor userAgentProcessor = new UserAgentProcessor(
             randomAlphaOfLength(10),
             null,
             "source_field",
@@ -121,7 +121,7 @@ public class UserAgentProcessorTests extends ESTestCase {
         );
         IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap());
         IngestDocument ingestDocument = new IngestDocument(originalIngestDocument);
-        Exception exception = expectThrows(Exception.class, () -> processor.execute(ingestDocument));
+        Exception exception = expectThrows(Exception.class, () -> userAgentProcessor.execute(ingestDocument));
         assertThat(exception.getMessage(), equalTo("field [source_field] not present as part of path [source_field]"));
     }
 
@@ -303,7 +303,7 @@ public class UserAgentProcessorTests extends ESTestCase {
         InputStream regexStream = UserAgentProcessor.class.getResourceAsStream("/regexes.yml");
         InputStream deviceTypeRegexStream = UserAgentProcessor.class.getResourceAsStream("/device_type_regexes.yml");
         UserAgentParser parser = new UserAgentParser(randomAlphaOfLength(10), regexStream, deviceTypeRegexStream, new UserAgentCache(1000));
-        UserAgentProcessor processor = new UserAgentProcessor(
+        UserAgentProcessor userAgentProcessor = new UserAgentProcessor(
             randomAlphaOfLength(10),
             null,
             "source_field",
@@ -313,7 +313,7 @@ public class UserAgentProcessorTests extends ESTestCase {
             false,
             false
         );
-        processor.execute(ingestDocument);
+        userAgentProcessor.execute(ingestDocument);
         Map<String, Object> data = ingestDocument.getSourceAndMetadata();
 
         assertThat(data, hasKey("target_field"));