diff --git a/build-tools/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java b/build-tools/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java index 880d7a069e9a7..cab4d55210864 100644 --- a/build-tools/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java +++ b/build-tools/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java @@ -186,7 +186,7 @@ public static void extendSourceSet(Project project, String parentSourceSetName, * task execution time. */ public static String getProjectPathFromTask(String taskPath) { - int lastDelimiterIndex = taskPath.lastIndexOf(":"); + int lastDelimiterIndex = taskPath.lastIndexOf(':'); return lastDelimiterIndex == 0 ? ":" : taskPath.substring(0, lastDelimiterIndex); } diff --git a/client/rest/src/main/java/org/elasticsearch/client/RestClient.java b/client/rest/src/main/java/org/elasticsearch/client/RestClient.java index ed087bef0ac76..8b769d3d311d4 100644 --- a/client/rest/src/main/java/org/elasticsearch/client/RestClient.java +++ b/client/rest/src/main/java/org/elasticsearch/client/RestClient.java @@ -159,10 +159,10 @@ public class RestClient implements Closeable { public static RestClientBuilder builder(String cloudId) { // there is an optional first portion of the cloudId that is a human readable string, but it is not used. if (cloudId.contains(":")) { - if (cloudId.indexOf(":") == cloudId.length() - 1) { + if (cloudId.indexOf(':') == cloudId.length() - 1) { throw new IllegalStateException("cloudId " + cloudId + " must begin with a human readable identifier followed by a colon"); } - cloudId = cloudId.substring(cloudId.indexOf(":") + 1); + cloudId = cloudId.substring(cloudId.indexOf(':') + 1); } String decoded = new String(Base64.getDecoder().decode(cloudId), UTF_8); diff --git a/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/RegisteredDomainProcessor.java b/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/RegisteredDomainProcessor.java index 6b949889fc960..acccdd92fc9b1 100644 --- a/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/RegisteredDomainProcessor.java +++ b/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/RegisteredDomainProcessor.java @@ -91,7 +91,7 @@ private DomainInfo getRegisteredDomain(IngestDocument d) { } return null; } - if (registeredDomain.indexOf(".") == -1) { + if (registeredDomain.indexOf('.') == -1) { // we have domain with no matching public suffix, but "." in it return null; } @@ -117,7 +117,7 @@ private DomainInfo(String eTLD) { } private DomainInfo(String registeredDomain, String domain) { - int index = registeredDomain.indexOf(".") + 1; + int index = registeredDomain.indexOf('.') + 1; if (index > 0 && index < registeredDomain.length()) { this.domain = domain; this.eTLD = registeredDomain.substring(index); diff --git a/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/UriPartsProcessor.java b/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/UriPartsProcessor.java index 2a7025a02ac30..66e6df5fde58d 100644 --- a/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/UriPartsProcessor.java +++ b/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/UriPartsProcessor.java @@ -155,7 +155,7 @@ private static Map getUriParts(URI uri, URL fallbackUrl) { if (userInfo != null) { uriParts.put("user_info", userInfo); if (userInfo.contains(":")) { - int colonIndex = userInfo.indexOf(":"); + int colonIndex = userInfo.indexOf(':'); uriParts.put("username", userInfo.substring(0, colonIndex)); uriParts.put("password", colonIndex < userInfo.length() ? userInfo.substring(colonIndex + 1) : ""); } diff --git a/modules/lang-painless/src/doc/java/org/elasticsearch/painless/ContextApiSpecGenerator.java b/modules/lang-painless/src/doc/java/org/elasticsearch/painless/ContextApiSpecGenerator.java index 29a73ea1742e0..d4b11d159ae44 100644 --- a/modules/lang-painless/src/doc/java/org/elasticsearch/painless/ContextApiSpecGenerator.java +++ b/modules/lang-painless/src/doc/java/org/elasticsearch/painless/ContextApiSpecGenerator.java @@ -121,7 +121,7 @@ public JavaClassFilesystemResolver(Path root, Map pkgRoots) { public InputStream openClassFile(String className) throws IOException { // TODO(stu): handle primitives & not stdlib if (className.contains(".")) { - int dollarPosition = className.indexOf("$"); + int dollarPosition = className.indexOf('$'); if (dollarPosition >= 0) { className = className.substring(0, dollarPosition); } @@ -131,10 +131,10 @@ public InputStream openClassFile(String className) throws IOException { Path classPath = root.resolve(path + ".java"); return new FileInputStream(classPath.toFile()); } else { - String packageName = className.substring(0, className.lastIndexOf(".")); + String packageName = className.substring(0, className.lastIndexOf('.')); Path packageRoot = pkgRoots.get(packageName); if (packageRoot != null) { - Path classPath = packageRoot.resolve(className.substring(className.lastIndexOf(".") + 1) + ".java"); + Path classPath = packageRoot.resolve(className.substring(className.lastIndexOf('.') + 1) + ".java"); return new FileInputStream(classPath.toFile()); } } diff --git a/modules/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureStorageSettings.java b/modules/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureStorageSettings.java index f804fe1e46282..93a388dea98ae 100644 --- a/modules/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureStorageSettings.java +++ b/modules/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureStorageSettings.java @@ -338,7 +338,7 @@ private String getProperty(String propertyName) { for (int i = 0; i < settings.length; i++) { String setting = settings[i].trim(); if (setting.length() > 0) { - final int idx = setting.indexOf("="); + final int idx = setting.indexOf('='); if (idx == -1 || idx == 0 || idx == settings[i].length() - 1) { new IllegalArgumentException("Invalid connection string: " + getConnectString()); } diff --git a/plugins/analysis-icu/src/main/java/org/elasticsearch/plugin/analysis/icu/IcuTokenizerFactory.java b/plugins/analysis-icu/src/main/java/org/elasticsearch/plugin/analysis/icu/IcuTokenizerFactory.java index e869ebf20f59e..0a73eb38bd45c 100644 --- a/plugins/analysis-icu/src/main/java/org/elasticsearch/plugin/analysis/icu/IcuTokenizerFactory.java +++ b/plugins/analysis-icu/src/main/java/org/elasticsearch/plugin/analysis/icu/IcuTokenizerFactory.java @@ -58,7 +58,7 @@ private static ICUTokenizerConfig getIcuConfig(Environment env, Settings setting List ruleFiles = settings.getAsList(RULE_FILES); for (String scriptAndResourcePath : ruleFiles) { - int colonPos = scriptAndResourcePath.indexOf(":"); + int colonPos = scriptAndResourcePath.indexOf(':'); if (colonPos == -1 || colonPos == scriptAndResourcePath.length() - 1) { throw new IllegalArgumentException(RULE_FILES + " should contain comma-separated \"code:rulefile\" pairs"); } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MetadataRolloverService.java b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MetadataRolloverService.java index e107b0d063778..4972a784cc2bd 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MetadataRolloverService.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MetadataRolloverService.java @@ -380,7 +380,7 @@ static String generateRolloverIndexName(String sourceIndexName) { String resolvedName = IndexNameExpressionResolver.resolveDateMathExpression(sourceIndexName); final boolean isDateMath = sourceIndexName.equals(resolvedName) == false; if (INDEX_NAME_PATTERN.matcher(resolvedName).matches()) { - int numberIndex = sourceIndexName.lastIndexOf("-"); + int numberIndex = sourceIndexName.lastIndexOf('-'); assert numberIndex != -1 : "no separator '-' found"; int counter = Integer.parseInt( sourceIndexName.substring(numberIndex + 1, isDateMath ? sourceIndexName.length() - 1 : sourceIndexName.length()) diff --git a/server/src/main/java/org/elasticsearch/action/fieldcaps/ResponseRewriter.java b/server/src/main/java/org/elasticsearch/action/fieldcaps/ResponseRewriter.java index d39dd28b32611..38b0287522207 100644 --- a/server/src/main/java/org/elasticsearch/action/fieldcaps/ResponseRewriter.java +++ b/server/src/main/java/org/elasticsearch/action/fieldcaps/ResponseRewriter.java @@ -109,7 +109,7 @@ private static boolean isNestedField(String field, Set nestedParents) { } private static boolean isNotMultifield(String field, Set objectFields) { - int lastDotPos = field.lastIndexOf("."); + int lastDotPos = field.lastIndexOf('.'); if (lastDotPos == -1) { return true; } diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java index 2730cc8909790..22672756bdaf0 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java @@ -2890,7 +2890,7 @@ public static int getRoutingFactor(int sourceNumberOfShards, int targetNumberOfS * number */ public static int parseIndexNameCounter(String indexName) { - int numberIndex = indexName.lastIndexOf("-"); + int numberIndex = indexName.lastIndexOf('-'); if (numberIndex == -1) { throw new IllegalArgumentException("no - separator found in index name [" + indexName + "]"); } diff --git a/server/src/main/java/org/elasticsearch/common/regex/Regex.java b/server/src/main/java/org/elasticsearch/common/regex/Regex.java index 1b60a5dce9038..532fc2ae9a019 100644 --- a/server/src/main/java/org/elasticsearch/common/regex/Regex.java +++ b/server/src/main/java/org/elasticsearch/common/regex/Regex.java @@ -44,7 +44,7 @@ public static boolean isMatchAllPattern(String str) { } public static boolean isSuffixMatchPattern(String str) { - return str.length() > 1 && str.indexOf("*") == str.length() - 1; + return str.length() > 1 && str.indexOf('*') == str.length() - 1; } /** Return an {@link Automaton} that matches the given pattern. */ diff --git a/server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java index 7f954a570348a..7a807f767611b 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java @@ -127,7 +127,7 @@ public final void addDynamic(String name, String prefix, Mapper mapper, Document // of the mapper name. So for a mapper 'foo.bar.baz', we locate 'foo' and then // call addDynamic on it with the name 'bar.baz', and next call addDynamic on 'bar' with the name 'baz'. else { - int firstDotIndex = name.indexOf("."); + int firstDotIndex = name.indexOf('.'); String immediateChild = name.substring(0, firstDotIndex); String immediateChildFullName = prefix == null ? immediateChild : prefix + "." + immediateChild; ObjectMapper.Builder parentBuilder = findObjectBuilder(immediateChildFullName, context); diff --git a/server/src/main/java/org/elasticsearch/plugins/PluginsService.java b/server/src/main/java/org/elasticsearch/plugins/PluginsService.java index d2f31697e1021..038b03c5dd93f 100644 --- a/server/src/main/java/org/elasticsearch/plugins/PluginsService.java +++ b/server/src/main/java/org/elasticsearch/plugins/PluginsService.java @@ -865,7 +865,7 @@ static final URI uncheckedToURI(URL url) { static final String toPackageName(String className) { assert className.endsWith(".") == false; - int index = className.lastIndexOf("."); + int index = className.lastIndexOf('.'); if (index == -1) { throw new IllegalStateException("invalid class name:" + className); } diff --git a/server/src/main/java/org/elasticsearch/plugins/PluginsUtils.java b/server/src/main/java/org/elasticsearch/plugins/PluginsUtils.java index 0533f535a19f1..becc5ef05e846 100644 --- a/server/src/main/java/org/elasticsearch/plugins/PluginsUtils.java +++ b/server/src/main/java/org/elasticsearch/plugins/PluginsUtils.java @@ -196,7 +196,7 @@ public static void checkForFailedPluginRemovals(final Path pluginsDirectory) thr if (iterator.hasNext()) { final Path removing = iterator.next(); final String fileName = removing.getFileName().toString(); - final String name = fileName.substring(1 + fileName.indexOf("-")); + final String name = fileName.substring(1 + fileName.indexOf('-')); final String message = String.format( Locale.ROOT, "found file [%s] from a failed attempt to remove the plugin [%s]; execute [elasticsearch-plugin remove %2$s]", diff --git a/server/src/main/java/org/elasticsearch/rest/RestUtils.java b/server/src/main/java/org/elasticsearch/rest/RestUtils.java index 5535ea65dfc41..c6d4f9ae38853 100644 --- a/server/src/main/java/org/elasticsearch/rest/RestUtils.java +++ b/server/src/main/java/org/elasticsearch/rest/RestUtils.java @@ -38,7 +38,7 @@ public static void decodeQueryString(String s, int fromIndex, Map queryParameters = new ArrayList<>(); Arrays.stream(Strings.tokenizeToStringArray(queryString, "&")).forEach(param -> { if (param.startsWith("x-")) { - final int equalPos = param.indexOf("="); + final int equalPos = param.indexOf('='); customQueryParameters.computeIfAbsent(param.substring(0, equalPos), k -> new ArrayList<>()) .add(param.substring(equalPos + 1)); } else { diff --git a/test/fixtures/testcontainer-utils/src/main/java/org/elasticsearch/test/fixtures/ResourceUtils.java b/test/fixtures/testcontainer-utils/src/main/java/org/elasticsearch/test/fixtures/ResourceUtils.java index 8fe64ea34d8d4..537a899e9d1ec 100644 --- a/test/fixtures/testcontainer-utils/src/main/java/org/elasticsearch/test/fixtures/ResourceUtils.java +++ b/test/fixtures/testcontainer-utils/src/main/java/org/elasticsearch/test/fixtures/ResourceUtils.java @@ -26,7 +26,7 @@ public static Path copyResourceToFile(Class clazz, Path targetFolder, String throw new RuntimeException("Failed to load " + resourcePath + " from classpath"); } InputStream inputStream = resourceUrl.openStream(); - File outputFile = new File(targetFolder.toFile(), resourcePath.substring(resourcePath.lastIndexOf("/"))); + File outputFile = new File(targetFolder.toFile(), resourcePath.substring(resourcePath.lastIndexOf('/'))); Files.copy(inputStream, outputFile.toPath(), StandardCopyOption.REPLACE_EXISTING); return outputFile.toPath(); } catch (IOException e) { diff --git a/test/framework/src/main/java/org/elasticsearch/test/fixture/AbstractHttpFixture.java b/test/framework/src/main/java/org/elasticsearch/test/fixture/AbstractHttpFixture.java index 8e7fae85e57f5..9a9088036ea6b 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/fixture/AbstractHttpFixture.java +++ b/test/framework/src/main/java/org/elasticsearch/test/fixture/AbstractHttpFixture.java @@ -222,7 +222,7 @@ public Request(final long id, final String method, final URI uri, final Map params = new HashMap<>(); if (uri.getQuery() != null && uri.getQuery().length() > 0) { for (String param : uri.getQuery().split("&")) { - int i = param.indexOf("="); + int i = param.indexOf('='); if (i > 0) { params.put(param.substring(0, i), param.substring(i + 1)); } else { diff --git a/test/logger-usage/src/main/java/org/elasticsearch/test/loggerusage/ESLoggerUsageChecker.java b/test/logger-usage/src/main/java/org/elasticsearch/test/loggerusage/ESLoggerUsageChecker.java index d7cde5676a27f..15a0f938da268 100644 --- a/test/logger-usage/src/main/java/org/elasticsearch/test/loggerusage/ESLoggerUsageChecker.java +++ b/test/logger-usage/src/main/java/org/elasticsearch/test/loggerusage/ESLoggerUsageChecker.java @@ -116,8 +116,8 @@ public record WrongLoggerUsage(String className, String methodName, String logMe */ public String getErrorLines() { String fullClassName = Type.getObjectType(className).getClassName(); - String simpleClassName = fullClassName.substring(fullClassName.lastIndexOf(".") + 1, fullClassName.length()); - int innerClassIndex = simpleClassName.indexOf("$"); + String simpleClassName = fullClassName.substring(fullClassName.lastIndexOf('.') + 1, fullClassName.length()); + int innerClassIndex = simpleClassName.indexOf('$'); if (innerClassIndex > 0) { simpleClassName = simpleClassName.substring(0, innerClassIndex); } diff --git a/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/section/TransformAndSetSection.java b/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/section/TransformAndSetSection.java index ff31cf8a57c34..a6626c1229319 100644 --- a/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/section/TransformAndSetSection.java +++ b/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/section/TransformAndSetSection.java @@ -78,7 +78,7 @@ public void execute(ClientYamlTestExecutionContext executionContext) throws IOEx String key = entry.getKey(); String value = entry.getValue(); if (value.startsWith("#base64EncodeCredentials(") && value.endsWith(")")) { - value = entry.getValue().substring("#base64EncodeCredentials(".length(), entry.getValue().lastIndexOf(")")); + value = entry.getValue().substring("#base64EncodeCredentials(".length(), entry.getValue().lastIndexOf(')')); String[] idAndPassword = value.split(","); if (idAndPassword.length == 2) { String credentials = executionContext.response(idAndPassword[0].trim()) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/TimeseriesLifecycleType.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/TimeseriesLifecycleType.java index e378cbb171a38..3203f85b2a7eb 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/TimeseriesLifecycleType.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/TimeseriesLifecycleType.java @@ -378,7 +378,7 @@ public static String validateMonotonicallyIncreasingPhaseTimings(Collection userOptional = SecurityField.USER_SETTING.get(settings); // TODO migrate to securesetting! userOptional.ifPresent(userSetting -> { - final int i = userSetting.indexOf(":"); + final int i = userSetting.indexOf(':'); if (i < 0 || i == userSetting.length() - 1) { throw new IllegalArgumentException( "invalid [" + SecurityField.USER_SETTING.getKey() + "] setting. must be in the form of \":\"" diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/jwt/JwtRealmSettings.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/jwt/JwtRealmSettings.java index e75ff1ac321bc..b05c81653963a 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/jwt/JwtRealmSettings.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/jwt/JwtRealmSettings.java @@ -545,7 +545,7 @@ private static void validateFallbackClaimSetting( } private static void verifyFallbackClaimName(String key, String fallbackClaimName) { - final String claimName = key.substring(key.lastIndexOf(".") + 1); + final String claimName = key.substring(key.lastIndexOf('.') + 1); verifyNonNullNotEmpty(key, fallbackClaimName, null); if (claimName.equals(fallbackClaimName)) { return; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/execution/Wid.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/execution/Wid.java index 39f59aa742690..f92df9be4648e 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/execution/Wid.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/execution/Wid.java @@ -37,7 +37,7 @@ public Wid(String watchId, ZonedDateTime executionTime) { public Wid(String value) { this.value = value; - int index = value.lastIndexOf("_"); + int index = value.lastIndexOf('_'); if (index <= 0) { throw illegalArgument("invalid watcher execution id [{}]", value); } diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestUtils.java b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestUtils.java index 4e0f0b8661631..438edecc76fbc 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestUtils.java +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestUtils.java @@ -160,7 +160,7 @@ public void close() { if (columns == null) { columns = new CsvColumn[entries.length]; for (int i = 0; i < entries.length; i++) { - int split = entries[i].indexOf(":"); + int split = entries[i].indexOf(':'); String name, typeName; if (split < 0) { @@ -245,7 +245,7 @@ static String[] multiValuesAwareCsvToStringArray(String csvLine, int lineNumber) int pos = 0; // current position in the csv String int commaPos; // current "," character position int previousCommaPos = 0; - while ((commaPos = csvLine.indexOf(",", pos)) != -1 || pos <= csvLine.length()) { + while ((commaPos = csvLine.indexOf(',', pos)) != -1 || pos <= csvLine.length()) { if (commaPos > 0 && csvLine.charAt(commaPos - 1) == ESCAPE_CHAR) {// skip the escaped comma pos = commaPos + 1;// moving on to the next character after comma continue; diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestsDataLoader.java b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestsDataLoader.java index 224f3d34980e6..302fda9b331e3 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestsDataLoader.java +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestsDataLoader.java @@ -261,7 +261,7 @@ private static void loadCsvData( if (columns == null) { columns = new String[entries.length]; for (int i = 0; i < entries.length; i++) { - int split = entries[i].indexOf(":"); + int split = entries[i].indexOf(':'); String name, typeName; if (split < 0) { diff --git a/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/execution/search/extractor/AbstractFieldHitExtractor.java b/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/execution/search/extractor/AbstractFieldHitExtractor.java index 0defe009c6f97..549c7ffab7f29 100644 --- a/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/execution/search/extractor/AbstractFieldHitExtractor.java +++ b/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/execution/search/extractor/AbstractFieldHitExtractor.java @@ -133,7 +133,7 @@ private Object extractNestedField(SearchHit hit) { List remainingPath = new ArrayList<>(); // first, search for the "root" DocumentField under which the remaining path of nested document values is while ((field = hit.field(tempHitname)) == null) { - int indexOfDot = tempHitname.lastIndexOf("."); + int indexOfDot = tempHitname.lastIndexOf('.'); if (indexOfDot < 0) {// there is no such field in the hit return null; } diff --git a/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/util/ReflectionUtils.java b/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/util/ReflectionUtils.java index 1447cb4dde143..6009e7514b413 100644 --- a/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/util/ReflectionUtils.java +++ b/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/util/ReflectionUtils.java @@ -48,9 +48,9 @@ public static Class detectSuperTypeForRuleLike(Class c) { // remove packaging from the name - strategy used for naming rules by default public static String ruleLikeNaming(Class c) { String className = c.getName(); - int parentPackage = className.lastIndexOf("."); + int parentPackage = className.lastIndexOf('.'); if (parentPackage > 0) { - int grandParentPackage = className.substring(0, parentPackage).lastIndexOf("."); + int grandParentPackage = className.substring(0, parentPackage).lastIndexOf('.'); return (grandParentPackage > 0 ? className.substring(grandParentPackage + 1) : className.substring(parentPackage)); } else { return className; diff --git a/x-pack/plugin/ql/test-fixtures/src/main/java/org/elasticsearch/xpack/ql/SpecReader.java b/x-pack/plugin/ql/test-fixtures/src/main/java/org/elasticsearch/xpack/ql/SpecReader.java index c6e21b64ce6ae..fef23f11b4a65 100644 --- a/x-pack/plugin/ql/test-fixtures/src/main/java/org/elasticsearch/xpack/ql/SpecReader.java +++ b/x-pack/plugin/ql/test-fixtures/src/main/java/org/elasticsearch/xpack/ql/SpecReader.java @@ -46,7 +46,7 @@ public static List readScriptSpec(List urls, Parser parser) throw public static List readURLSpec(URL source, Parser parser) throws Exception { String fileName = pathAndName(source.getFile()).v2(); - String groupName = fileName.substring(0, fileName.lastIndexOf(".")); + String groupName = fileName.substring(0, fileName.lastIndexOf('.')); Map testNames = new LinkedHashMap<>(); List testCases = new ArrayList<>(); diff --git a/x-pack/plugin/ql/test-fixtures/src/main/java/org/elasticsearch/xpack/ql/TestUtils.java b/x-pack/plugin/ql/test-fixtures/src/main/java/org/elasticsearch/xpack/ql/TestUtils.java index 7f5249fe4c2db..8ff7cac54bf5c 100644 --- a/x-pack/plugin/ql/test-fixtures/src/main/java/org/elasticsearch/xpack/ql/TestUtils.java +++ b/x-pack/plugin/ql/test-fixtures/src/main/java/org/elasticsearch/xpack/ql/TestUtils.java @@ -286,7 +286,7 @@ public static BufferedReader reader(URL resource) throws IOException { public static Tuple pathAndName(String string) { String folder = StringUtils.EMPTY; String file = string; - int lastIndexOf = string.lastIndexOf("/"); + int lastIndexOf = string.lastIndexOf('/'); if (lastIndexOf > 0) { folder = string.substring(0, lastIndexOf - 1); if (lastIndexOf + 1 < string.length()) { diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/file/FileUserRolesStore.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/file/FileUserRolesStore.java index b644ba174e2ef..ffc14ca96a768 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/file/FileUserRolesStore.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/file/FileUserRolesStore.java @@ -128,7 +128,7 @@ public static Map parseFile(Path path, @Nullable Logger logger if (line.startsWith("#")) { // comment continue; } - int i = line.indexOf(":"); + int i = line.indexOf(':'); if (i <= 0 || i == line.length() - 1) { logger.error("invalid entry in users_roles file [{}], line [{}]. skipping...", path.toAbsolutePath(), lineNr); continue; 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 495fdfe4cc0f2..12f51e0ec7912 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 @@ -261,7 +261,7 @@ ServerSet getServerSet() { ADAuthenticator getADAuthenticator(String username) { if (username.indexOf('\\') > 0) { return downLevelADAuthenticator; - } else if (username.indexOf("@") > 0) { + } else if (username.indexOf('@') > 0) { return upnADAuthenticator; } return defaultADAuthenticator; diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/profile/ProfileService.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/profile/ProfileService.java index c7965872f8185..349df95f16b57 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/profile/ProfileService.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/profile/ProfileService.java @@ -789,7 +789,7 @@ void getOrCreateProfileWithBackoff( void maybeIncrementDifferentiatorAndCreateNewProfile(Subject subject, ProfileDocument profileDocument, ActionListener listener) throws IOException { final String uid = profileDocument.uid(); - final int index = uid.lastIndexOf("_"); + final int index = uid.lastIndexOf('_'); if (index == -1) { listener.onFailure(new ElasticsearchException("profile uid [{}] does not contain any underscore character", uid)); return; diff --git a/x-pack/plugin/sql/sql-client/src/main/java/org/elasticsearch/xpack/sql/client/StringUtils.java b/x-pack/plugin/sql/sql-client/src/main/java/org/elasticsearch/xpack/sql/client/StringUtils.java index a5d45f2e5b525..4f5239e1ca8ec 100644 --- a/x-pack/plugin/sql/sql-client/src/main/java/org/elasticsearch/xpack/sql/client/StringUtils.java +++ b/x-pack/plugin/sql/sql-client/src/main/java/org/elasticsearch/xpack/sql/client/StringUtils.java @@ -121,7 +121,7 @@ public static String normalize(String path) { } String pathToUse = path.replace("\\", SLASH); - int prefixIndex = pathToUse.indexOf(":"); + int prefixIndex = pathToUse.indexOf(':'); String prefix = ""; if (prefixIndex != -1) { prefix = pathToUse.substring(0, prefixIndex + 1); diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/pivot/SchemaUtil.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/pivot/SchemaUtil.java index 2ddc9d6d4abda..48b156ce39fc2 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/pivot/SchemaUtil.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/pivot/SchemaUtil.java @@ -326,7 +326,7 @@ static void insertNestedObjectMappings(Map fieldMappings) { int pos; String objectKey = key; // lastIndexOf returns -1 on mismatch, but to disallow empty strings check for > 0 - while ((pos = objectKey.lastIndexOf(".")) > 0) { + while ((pos = objectKey.lastIndexOf('.')) > 0) { objectKey = objectKey.substring(0, pos); additionalMappings.putIfAbsent(objectKey, "object"); } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/EmailService.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/EmailService.java index 3afe2fa731860..d11cb7521976a 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/EmailService.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/notification/email/EmailService.java @@ -248,7 +248,7 @@ static Set getRecipientDomains(Email email) { ) .map(InternetAddress::getAddress) // Pull out only the domain of the email address, so foo@bar.com -> bar.com - .map(emailAddress -> emailAddress.substring(emailAddress.lastIndexOf("@") + 1)) + .map(emailAddress -> emailAddress.substring(emailAddress.lastIndexOf('@') + 1)) .collect(Collectors.toSet()); } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/DayTimes.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/DayTimes.java index 7586543d0869e..52e5a50ec7d01 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/DayTimes.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/support/DayTimes.java @@ -68,11 +68,11 @@ public static DayTimes parse(String time) throws ElasticsearchParseException { } int[] hour; int[] minute; - int i = time.indexOf(":"); + int i = time.indexOf(':'); if (i < 0) { throw new ElasticsearchParseException("could not parse time [{}]. time format must be in the form of hh:mm", time); } - if (i == time.length() - 1 || time.indexOf(":", i + 1) >= 0) { + if (i == time.length() - 1 || time.indexOf(':', i + 1) >= 0) { throw new ElasticsearchParseException("could not parse time [{}]. time format must be in the form of hh:mm", time); } String hrStr = time.substring(0, i);