From b370b1f03aae8a90d493fdae670822591e1a014a Mon Sep 17 00:00:00 2001 From: igor-suhorukov Date: Mon, 24 Dec 2018 07:59:43 +0300 Subject: [PATCH 1/2] Replace indexOf() with a call to the contains() See gh-15559 --- .../org/springframework/boot/loader/jar/JarURLConnection.java | 2 +- .../analyzer/NoUniqueBeanDefinitionFailureAnalyzer.java | 2 +- .../source/FilteredConfigurationPropertiesSourceTests.java | 2 +- .../FilteredIterableConfigurationPropertiesSourceTests.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java index db34f47c0e..c497346d20 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java @@ -130,7 +130,7 @@ final class JarURLConnection extends java.net.JarURLConnection { if (spec.endsWith(SEPARATOR)) { spec = spec.substring(0, spec.length() - SEPARATOR.length()); } - if (spec.indexOf(SEPARATOR) == -1) { + if (!spec.contains(SEPARATOR)) { return new URL(spec); } return new URL("jar:" + spec); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/NoUniqueBeanDefinitionFailureAnalyzer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/NoUniqueBeanDefinitionFailureAnalyzer.java index 7f16a51ff6..50808d2724 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/NoUniqueBeanDefinitionFailureAnalyzer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/NoUniqueBeanDefinitionFailureAnalyzer.java @@ -91,7 +91,7 @@ class NoUniqueBeanDefinitionFailureAnalyzer } private String[] extractBeanNames(NoUniqueBeanDefinitionException cause) { - if (cause.getMessage().indexOf("but found") > -1) { + if (cause.getMessage().contains("but found")) { return StringUtils.commaDelimitedListToStringArray(cause.getMessage() .substring(cause.getMessage().lastIndexOf(':') + 1).trim()); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/FilteredConfigurationPropertiesSourceTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/FilteredConfigurationPropertiesSourceTests.java index 8f3d2d4d4b..9bdb10b9c4 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/FilteredConfigurationPropertiesSourceTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/FilteredConfigurationPropertiesSourceTests.java @@ -114,7 +114,7 @@ public class FilteredConfigurationPropertiesSourceTests { } private boolean noBrackets(ConfigurationPropertyName name) { - return name.toString().indexOf("[") == -1; + return !name.toString().contains("["); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/FilteredIterableConfigurationPropertiesSourceTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/FilteredIterableConfigurationPropertiesSourceTests.java index 7e910f1bfe..fd54f09884 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/FilteredIterableConfigurationPropertiesSourceTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/FilteredIterableConfigurationPropertiesSourceTests.java @@ -57,7 +57,7 @@ public class FilteredIterableConfigurationPropertiesSourceTests } private boolean noBrackets(ConfigurationPropertyName name) { - return name.toString().indexOf("[") == -1; + return !name.toString().contains("["); } } From 805ff6000a1a7b796528ce22e9aac498dc9554cf Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 24 Dec 2018 09:52:29 +0100 Subject: [PATCH 2/2] Polish "Replace indexOf() with a call to the contains()" Closes gh-15559 --- .../FilteredIterableConfigurationPropertiesSourceTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/FilteredIterableConfigurationPropertiesSourceTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/FilteredIterableConfigurationPropertiesSourceTests.java index fd54f09884..7e40610936 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/FilteredIterableConfigurationPropertiesSourceTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/FilteredIterableConfigurationPropertiesSourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.