Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed Oct 25, 2022
1 parent b014039 commit 99edda7
Show file tree
Hide file tree
Showing 42 changed files with 125 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.file.RegularFile;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.PathSensitivity;
Expand Down Expand Up @@ -145,7 +144,7 @@ private void registerCheckMetadataTask(Project project) {
TaskProvider<CheckSpringConfigurationMetadata> checkConfigurationMetadata = project.getTasks()
.register(CHECK_SPRING_CONFIGURATION_METADATA_TASK_NAME, CheckSpringConfigurationMetadata.class);
checkConfigurationMetadata.configure((check) -> {
SourceSet mainSourceSet = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets()
SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets()
.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
Provider<RegularFile> metadataLocation = project.getTasks()
.named(mainSourceSet.getCompileJavaTaskName(), JavaCompile.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* @author Brian Clozel
*/
@SuppressWarnings("removal")
@Deprecated(since = "3.0.0", forRemoval = true)
class ServerRequestObservationConventionAdapter implements ServerRequestObservationConvention {

private final String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
*
* @author Brian Clozel
*/
@SuppressWarnings({ "deprecation", "removal" })
@SuppressWarnings("removal")
@Deprecated(since = "3.0.0", forRemoval = true)
class ServerRequestObservationConventionAdapter implements ServerRequestObservationConvention {

private final String observationName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ void rolesCanBeConfiguredViaTheEnvironment() {
}

@Test
@SuppressWarnings("unchecked")
void showValuesCanBeConfiguredViaTheEnvironment() {
this.contextRunner.withUserConfiguration(Config.class)
.withPropertyValues("management.endpoint.configprops.show-values: WHEN_AUTHORIZED")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ void rolesCanBeConfiguredViaTheEnvironment() {
}

@Test
@SuppressWarnings("unchecked")
void showValuesCanBeConfiguredViaTheEnvironment() {
this.contextRunner.withPropertyValues("management.endpoint.env.show-values: WHEN_AUTHORIZED")
.withPropertyValues("management.endpoints.web.exposure.include=env")
Expand All @@ -107,10 +106,8 @@ void showValuesCanBeConfiguredViaTheEnvironment() {
EnvironmentEndpointWebExtension webExtension = context
.getBean(EnvironmentEndpointWebExtension.class);
EnvironmentEndpoint endpoint = context.getBean(EnvironmentEndpoint.class);
Show showValuesWebExtension = (Show) ReflectionTestUtils.getField(webExtension, "showValues");
assertThat(showValuesWebExtension).isEqualTo(Show.WHEN_AUTHORIZED);
Show showValues = (Show) ReflectionTestUtils.getField(endpoint, "showValues");
assertThat(showValues).isEqualTo(Show.WHEN_AUTHORIZED);
assertThat(webExtension).extracting("showValues").isEqualTo(Show.WHEN_AUTHORIZED);
assertThat(endpoint).extracting("showValues").isEqualTo(Show.WHEN_AUTHORIZED);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
* @author Brian Clozel
*/
@ExtendWith(OutputCaptureExtension.class)
@SuppressWarnings({ "deprecation", "removal" })
@SuppressWarnings("removal")
class RestTemplateObservationConfigurationTests {

private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
* @author Stephane Nicoll
*/
@ExtendWith(OutputCaptureExtension.class)
@SuppressWarnings({ "deprecation", "removal" })
@SuppressWarnings("removal")
class WebClientObservationConfigurationTests {

private final ApplicationContextRunner contextRunner = new ApplicationContextRunner().with(MetricsRun.simple())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* @author Brian Clozel
*/
@SuppressWarnings("removal")
@Deprecated(since = "3.0.0", forRemoval = true)
class ServerRequestObservationConventionAdapterTests {

private static final String TEST_METRIC_NAME = "test.metric.name";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ void shouldUseConventionAdapterWhenCustomTagsContributor() {
});
}

@Deprecated(since = "3.0.0", forRemoval = true)
@Configuration(proxyBeanMethods = false)
static class CustomTagsProviderConfiguration {

Expand All @@ -96,6 +97,7 @@ WebFluxTagsContributor tagsContributor() {

}

@Deprecated(since = "3.0.0", forRemoval = true)
static class CustomTagsContributor implements WebFluxTagsContributor {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
* @author Brian Clozel
*/
@SuppressWarnings("removal")
@Deprecated(since = "3.0.0", forRemoval = true)
class ServerRequestObservationConventionAdapterTests {

private static final String TEST_METRIC_NAME = "test.metric.name";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ WebMvcTagsContributor tagContributorTwo() {

}

@Deprecated(since = "3.0.0", forRemoval = true)
private static final class TestWebMvcTagsProvider implements WebMvcTagsProvider {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,14 @@ void rolesCanBeConfiguredViaTheEnvironment() {
}

@Test
@SuppressWarnings("unchecked")
void showValuesCanBeConfiguredViaTheEnvironment() {
this.contextRunner.withBean(Scheduler.class, () -> mock(Scheduler.class))
.withPropertyValues("management.endpoint.quartz.show-values: WHEN_AUTHORIZED")
.withPropertyValues("management.endpoints.web.exposure.include=quartz")
.withSystemProperties("dbPassword=123456", "apiKey=123456").run((context) -> {
assertThat(context).hasSingleBean(QuartzEndpointWebExtension.class);
QuartzEndpointWebExtension webExtension = context.getBean(QuartzEndpointWebExtension.class);
Show showValuesWebExtension = (Show) ReflectionTestUtils.getField(webExtension, "showValues");
assertThat(showValuesWebExtension).isEqualTo(Show.WHEN_AUTHORIZED);
assertThat(context.getBean(QuartzEndpointWebExtension.class)).extracting("showValues")
.isEqualTo(Show.WHEN_AUTHORIZED);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,21 +239,16 @@ private Response convertToJaxRsResponse(Object response, String httpMethod) {
Status status = isGet ? Status.NOT_FOUND : Status.NO_CONTENT;
return Response.status(status).build();
}
try {
if (!(response instanceof WebEndpointResponse)) {
return Response.status(Status.OK).entity(convertIfNecessary(response)).build();
}
WebEndpointResponse<?> webEndpointResponse = (WebEndpointResponse<?>) response;
return Response.status(webEndpointResponse.getStatus())
.header("Content-Type", webEndpointResponse.getContentType())
.entity(convertIfNecessary(webEndpointResponse.getBody())).build();
}
catch (IOException ex) {
return Response.status(Status.INTERNAL_SERVER_ERROR).build();
if (!(response instanceof WebEndpointResponse)) {
return Response.status(Status.OK).entity(convertIfNecessary(response)).build();
}
WebEndpointResponse<?> webEndpointResponse = (WebEndpointResponse<?>) response;
return Response.status(webEndpointResponse.getStatus())
.header("Content-Type", webEndpointResponse.getContentType())
.entity(convertIfNecessary(webEndpointResponse.getBody())).build();
}

private Object convertIfNecessary(Object body) throws IOException {
private Object convertIfNecessary(Object body) {
for (Function<Object, Object> converter : BODY_CONVERTERS) {
body = converter.apply(body);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ public AbstractWebMvcEndpointHandlerMapping(EndpointMapping endpointMapping,
}

@Override
@SuppressWarnings("deprecation")
public void afterPropertiesSet() {
this.builderConfig = new RequestMappingInfo.BuilderConfiguration();
this.builderConfig.setPatternParser(getPatternParser());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public class ControllerEndpointHandlerMapping extends RequestMappingHandlerMappi
* @param endpoints the web endpoints
* @param corsConfiguration the CORS configuration for the endpoints or {@code null}
*/
@SuppressWarnings("deprecation")
public ControllerEndpointHandlerMapping(EndpointMapping endpointMapping,
Collection<ExposableControllerEndpoint> endpoints, CorsConfiguration corsConfiguration) {
Assert.notNull(endpointMapping, "EndpointMapping must not be null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* {@link org.springframework.http.client.observation.DefaultClientRequestObservationConvention}
*/
@Deprecated(since = "3.0.0", forRemoval = true)
@SuppressWarnings({ "deprecation", "removal" })
@SuppressWarnings("removal")
public class DefaultRestTemplateExchangeTagsProvider implements RestTemplateExchangeTagsProvider {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* {@link org.springframework.web.reactive.function.client.ClientRequestObservationConvention}
*/
@Deprecated(since = "3.0.0", forRemoval = true)
@SuppressWarnings({ "deprecation", "removal" })
@SuppressWarnings("removal")
public class DefaultWebClientExchangeTagsProvider implements WebClientExchangeTagsProvider {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
* @author Andy Wilkinson
*/
@SuppressWarnings("removal")
@Deprecated(since = "3.0.0", forRemoval = true)
class DefaultWebMvcTagsProviderTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2022 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.
Expand Down Expand Up @@ -35,6 +35,7 @@
* @author Michael McFadyen
*/
@SuppressWarnings("removal")
@Deprecated(since = "3.0.0", forRemoval = true)
class WebMvcTagsTests {

private final MockHttpServletRequest request = new MockHttpServletRequest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
*
* @author Brian Clozel
*/
@SuppressWarnings("deprecation")
class ObservationWebClientCustomizerTests {

private static final String TEST_METRIC_NAME = "http.test.metric.name";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* @author Andy Wilkinson
*/
@SuppressWarnings("removal")
@Deprecated(since = "3.0.0", forRemoval = true)
class DefaultWebFluxTagsProviderTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
* @author Stephane Nicoll
*/
@SuppressWarnings("removal")
@Deprecated(since = "3.0.0", forRemoval = true)
class WebFluxTagsTests {

private MockServerWebExchange exchange;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ private GenericHttpMessageConverter<Object> asGenericHttpMessageConverter(HttpMe
}

@Bean
@SuppressWarnings("deprecation")
public HandlerMapping graphQlWebSocketMapping(GraphQlWebSocketHandler handler, GraphQlProperties properties) {
String path = properties.getWebsocket().getPath();
logger.info(LogMessage.format("GraphQL endpoint WebSocket %s", path));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@ void autoConfigurationWhenIntrospectionUriAvailableShouldBeConditionalOnClass()
.run((context) -> assertThat(context).doesNotHaveBean(OpaqueTokenIntrospector.class));
}

@SuppressWarnings("unchecked")
@Test
void autoConfigurationShouldConfigureResourceServerUsingJwkSetUriAndIssuerUri() throws Exception {
this.server = new MockWebServer();
Expand All @@ -445,7 +444,6 @@ void autoConfigurationShouldConfigureResourceServerUsingJwkSetUriAndIssuerUri()
});
}

@SuppressWarnings("unchecked")
@Test
void autoConfigurationShouldNotConfigureIssuerUriAndAudienceJwtValidatorIfPropertyNotConfigured() throws Exception {
this.server = new MockWebServer();
Expand Down Expand Up @@ -523,7 +521,6 @@ private void validate(String issuerUri, JwtDecoder jwtDecoder) throws MalformedU
validateDelegates(issuerUri, delegates);
}

@SuppressWarnings("unchecked")
private void validateDelegates(String issuerUri, Collection<OAuth2TokenValidator<Jwt>> delegates) {
assertThat(delegates).hasAtLeastOneElementOfType(JwtClaimValidator.class);
OAuth2TokenValidator<Jwt> delegatingValidator = delegates.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ LiveReloadServerEventListener liveReloadServerEventListener(OptionalLiveReloadSe
@ConditionalOnProperty(prefix = "spring.devtools.restart", name = "enabled", matchIfMissing = true)
static class RestartConfiguration {

private static final Log restarterLogger = LogFactory.getLog(Restarter.class);

private final DevToolsProperties properties;

RestartConfiguration(DevToolsProperties properties) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void orderShouldBeSameAsDependencyInjectionTestExecutionListener() {
}

@Test
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
void prepareFailingTestInstanceShouldPrintReport(CapturedOutput output) throws Exception {
TestContext testContext = mock(TestContext.class);
given(testContext.getTestClass()).willReturn((Class) Config.class);
Expand All @@ -73,7 +73,7 @@ void prepareFailingTestInstanceShouldPrintReport(CapturedOutput output) throws E
}

@Test
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
void originalFailureIsThrownWhenReportGenerationFails() {
TestContext testContext = mock(TestContext.class);
given(testContext.getTestClass()).willReturn((Class) Config.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.springframework.boot.test.autoconfigure.web.client;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ConstructorBinding;
import org.springframework.boot.context.properties.bind.ConstructorBinding;
import org.springframework.boot.context.properties.bind.DefaultValue;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
class AutoConfigureAnnotationProcessorTests {

@Test
void annotatedClass() throws Exception {
void annotatedClass() {
compile(TestClassConfiguration.class, (properties) -> {
assertThat(properties).hasSize(7);
assertThat(properties).containsEntry(
Expand Down Expand Up @@ -108,7 +108,7 @@ void annotatedClassWithOrder() {
}

@Test
void annotatedClassWithAutoConfiguration() throws Exception {
void annotatedClassWithAutoConfiguration() {
compile(TestAutoConfigurationConfiguration.class, (properties) -> {
assertThat(properties).containsEntry(
"org.springframework.boot.autoconfigureprocessor.TestAutoConfigurationConfiguration", "");
Expand All @@ -122,7 +122,7 @@ void annotatedClassWithAutoConfiguration() throws Exception {
}

@Test
void annotatedClassWithAutoConfigurationMerged() throws Exception {
void annotatedClassWithAutoConfigurationMerged() {
compile(TestMergedAutoConfigurationConfiguration.class, (properties) -> {
assertThat(properties).containsEntry(
"org.springframework.boot.autoconfigureprocessor.TestMergedAutoConfigurationConfiguration", "");
Expand All @@ -136,7 +136,7 @@ void annotatedClassWithAutoConfigurationMerged() throws Exception {
}

@Test // gh-19370
void propertiesAreFullRepeatable() throws Exception {
void propertiesAreFullRepeatable() {
process(TestOrderedClassConfiguration.class, (firstFile) -> {
String first = getFileContents(firstFile);
process(TestOrderedClassConfiguration.class, (secondFile) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public ConfigurationMetadata readAdditionalMetadata() throws IOException {
return readMetadata(getAdditionalMetadataStream());
}

private ConfigurationMetadata readMetadata(InputStream in) throws IOException {
private ConfigurationMetadata readMetadata(InputStream in) {
try (in) {
return new JsonMarshaller().read(in);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package org.springframework.boot.configurationprocessor;

import java.io.IOException;

import org.junit.jupiter.api.Test;

import org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata;
Expand Down Expand Up @@ -414,7 +412,7 @@ void recursivePropertiesDoNotCauseAStackOverflow() {
}

@Test
void recordProperties() throws IOException {
void recordProperties() {
String source = """
@org.springframework.boot.configurationsample.ConfigurationProperties("implicit")
public record ExampleRecord(String someString, Integer someInteger) {
Expand All @@ -426,7 +424,7 @@ public record ExampleRecord(String someString, Integer someInteger) {
}

@Test
void recordPropertiesWithDefaultValues() throws IOException {
void recordPropertiesWithDefaultValues() {
String source = """
@org.springframework.boot.configurationsample.ConfigurationProperties("record.defaults")
public record ExampleRecord(
Expand All @@ -442,7 +440,7 @@ public record ExampleRecord(
}

@Test
void multiConstructorRecordProperties() throws IOException {
void multiConstructorRecordProperties() {
String source = """
@org.springframework.boot.configurationsample.ConfigurationProperties("multi")
public record ExampleRecord(String someString, Integer someInteger) {
Expand Down
Loading

0 comments on commit 99edda7

Please sign in to comment.