Skip to content

Commit 9127c48

Browse files
committed
Fixup warnings
1 parent a869d25 commit 9127c48

File tree

9 files changed

+65
-64
lines changed

9 files changed

+65
-64
lines changed

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/MetricFilterAutoConfigurationTests.java

Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,25 @@ public void defaultMetricFilterAutoConfigurationProperties() {
9393
public void recordsHttpInteractions() throws Exception {
9494
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
9595
Config.class, MetricFilterAutoConfiguration.class);
96-
Filter filter = context.getBean(Filter.class);
97-
final MockHttpServletRequest request = new MockHttpServletRequest("GET",
98-
"/test/path");
99-
final MockHttpServletResponse response = new MockHttpServletResponse();
100-
FilterChain chain = mock(FilterChain.class);
101-
willAnswer((invocation) -> {
102-
response.setStatus(200);
103-
return null;
104-
}).given(chain).doFilter(request, response);
105-
filter.doFilter(request, response, chain);
106-
verify(context.getBean(CounterService.class)).increment("status.200.test.path");
107-
verify(context.getBean(GaugeService.class)).submit(eq("response.test.path"),
108-
anyDouble());
109-
context.close();
96+
try {
97+
Filter filter = context.getBean(Filter.class);
98+
MockHttpServletRequest request = new MockHttpServletRequest("GET",
99+
"/test/path");
100+
MockHttpServletResponse response = new MockHttpServletResponse();
101+
FilterChain chain = mock(FilterChain.class);
102+
willAnswer((invocation) -> {
103+
response.setStatus(200);
104+
return null;
105+
}).given(chain).doFilter(request, response);
106+
filter.doFilter(request, response, chain);
107+
verify(context.getBean(CounterService.class))
108+
.increment("status.200.test.path");
109+
verify(context.getBean(GaugeService.class)).submit(eq("response.test.path"),
110+
anyDouble());
111+
}
112+
finally {
113+
context.close();
114+
}
110115
}
111116

