From 30262e3bc1a58de1f79c6a91715e44b44dc47ac1 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Tue, 5 Sep 2017 23:08:39 +0900 Subject: [PATCH] Polish Closes gh-10168 --- .../metrics/statsd/StatsdMetricWriter.java | 4 ++-- ...ositeReactiveHealthIndicatorFactoryTests.java | 8 ++++---- .../boot/autoconfigure/AutoConfigurations.java | 2 +- .../compiler/grape/RepositoryConfiguration.java | 4 ++-- .../boot/test/util/TestPropertyValues.java | 16 ++++++++-------- .../boot/test/util/TestPropertyValuesTests.java | 1 - .../boot/context/annotation/Configurations.java | 8 ++++---- ...AbstractWebEndpointServletHandlerMapping.java | 2 +- .../GenericReactiveWebApplicationContext.java | 2 +- .../context/annotation/ConfigurationsTests.java | 1 - 10 files changed, 23 insertions(+), 25 deletions(-) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/statsd/StatsdMetricWriter.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/statsd/StatsdMetricWriter.java index 8f0dbf4a5c..d4cc7703bd 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/statsd/StatsdMetricWriter.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/statsd/StatsdMetricWriter.java @@ -121,8 +121,8 @@ public class StatsdMetricWriter implements MetricWriter, Closeable { /** * Sanitize the metric name if necessary. - * @param name The metric name - * @return The sanitized metric name + * @param name the metric name + * @return the sanitized metric name */ private String sanitizeMetricName(String name) { return name.replace(":", "-"); diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicatorFactoryTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicatorFactoryTests.java index 7bc4c08ed0..1df69483ee 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicatorFactoryTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicatorFactoryTests.java @@ -74,19 +74,19 @@ public class CompositeReactiveHealthIndicatorFactoryTests { @Test public void reactiveHealthIndicatorTakesPrecedence() { - ReactiveHealthIndicator reactivehealthIndicator = mock( + ReactiveHealthIndicator reactiveHealthIndicator = mock( ReactiveHealthIndicator.class); - given(reactivehealthIndicator.health()).willReturn(Mono.just(UP)); + given(reactiveHealthIndicator.health()).willReturn(Mono.just(UP)); HealthIndicator regularHealthIndicator = mock(HealthIndicator.class); given(regularHealthIndicator.health()).willReturn(UP); ReactiveHealthIndicator healthIndicator = createHealthIndicator( - Collections.singletonMap("test", reactivehealthIndicator), + Collections.singletonMap("test", reactiveHealthIndicator), Collections.singletonMap("test", regularHealthIndicator)); StepVerifier.create(healthIndicator.health()).consumeNextWith((h) -> { assertThat(h.getStatus()).isEqualTo(Status.UP); assertThat(h.getDetails()).containsOnlyKeys("test"); }).verifyComplete(); - verify(reactivehealthIndicator, times(1)).health(); + verify(reactiveHealthIndicator, times(1)).health(); verify(regularHealthIndicator, times(0)).health(); } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurations.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurations.java index a4239abc53..b611cf3b3d 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurations.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurations.java @@ -36,7 +36,7 @@ import org.springframework.util.ClassUtils; */ public class AutoConfigurations extends Configurations implements Ordered { - private static AutoConfigurationSorter SORTER = new AutoConfigurationSorter( + private static final AutoConfigurationSorter SORTER = new AutoConfigurationSorter( new SimpleMetadataReaderFactory(), null); private static final Ordered ORDER = new AutoConfigurationImportSelector(); diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/RepositoryConfiguration.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/RepositoryConfiguration.java index 8c1ec3393f..b950b81059 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/RepositoryConfiguration.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/RepositoryConfiguration.java @@ -35,8 +35,8 @@ public final class RepositoryConfiguration { /** * Creates a new {@code RepositoryConfiguration} instance. - * @param name The name of the repository - * @param uri The uri of the repository + * @param name the name of the repository + * @param uri the uri of the repository * @param snapshotsEnabled {@code true} if the repository should enable access to * snapshots, {@code false} otherwise */ diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java b/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java index 6a9372c658..2921de95e1 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java @@ -60,7 +60,7 @@ public final class TestPropertyValues { /** * Builder method to add more properties. - * @param pairs The property pairs to add + * @param pairs the property pairs to add * @return a new {@link TestPropertyValues} instance */ public TestPropertyValues and(String... pairs) { @@ -119,7 +119,7 @@ public final class TestPropertyValues { /** * Add the properties to the {@link System#getProperties() system properties} for the - * duration of the {@code call}, restoring previous values then the call completes. + * duration of the {@code call}, restoring previous values when the call completes. * @param the result type * @param call the call to make * @return the result of the call @@ -158,7 +158,7 @@ public final class TestPropertyValues { * Return a new {@link TestPropertyValues} with the underlying map populated with the * given property pairs. Name-value pairs can be specified with colon (":") or equals * ("=") separators. - * @param pairs The key value pairs for properties that need to be added to the + * @param pairs the name-value pairs for properties that need to be added to the * environment * @return the new instance */ @@ -170,7 +170,7 @@ public final class TestPropertyValues { * Return a new {@link TestPropertyValues} with the underlying map populated with the * given property pairs. Name-value pairs can be specified with colon (":") or equals * ("=") separators. - * @param pairs The key value pairs for properties that need to be added to the + * @param pairs the name-value pairs for properties that need to be added to the * environment * @return the new instance */ @@ -185,7 +185,7 @@ public final class TestPropertyValues { * Return a new {@link TestPropertyValues} with the underlying map populated with the * given property pairs. Name-value pairs can be specified with colon (":") or equals * ("=") separators. - * @param pairs The key value pairs for properties that need to be added to the + * @param pairs the name-value pairs for properties that need to be added to the * environment * @return the new instance */ @@ -197,7 +197,7 @@ public final class TestPropertyValues { } /** - * Return a new empty {@link TestPropertyValues} instance. + * Return an empty {@link TestPropertyValues} instance. * @return an empty instance */ public static TestPropertyValues empty() { @@ -252,9 +252,9 @@ public final class TestPropertyValues { public static Pair parse(String pair) { int index = getSeparatorIndex(pair); - String key = (index > 0 ? pair.substring(0, index) : pair); + String name = (index > 0 ? pair.substring(0, index) : pair); String value = (index > 0 ? pair.substring(index + 1) : ""); - return of(key.trim(), value.trim()); + return of(name.trim(), value.trim()); } private static int getSeparatorIndex(String pair) { diff --git a/spring-boot-test/src/test/java/org/springframework/boot/test/util/TestPropertyValuesTests.java b/spring-boot-test/src/test/java/org/springframework/boot/test/util/TestPropertyValuesTests.java index 3d97c5ec86..fcdf54c02c 100644 --- a/spring-boot-test/src/test/java/org/springframework/boot/test/util/TestPropertyValuesTests.java +++ b/spring-boot-test/src/test/java/org/springframework/boot/test/util/TestPropertyValuesTests.java @@ -132,7 +132,6 @@ public class TestPropertyValuesTests { return null; }); assertThat(System.getProperty("foo")).isEqualTo("bar1"); - assertThat(System.getProperties()).doesNotContainKey("baz"); } finally { System.clearProperty("foo"); diff --git a/spring-boot/src/main/java/org/springframework/boot/context/annotation/Configurations.java b/spring-boot/src/main/java/org/springframework/boot/context/annotation/Configurations.java index 07a8963217..b83c442e13 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/annotation/Configurations.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/annotation/Configurations.java @@ -36,9 +36,9 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.util.Assert; /** - * A set of {@link Configuration @Configuration} classes that can be registered + * A set of {@link Configuration @Configuration} classes that can be registered in * {@link ApplicationContext}. Classes can be returned from one or more - * {@link Configurations} instance by using {@link #getClasses(Configurations[])}. The + * {@link Configurations} instances by using {@link #getClasses(Configurations[])}. The * resulting array follows the ordering rules usually applied by the * {@link ApplicationContext} and/or custom {@link ImportSelector} implementations. *

@@ -57,7 +57,7 @@ public abstract class Configurations { private static final Comparator COMPARATOR = OrderComparator.INSTANCE .thenComparing((other) -> other.getClass().getName()); - private Set> classes; + private final Set> classes; protected Configurations(Collection> classes) { Assert.notNull(classes, "Classes must not be null"); @@ -92,7 +92,7 @@ public abstract class Configurations { /** * Merge configurations. - * @param mergedClasses the merge classes + * @param mergedClasses the merged classes * @return a new configurations instance (must be of the same type as this instance) */ protected abstract Configurations merge(Set> mergedClasses); diff --git a/spring-boot/src/main/java/org/springframework/boot/endpoint/web/mvc/AbstractWebEndpointServletHandlerMapping.java b/spring-boot/src/main/java/org/springframework/boot/endpoint/web/mvc/AbstractWebEndpointServletHandlerMapping.java index f07430e459..b04bf74f83 100644 --- a/spring-boot/src/main/java/org/springframework/boot/endpoint/web/mvc/AbstractWebEndpointServletHandlerMapping.java +++ b/spring-boot/src/main/java/org/springframework/boot/endpoint/web/mvc/AbstractWebEndpointServletHandlerMapping.java @@ -72,7 +72,7 @@ public abstract class AbstractWebEndpointServletHandlerMapping * operations of the given {@code webEndpoints}. * @param endpointPath the path beneath which all endpoints should be mapped * @param webEndpoints the web endpoints - * @param corsConfiguration the CORS configuraton for the endpoints + * @param corsConfiguration the CORS configuration for the endpoints */ public AbstractWebEndpointServletHandlerMapping(String endpointPath, Collection> webEndpoints, diff --git a/spring-boot/src/main/java/org/springframework/boot/web/reactive/context/GenericReactiveWebApplicationContext.java b/spring-boot/src/main/java/org/springframework/boot/web/reactive/context/GenericReactiveWebApplicationContext.java index a3b73c13e2..3837ba2f8e 100644 --- a/spring-boot/src/main/java/org/springframework/boot/web/reactive/context/GenericReactiveWebApplicationContext.java +++ b/spring-boot/src/main/java/org/springframework/boot/web/reactive/context/GenericReactiveWebApplicationContext.java @@ -68,7 +68,7 @@ public class GenericReactiveWebApplicationContext * {@link org.springframework.web.context.support.ServletContextResource} in a * reactive web application. *

- * {@link #exists()} always returns null in order to avoid exposing the whole + * {@link #exists()} always returns {@code false} in order to avoid exposing the whole * classpath in a non-servlet environment. */ class FilteredReactiveWebContextResource extends AbstractResource { diff --git a/spring-boot/src/test/java/org/springframework/boot/context/annotation/ConfigurationsTests.java b/spring-boot/src/test/java/org/springframework/boot/context/annotation/ConfigurationsTests.java index 9ec6b7b9fa..bc4d21d132 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/annotation/ConfigurationsTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/annotation/ConfigurationsTests.java @@ -68,7 +68,6 @@ public class ConfigurationsTests { Arrays.asList(String.class, Integer.class)); Configurations c4 = new TestConfigurations(Arrays.asList(Long.class, Byte.class)); Class[] classes = Configurations.getClasses(c1, c2, c3, c4); - System.out.println(Arrays.asList(classes)); assertThat(classes).containsExactly(Short.class, Long.class, Byte.class, InputStream.class, Integer.class, OutputStream.class, String.class); }