112117
@Test
@@ -355,9 +360,8 @@ public void additionallyRecordsMetricsWithHttpMethodNameIfConfigured()
355360
.applyTo(context);
356361
context.refresh();
357362
Filter filter = context.getBean(Filter.class);
358-
final MockHttpServletRequest request = new MockHttpServletRequest("PUT",
359-
"/test/path");
360-
final MockHttpServletResponse response = new MockHttpServletResponse();
363+
MockHttpServletRequest request = new MockHttpServletRequest("PUT", "/test/path");
364+
MockHttpServletResponse response = new MockHttpServletResponse();
361365
FilterChain chain = mock(FilterChain.class);
362366
willAnswer((invocation) -> {
363367
response.setStatus(200);
@@ -383,9 +387,8 @@ public void doesNotRecordRolledUpMetricsIfConfigured() throws Exception {
383387
"endpoints.metrics.filter.counter-submissions=").applyTo(context);
384388
context.refresh();
385389
Filter filter = context.getBean(Filter.class);
386-
final MockHttpServletRequest request = new MockHttpServletRequest("PUT",
387-
"/test/path");
388-
final MockHttpServletResponse response = new MockHttpServletResponse();
390+
MockHttpServletRequest request = new MockHttpServletRequest("PUT", "/test/path");
391+
MockHttpServletResponse response = new MockHttpServletResponse();
389392
FilterChain chain = mock(FilterChain.class);
390393
willAnswer((invocation) -> {
391394
response.setStatus(200);
@@ -402,28 +405,32 @@ public void doesNotRecordRolledUpMetricsIfConfigured() throws Exception {
402405
public void whenExceptionIsThrownResponseStatusIsUsedWhenResponseHasBeenCommitted()
403406
throws Exception {
404407
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
405-
context.register(Config.class, MetricFilterAutoConfiguration.class);
406-
context.refresh();
407-
Filter filter = context.getBean(Filter.class);
408-
final MockHttpServletRequest request = new MockHttpServletRequest("GET",
409-
"/test/path");
410-
final MockHttpServletResponse response = new MockHttpServletResponse();
411-
FilterChain chain = mock(FilterChain.class);
412-
willAnswer((invocation) -> {
413-
response.setStatus(200);
414-
response.setCommitted(true);
415-
throw new IOException();
416-
}).given(chain).doFilter(request, response);
417408
try {
418-
filter.doFilter(request, response, chain);
419-
fail();
409+
context.register(Config.class, MetricFilterAutoConfiguration.class);
410+
context.refresh();
411+
Filter filter = context.getBean(Filter.class);
412+
MockHttpServletRequest request = new MockHttpServletRequest("GET",
413+
"/test/path");
414+
MockHttpServletResponse response = new MockHttpServletResponse();
415+
FilterChain chain = mock(FilterChain.class);
416+
willAnswer((invocation) -> {
417+
response.setStatus(200);
418+
response.setCommitted(true);
419+
throw new IOException();
420+
}).given(chain).doFilter(request, response);
421+
try {
422+
filter.doFilter(request, response, chain);
423+
fail();
424+
}
425+
catch (IOException ex) {
426+
// Continue
427+
}
428+
verify(context.getBean(CounterService.class))
429+
.increment(eq("status.200.test.path"));
420430
}
421-
catch (IOException ex) {
422-
// Continue
431+
finally {
432+
context.close();
423433
}
424-
verify(context.getBean(CounterService.class))
425-
.increment(eq("status.200.test.path"));
426-
context.close();
427434
}
428435

429436
@Configuration

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/PathBasedTemplateAvailabilityProvider.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import java.util.List;
2020

21-
import org.springframework.boot.autoconfigure.template.PathBasedTemplateAvailabilityProvider.TemplateAvailabilityProperties;
2221
import org.springframework.boot.context.properties.bind.Binder;
2322
import org.springframework.core.env.Environment;
2423
import org.springframework.core.io.ResourceLoader;
@@ -33,19 +32,21 @@
3332
* @author Madhura Bhave
3433
* @since 1.4.6
3534
*/
36-
public abstract class PathBasedTemplateAvailabilityProvider<T extends TemplateAvailabilityProperties>
35+
public abstract class PathBasedTemplateAvailabilityProvider
3736
implements TemplateAvailabilityProvider {
3837

3938
private final String className;
4039

41-
private final Class<T> propertiesClass;
40+
private final Class<TemplateAvailabilityProperties> propertiesClass;
4241

4342
private final String propertyPrefix;
4443

44+
@SuppressWarnings("unchecked")
4545
public PathBasedTemplateAvailabilityProvider(String className,
46-
Class<T> propertiesClass, String propertyPrefix) {
46+
Class<? extends TemplateAvailabilityProperties> propertiesClass,
47+
String propertyPrefix) {
4748
this.className = className;
48-
this.propertiesClass = propertiesClass;
49+
this.propertiesClass = (Class<TemplateAvailabilityProperties>) propertiesClass;
4950
this.propertyPrefix = propertyPrefix;
5051
}
5152

@@ -54,9 +55,10 @@ public boolean isTemplateAvailable(String view, Environment environment,
5455
ClassLoader classLoader, ResourceLoader resourceLoader) {
5556
if (ClassUtils.isPresent(this.className, classLoader)) {
5657
Binder binder = Binder.get(environment);
57-
TemplateAvailabilityProperties properties = binder
58+
TemplateAvailabilityProperties properties1 = binder
5859
.bind(this.propertyPrefix, this.propertiesClass)
5960
.orElseCreate(this.propertiesClass);
61+
TemplateAvailabilityProperties properties = properties1;
6062
return isTemplateAvailable(view, resourceLoader, properties);
6163
}
6264
return false;

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfigurationTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ public void jwkTokenStoreShouldBeConditionalOnMissingBean() throws Exception {
261261
.of("security.oauth2.resource.jwk.key-set-uri=http://my-auth-server/token_keys")
262262
.applyTo(this.environment);
263263
this.context = new SpringApplicationBuilder(JwkTokenStoreConfiguration.class,
264-
ResourceConfiguration.class).environment(this.environment).web(false)
265-
.run();
264+
ResourceConfiguration.class).environment(this.environment)
265+
.web(WebApplicationType.NONE).run();
266266
assertThat(this.context.getBeansOfType(JwkTokenStore.class)).hasSize(1);
267267
}
268268

@@ -271,8 +271,8 @@ public void jwtTokenStoreShouldBeConditionalOnMissingBean() throws Exception {
271271
TestPropertyValues.of("security.oauth2.resource.jwt.keyValue=" + PUBLIC_KEY)
272272
.applyTo(this.environment);
273273
this.context = new SpringApplicationBuilder(JwtTokenStoreConfiguration.class,
274-
ResourceConfiguration.class).environment(this.environment).web(false)
275-
.run();
274+
ResourceConfiguration.class).environment(this.environment)
275+
.web(WebApplicationType.NONE).run();
276276
assertThat(this.context.getBeansOfType(JwtTokenStore.class)).hasSize(1);
277277
}
278278

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/UserInfoTokenServicesTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ public class UserInfoTokenServicesTests {
5959

6060
private Map<String, Object> map = new LinkedHashMap<>();
6161

62-
@SuppressWarnings("rawtypes")
6362
@Before
6463
public void init() {
6564
this.resource.setClientId("foo");

spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/RemoteDevToolsAutoConfigurationTests.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,6 @@ public void devToolsHealthWithCustomServerContextPathReturns200() throws Excepti
175175
assertThat(this.response.getStatus()).isEqualTo(200);
176176
}
177177

178-
private void assertTunnelInvoked(boolean value) {
179-
assertThat(this.context.getBean(MockHttpTunnelServer.class).invoked)
180-
.isEqualTo(value);
181-
}
182-
183178
private void assertRestartInvoked(boolean value) {
184179
assertThat(this.context.getBean(MockHttpRestartServer.class).invoked)
185180
.isEqualTo(value);
@@ -211,16 +206,13 @@ public HttpRestartServer remoteRestartHttpRestartServer() {
211206
*/
212207
static class MockHttpTunnelServer extends HttpTunnelServer {
213208

214-
private boolean invoked;
215-
216209
MockHttpTunnelServer(TargetServerConnection serverConnection) {
217210
super(serverConnection);
218211
}
219212

220213
@Override
221214
public void handle(ServerHttpRequest request, ServerHttpResponse response)
222215
throws IOException {
223-
this.invoked = true;
224216
}
225217

226218
}

spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/SpringBootDependencyInjectionTestExecutionListenerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void originalFailureIsThrownWhenReportGenerationFails() throws Exception
8585
IllegalStateException originalFailure = new IllegalStateException();
8686
given(testContext.getTestInstance()).willThrow(originalFailure);
8787
SpringApplication application = new SpringApplication(Config.class);
88-
application.setWebEnvironment(false);
88+
application.setWebApplicationType(WebApplicationType.NONE);
8989
given(testContext.getApplicationContext()).willThrow(new RuntimeException());
9090
this.thrown.expect(is(originalFailure));
9191
this.reportListener.prepareTestInstance(testContext);

spring-boot-test/src/test/java/org/springframework/boot/test/json/JsonContentTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public void createWhenTypeIsNullShouldCreateContent() throws Exception {
6060
}
6161

6262
@Test
63+
@SuppressWarnings("deprecation")
6364
public void assertThatShouldReturnJsonContentAssert() throws Exception {
6465
JsonContent<ExampleObject> content = new JsonContent<>(getClass(), TYPE, JSON);
6566
assertThat(content.assertThat()).isInstanceOf(JsonContentAssert.class);

spring-boot/src/main/java/org/springframework/boot/context/properties/source/UnboundElementsSourceFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class UnboundElementsSourceFilter
4646
public Boolean apply(ConfigurationPropertySource configurationPropertySource) {
4747
Object underlyingSource = configurationPropertySource.getUnderlyingSource();
4848
if (underlyingSource instanceof PropertySource) {
49-
String name = ((PropertySource) underlyingSource).getName();
49+
String name = ((PropertySource<?>) underlyingSource).getName();
5050
return !BENIGN_PROPERTY_SOURCE_NAMES.contains(name);
5151

5252
}

spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactory.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ public void setDirectBuffers(Boolean directBuffers) {
117117

118118
/**
119119
* Set {@link UndertowBuilderCustomizer}s that should be applied to the Undertow
120-
* {@link Undertow.Builder}. Calling this method will replace any existing
121-
* customizers.
120+
* {@link io.undertow.Undertow.Builder Builder}. Calling this method will replace any
121+
* existing customizers.
122122
* @param customizers the customizers to set
123123
*/
124124
public void setBuilderCustomizers(
@@ -129,7 +129,7 @@ public void setBuilderCustomizers(
129129

130130
/**
131131
* Returns a mutable collection of the {@link UndertowBuilderCustomizer}s that will be
132-
* applied to the Undertow {@link Undertow.Builder} .
132+
* applied to the Undertow {@link io.undertow.Undertow.Builder Builder}.
133133
* @return the customizers that will be applied
134134
*/
135135
public Collection<UndertowBuilderCustomizer> getBuilderCustomizers() {
@@ -138,7 +138,7 @@ public Collection<UndertowBuilderCustomizer> getBuilderCustomizers() {
138138

139139
/**
140140
* Add {@link UndertowBuilderCustomizer}s that should be used to customize the
141-
* Undertow {@link Undertow.Builder}.
141+
* Undertow {@link io.undertow.Undertow.Builder Builder}.
142142
* @param customizers the customizers to add
143143
*/
144144
public void addBuilderCustomizers(UndertowBuilderCustomizer... customizers) {

0 commit comments

Comments
 (0)