From 48a507a99376165eebc020c2f61bbe412325f64c Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 5 Oct 2021 14:35:32 +0200 Subject: [PATCH] Clean up warnings --- .../AutowiredAnnotationBeanPostProcessor.java | 3 +-- .../annotation/AsyncAnnotationAdvisor.java | 1 - .../test/java/example/scannable/FooServiceImpl.java | 3 ++- .../autoproxy/AspectJAutoProxyCreatorTests.java | 7 ------- .../aop/framework/CglibProxyTests.java | 3 ++- .../AggressiveFactoryBeanInstantiationTests.java | 1 + .../ConfigurationClassPostProcessorTests.java | 4 +++- .../context/annotation/ParserStrategyUtilsTests.java | 4 ++-- .../context/annotation/Spr12278Tests.java | 3 +++ .../context/annotation/Spr16179Tests.java | 1 + .../ConfigurationClassProcessingTests.java | 10 ++++------ .../configuration/ImportResourceTests.java | 7 ++++--- .../configuration/ImportWithConditionTests.java | 4 +++- .../ImportedConfigurationClassEnhancementTests.java | 3 ++- .../annotation/configuration/Spr7167Tests.java | 3 ++- .../support/BeanFactoryPostProcessorTests.java | 6 +++--- .../context/support/LiveBeansViewTests.java | 3 ++- .../PropertyResourceConfigurerIntegrationTests.java | 1 + .../PropertySourcesPlaceholderConfigurerTests.java | 4 ++-- .../StaticApplicationContextMulticasterTests.java | 7 ++++--- .../support/StaticApplicationContextTests.java | 7 ++++--- .../context/support/StaticMessageSourceTests.java | 7 ++++--- .../EnableMBeanExportConfigurationTests.java | 4 ++-- .../core/testfixture/codec/AbstractEncoderTests.java | 10 +++------- .../orm/hibernate5/HibernateTemplate.java | 3 ++- .../springframework/r2dbc/core/binding/Bindings.java | 3 ++- .../http/codec/EncoderHttpMessageWriter.java | 3 --- .../http/codec/json/Jackson2SmileEncoder.java | 5 +---- .../http/codec/json/Jackson2JsonDecoderTests.java | 2 ++ .../http/codec/json/Jackson2JsonEncoderTests.java | 7 +++---- .../result/method/AbstractHandlerMethodMapping.java | 4 ---- .../socket/adapter/ReactorNettyWebSocketSession.java | 1 + .../adapter/UndertowWebSocketHandlerAdapter.java | 5 ++++- .../resource/AppCacheManifestTransformerTests.java | 6 +++--- .../reactive/resource/ResourceUrlProviderTests.java | 2 ++ .../web/servlet/ComplexWebApplicationContext.java | 2 ++ .../annotation/ResourceHandlerRegistryTests.java | 12 +++++++----- .../resource/AppCacheManifestTransformerTests.java | 6 +++--- .../view/ContentNegotiatingViewResolverTests.java | 9 +++++---- 39 files changed, 92 insertions(+), 84 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java index 2065f6b6e9..e7131a562e 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java @@ -539,8 +539,7 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA */ @SuppressWarnings({"deprecation", "cast"}) protected boolean determineRequiredStatus(MergedAnnotation ann) { - // The following (AnnotationAttributes) cast is required on JDK 9+. - return determineRequiredStatus((AnnotationAttributes) + return determineRequiredStatus( ann.asMap(mergedAnnotation -> new AnnotationAttributes(mergedAnnotation.getType()))); } diff --git a/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncAnnotationAdvisor.java b/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncAnnotationAdvisor.java index c5636f2daa..3b8792f7a1 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncAnnotationAdvisor.java +++ b/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncAnnotationAdvisor.java @@ -75,7 +75,6 @@ public class AsyncAnnotationAdvisor extends AbstractPointcutAdvisor implements B * handle unexpected exception thrown by asynchronous method executions * @see AnnotationAsyncExecutionInterceptor#getDefaultExecutor(BeanFactory) */ - @SuppressWarnings("unchecked") public AsyncAnnotationAdvisor( @Nullable Executor executor, @Nullable AsyncUncaughtExceptionHandler exceptionHandler) { diff --git a/spring-context/src/test/java/example/scannable/FooServiceImpl.java b/spring-context/src/test/java/example/scannable/FooServiceImpl.java index de062761fa..6a39aaf892 100644 --- a/spring-context/src/test/java/example/scannable/FooServiceImpl.java +++ b/spring-context/src/test/java/example/scannable/FooServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 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. @@ -47,6 +47,7 @@ import org.springframework.util.Assert; public abstract class FooServiceImpl implements FooService { // Just to test ASM5's bytecode parsing of INVOKESPECIAL/STATIC on interfaces + @SuppressWarnings("unused") private static final Comparator COMPARATOR_BY_MESSAGE = Comparator.comparing(MessageBean::getMessage); diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java index 279e600ec9..d841044f26 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java @@ -48,7 +48,6 @@ import org.springframework.core.NestedRuntimeException; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import org.springframework.lang.Nullable; -import org.springframework.util.StopWatch; import static org.assertj.core.api.Assertions.assertThat; @@ -310,12 +309,6 @@ public class AspectJAutoProxyCreatorTests { return String.format("%s-%s", getClass().getSimpleName(), fileSuffix); } - private void assertStopWatchTimeLimit(final StopWatch sw, final long maxTimeMillis) { - long totalTimeMillis = sw.getTotalTimeMillis(); - assertThat(totalTimeMillis < maxTimeMillis).as("'" + sw.getLastTaskName() + "' took too long: expected less than<" + maxTimeMillis + - "> ms, actual<" + totalTimeMillis + "> ms.").isTrue(); - } - } @Aspect("pertarget(execution(* *.getSpouse()))") diff --git a/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java b/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java index ba247ed89a..b1d1cd5943 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -513,6 +513,7 @@ public class CglibProxyTests extends AbstractAopProxyTests implements Serializab this.name = name; } + @SuppressWarnings("unused") public String getName() { return this.name; } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AggressiveFactoryBeanInstantiationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AggressiveFactoryBeanInstantiationTests.java index 5f97cd7f5c..07edad06f9 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AggressiveFactoryBeanInstantiationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AggressiveFactoryBeanInstantiationTests.java @@ -137,6 +137,7 @@ public class AggressiveFactoryBeanInstantiationTests { static class ExceptionInInitializer { + @SuppressWarnings("unused") private static final int ERROR = callInClinit(); private static int callInClinit() { diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java index 3b1f1a7f0d..2706511ea7 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -1956,6 +1956,7 @@ class ConfigurationClassPostProcessorTests { } // Unrelated, not to be considered as a factory method + @SuppressWarnings("unused") private boolean testBean(boolean param) { return param; } @@ -1985,6 +1986,7 @@ class ConfigurationClassPostProcessorTests { } // Unrelated, not to be considered as a factory method + @SuppressWarnings("unused") private boolean testBean(boolean param) { return param; } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ParserStrategyUtilsTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ParserStrategyUtilsTests.java index d5e5fc5466..f13afc6974 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ParserStrategyUtilsTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ParserStrategyUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 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. @@ -61,7 +61,7 @@ public class ParserStrategyUtilsTests { @BeforeEach void setup() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); given(this.resourceLoader.getClassLoader()).willReturn(this.beanClassLoader); } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/Spr12278Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/Spr12278Tests.java index afceea8a09..c17203dbc1 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/Spr12278Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/Spr12278Tests.java @@ -74,6 +74,7 @@ public class Spr12278Tests { private final String autowiredName; // No @Autowired - implicit wiring + @SuppressWarnings("unused") public SingleConstructorComponent(String autowiredName) { this.autowiredName = autowiredName; } @@ -88,11 +89,13 @@ public class Spr12278Tests { this.name = name; } + @SuppressWarnings("unused") public TwoConstructorsComponent() { this("fallback"); } } + @SuppressWarnings("unused") private static class TwoSpecificConstructorsComponent { private final Integer counter; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/Spr16179Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/Spr16179Tests.java index afeae7ece2..3bb8175464 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/Spr16179Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/Spr16179Tests.java @@ -70,6 +70,7 @@ public class Spr16179Tests { Assembler> assembler2; @Autowired(required = false) + @SuppressWarnings("rawtypes") Assembler assembler3; @Autowired(required = false) diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java index 89da3b9162..ce9033334c 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java @@ -42,7 +42,6 @@ import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.DependencyDescriptor; import org.springframework.beans.factory.config.ListFactoryBean; -import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; @@ -247,7 +246,9 @@ public class ConfigurationClassProcessingTests { public void configurationWithPostProcessor() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(ConfigWithPostProcessor.class); - RootBeanDefinition placeholderConfigurer = new RootBeanDefinition(PropertyPlaceholderConfigurer.class); + @SuppressWarnings("deprecation") + RootBeanDefinition placeholderConfigurer = new RootBeanDefinition( + org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.class); placeholderConfigurer.getPropertyValues().add("properties", "myProp=myValue"); ctx.registerBeanDefinition("placeholderConfigurer", placeholderConfigurer); ctx.refresh(); @@ -536,6 +537,7 @@ public class ConfigurationClassProcessingTests { String nameSuffix = "-processed-" + myProp; + @SuppressWarnings("unused") public void setNameSuffix(String nameSuffix) { this.nameSuffix = nameSuffix; } @@ -552,10 +554,6 @@ public class ConfigurationClassProcessingTests { public Object postProcessAfterInitialization(Object bean, String beanName) { return bean; } - - public int getOrder() { - return 0; - } }; } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportResourceTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportResourceTests.java index 87dd37d398..12fe608bbb 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportResourceTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportResourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 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. @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader; import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -166,8 +165,10 @@ public class ImportResourceTests { } } + @SuppressWarnings("deprecation") @Configuration - @ImportResource(locations = "classpath:org/springframework/context/annotation/configuration/ImportNonXmlResourceConfig-context.properties", reader = PropertiesBeanDefinitionReader.class) + @ImportResource(locations = "classpath:org/springframework/context/annotation/configuration/ImportNonXmlResourceConfig-context.properties", + reader = org.springframework.beans.factory.support.PropertiesBeanDefinitionReader.class) static class ImportNonXmlResourceConfig { } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportWithConditionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportWithConditionTests.java index 1a7b5f998b..52755bd7e5 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportWithConditionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportWithConditionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -59,6 +59,7 @@ public class ImportWithConditionTests { protected static class ConditionalThenUnconditional { @Autowired + @SuppressWarnings("unused") private BeanOne beanOne; } @@ -68,6 +69,7 @@ public class ImportWithConditionTests { protected static class UnconditionalThenConditional { @Autowired + @SuppressWarnings("unused") private BeanOne beanOne; } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportedConfigurationClassEnhancementTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportedConfigurationClassEnhancementTests.java index df640ffbd7..8aa24e9f1e 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportedConfigurationClassEnhancementTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportedConfigurationClassEnhancementTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 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. @@ -47,6 +47,7 @@ public class ImportedConfigurationClassEnhancementTests { autowiredConfigClassIsEnhanced(ConfigThatDoesNotImport.class, ConfigToBeAutowired.class); } + @SuppressWarnings("deprecation") private void autowiredConfigClassIsEnhanced(Class... configClasses) { ApplicationContext ctx = new AnnotationConfigApplicationContext(configClasses); Config config = ctx.getBean(Config.class); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr7167Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr7167Tests.java index ef73432110..6b66fcc5b5 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr7167Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr7167Tests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 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. @@ -32,6 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class Spr7167Tests { + @SuppressWarnings("deprecation") @Test public void test() { ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(MyConfig.class); diff --git a/spring-context/src/test/java/org/springframework/context/support/BeanFactoryPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/support/BeanFactoryPostProcessorTests.java index ffbdceb815..93e0dfa255 100644 --- a/spring-context/src/test/java/org/springframework/context/support/BeanFactoryPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/BeanFactoryPostProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 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. @@ -22,7 +22,6 @@ import org.springframework.beans.BeansException; import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor; import org.springframework.beans.factory.support.DefaultListableBeanFactory; @@ -75,6 +74,7 @@ public class BeanFactoryPostProcessorTests { } @Test + @SuppressWarnings("deprecation") public void testMultipleDefinedBeanFactoryPostProcessors() { StaticApplicationContext ac = new StaticApplicationContext(); ac.registerSingleton("tb1", TestBean.class); @@ -84,7 +84,7 @@ public class BeanFactoryPostProcessorTests { ac.registerSingleton("bfpp1", TestBeanFactoryPostProcessor.class, pvs1); MutablePropertyValues pvs2 = new MutablePropertyValues(); pvs2.add("properties", "key=value"); - ac.registerSingleton("bfpp2", PropertyPlaceholderConfigurer.class, pvs2); + ac.registerSingleton("bfpp2", org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.class, pvs2); ac.refresh(); TestBeanFactoryPostProcessor bfpp = (TestBeanFactoryPostProcessor) ac.getBean("bfpp1"); assertThat(bfpp.initValue).isEqualTo("value"); diff --git a/spring-context/src/test/java/org/springframework/context/support/LiveBeansViewTests.java b/spring-context/src/test/java/org/springframework/context/support/LiveBeansViewTests.java index 56c9ef4467..983fa9bc88 100644 --- a/spring-context/src/test/java/org/springframework/context/support/LiveBeansViewTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/LiveBeansViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 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. @@ -38,6 +38,7 @@ import static org.mockito.Mockito.mock; * @author Stephane Nicoll * @author Sam Brannen */ +@SuppressWarnings("deprecation") class LiveBeansViewTests { private final MockEnvironment environment = new MockEnvironment(); diff --git a/spring-context/src/test/java/org/springframework/context/support/PropertyResourceConfigurerIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/support/PropertyResourceConfigurerIntegrationTests.java index 82a018cf36..9a598631dc 100644 --- a/spring-context/src/test/java/org/springframework/context/support/PropertyResourceConfigurerIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/PropertyResourceConfigurerIntegrationTests.java @@ -43,6 +43,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Sam Brannen * @see org.springframework.beans.factory.config.PropertyResourceConfigurerTests */ +@SuppressWarnings("deprecation") public class PropertyResourceConfigurerIntegrationTests { @Test diff --git a/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java b/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java index 03606bc697..8717dba116 100644 --- a/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 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. @@ -46,7 +46,6 @@ import static org.springframework.beans.factory.support.BeanDefinitionBuilder.ro */ public class PropertySourcesPlaceholderConfigurerTests { - @Test public void replacementFromEnvironmentProperties() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); @@ -397,6 +396,7 @@ public class PropertySourcesPlaceholderConfigurerTests { return name; } + @SuppressWarnings("unused") public void setName(Optional name) { this.name = name; } diff --git a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java index 403bf613be..491af1c4db 100644 --- a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 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. @@ -23,7 +23,6 @@ import java.util.Map; import org.junit.jupiter.api.Test; import org.springframework.beans.MutablePropertyValues; -import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader; import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationEvent; import org.springframework.context.ConfigurableApplicationContext; @@ -48,6 +47,7 @@ public class StaticApplicationContextMulticasterTests extends AbstractApplicatio protected StaticApplicationContext sac; + @SuppressWarnings("deprecation") @Override protected ConfigurableApplicationContext createContext() throws Exception { StaticApplicationContext parent = new StaticApplicationContext(); @@ -67,7 +67,8 @@ public class StaticApplicationContextMulticasterTests extends AbstractApplicatio sac.registerSingleton("beanThatListens", BeanThatListens.class, new MutablePropertyValues()); sac.registerSingleton("aca", ACATester.class, new MutablePropertyValues()); sac.registerPrototype("aca-prototype", ACATester.class, new MutablePropertyValues()); - PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(sac.getDefaultListableBeanFactory()); + org.springframework.beans.factory.support.PropertiesBeanDefinitionReader reader = + new org.springframework.beans.factory.support.PropertiesBeanDefinitionReader(sac.getDefaultListableBeanFactory()); Resource resource = new ClassPathResource("testBeans.properties", getClass()); reader.loadBeanDefinitions(new EncodedResource(resource, "ISO-8859-1")); sac.refresh(); diff --git a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java index 91c06a88da..023efd449b 100644 --- a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2021 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. @@ -23,7 +23,6 @@ import java.util.Map; import org.junit.jupiter.api.Test; import org.springframework.beans.MutablePropertyValues; -import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader; import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.testfixture.AbstractApplicationContextTests; @@ -40,6 +39,7 @@ public class StaticApplicationContextTests extends AbstractApplicationContextTes protected StaticApplicationContext sac; + @SuppressWarnings("deprecation") @Override protected ConfigurableApplicationContext createContext() throws Exception { StaticApplicationContext parent = new StaticApplicationContext(); @@ -57,7 +57,8 @@ public class StaticApplicationContextTests extends AbstractApplicationContextTes sac.registerSingleton("beanThatListens", BeanThatListens.class, new MutablePropertyValues()); sac.registerSingleton("aca", ACATester.class, new MutablePropertyValues()); sac.registerPrototype("aca-prototype", ACATester.class, new MutablePropertyValues()); - PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(sac.getDefaultListableBeanFactory()); + org.springframework.beans.factory.support.PropertiesBeanDefinitionReader reader = + new org.springframework.beans.factory.support.PropertiesBeanDefinitionReader(sac.getDefaultListableBeanFactory()); reader.loadBeanDefinitions(new ClassPathResource("testBeans.properties", getClass())); sac.refresh(); sac.addApplicationListener(listener); diff --git a/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java b/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java index 3b84bd9a8f..d24f13a13c 100644 --- a/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.beans.MutablePropertyValues; -import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.MessageSourceResolvable; import org.springframework.context.NoSuchMessageException; @@ -176,6 +175,7 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests { sac.getMessage(resolvable4, Locale.US)); } + @SuppressWarnings("deprecation") @Override protected ConfigurableApplicationContext createContext() throws Exception { StaticApplicationContext parent = new StaticApplicationContext(); @@ -197,7 +197,8 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests { sac.registerPrototype("aca-prototype", ACATester.class, new MutablePropertyValues()); - PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(sac.getDefaultListableBeanFactory()); + org.springframework.beans.factory.support.PropertiesBeanDefinitionReader reader = + new org.springframework.beans.factory.support.PropertiesBeanDefinitionReader(sac.getDefaultListableBeanFactory()); reader.loadBeanDefinitions(new ClassPathResource("testBeans.properties", getClass())); sac.refresh(); sac.addApplicationListener(listener); diff --git a/spring-context/src/test/java/org/springframework/jmx/export/annotation/EnableMBeanExportConfigurationTests.java b/spring-context/src/test/java/org/springframework/jmx/export/annotation/EnableMBeanExportConfigurationTests.java index 5d7f8998a8..553a4cb14c 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/annotation/EnableMBeanExportConfigurationTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/annotation/EnableMBeanExportConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 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. @@ -251,7 +251,7 @@ public class EnableMBeanExportConfigurationTests { @Bean @Lazy public Object notLoadable() throws Exception { - return Class.forName("does.not.exist").newInstance(); + return Class.forName("does.not.exist").getDeclaredConstructor().newInstance(); } } diff --git a/spring-core/src/testFixtures/java/org/springframework/core/testfixture/codec/AbstractEncoderTests.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/codec/AbstractEncoderTests.java index 106cc114e8..0b626f94de 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/testfixture/codec/AbstractEncoderTests.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/codec/AbstractEncoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -39,8 +39,8 @@ import static org.springframework.core.io.buffer.DataBufferUtils.release; /** * Abstract base class for {@link Encoder} unit tests. Subclasses need to implement - * {@link #canEncode()} and {@link #encode()}, possibly using the wide - * * variety of helper methods like {@link #testEncodeAll}. + * {@link #canEncode()} and {@link #encode()}, possibly using the wide variety of + * helper methods like {@link #testEncodeAll}. * * @author Arjen Poutsma * @since 5.1.3 @@ -58,9 +58,7 @@ public abstract class AbstractEncoderTests> extends Abstrac * @param encoder the encoder */ protected AbstractEncoderTests(E encoder) { - Assert.notNull(encoder, "Encoder must not be null"); - this.encoder = encoder; } @@ -253,13 +251,11 @@ public abstract class AbstractEncoderTests> extends Abstrac release(dataBuffer); assertThat(actual).isEqualTo(expected); }; - } @SuppressWarnings("unchecked") private Encoder encoder() { return (Encoder) this.encoder; - } /** diff --git a/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTemplate.java b/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTemplate.java index e624fca329..d4433bc985 100644 --- a/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTemplate.java +++ b/spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -983,6 +983,7 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean // Convenience query methods for iteration and bulk updates/deletes //------------------------------------------------------------------------- + @SuppressWarnings("deprecation") @Deprecated @Override public Iterator iterate(String queryString, @Nullable Object... values) throws DataAccessException { diff --git a/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/binding/Bindings.java b/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/binding/Bindings.java index 63cf20dc5f..9be490287c 100644 --- a/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/binding/Bindings.java +++ b/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/binding/Bindings.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -100,6 +100,7 @@ public class Bindings implements Iterable { * Exceptions thrown by the action are relayed to the * @param action the action to be performed for each {@link Binding} */ + @Override public void forEach(Consumer action) { this.bindings.forEach((marker, binding) -> action.accept(binding)); } diff --git a/spring-web/src/main/java/org/springframework/http/codec/EncoderHttpMessageWriter.java b/spring-web/src/main/java/org/springframework/http/codec/EncoderHttpMessageWriter.java index 3fe1920773..c2d6986bd2 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/EncoderHttpMessageWriter.java +++ b/spring-web/src/main/java/org/springframework/http/codec/EncoderHttpMessageWriter.java @@ -180,9 +180,6 @@ public class EncoderHttpMessageWriter implements HttpMessageWriter { return main; } - private static void touch(DataBuffer buffer, Map hints) { - } - private boolean isStreamingMediaType(@Nullable MediaType mediaType) { if (mediaType == null || !(this.encoder instanceof HttpMessageEncoder)) { return false; diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2SmileEncoder.java b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2SmileEncoder.java index 98d294d3bb..580b35c002 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2SmileEncoder.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2SmileEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -44,9 +44,6 @@ public class Jackson2SmileEncoder extends AbstractJackson2Encoder { new MimeType("application", "x-jackson-smile"), new MimeType("application", "*+x-jackson-smile")}; - private static final MimeType STREAM_MIME_TYPE = - MediaType.parseMediaType("application/stream+x-jackson-smile"); - private static final byte[] STREAM_SEPARATOR = new byte[0]; diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java index 8cfeb045f8..aa8c1f5dfd 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java @@ -76,6 +76,7 @@ public class Jackson2JsonDecoderTests extends AbstractDecoderTests input = Flux.just(new Pojo("foo", "bar"), new Pojo("foofoo", "barbar"), @@ -257,7 +257,6 @@ public class Jackson2JsonEncoderTests extends AbstractEncoderTests extends AbstractHandlerMap this.registration = registration; } - public T getMapping() { - return this.mapping; - } - public HandlerMethod getHandlerMethod() { return this.registration.getHandlerMethod(); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/adapter/ReactorNettyWebSocketSession.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/adapter/ReactorNettyWebSocketSession.java index b84caa7439..9354318c71 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/adapter/ReactorNettyWebSocketSession.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/adapter/ReactorNettyWebSocketSession.java @@ -64,6 +64,7 @@ public class ReactorNettyWebSocketSession * Constructor with an additional maxFramePayloadLength argument. * @since 5.1 */ + @SuppressWarnings("rawtypes") public ReactorNettyWebSocketSession(WebsocketInbound inbound, WebsocketOutbound outbound, HandshakeInfo info, NettyDataBufferFactory bufferFactory, int maxFramePayloadLength) { diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/adapter/UndertowWebSocketHandlerAdapter.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/adapter/UndertowWebSocketHandlerAdapter.java index e2b0323a61..879ea596b2 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/adapter/UndertowWebSocketHandlerAdapter.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/adapter/UndertowWebSocketHandlerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -58,18 +58,21 @@ public class UndertowWebSocketHandlerAdapter extends AbstractReceiveListener { } @Override + @SuppressWarnings("deprecation") protected void onFullBinaryMessage(WebSocketChannel channel, BufferedBinaryMessage message) { this.session.handleMessage(Type.BINARY, toMessage(Type.BINARY, message.getData().getResource())); message.getData().free(); } @Override + @SuppressWarnings("deprecation") protected void onFullPongMessage(WebSocketChannel channel, BufferedBinaryMessage message) { this.session.handleMessage(Type.PONG, toMessage(Type.PONG, message.getData().getResource())); message.getData().free(); } @Override + @SuppressWarnings("deprecation") protected void onFullCloseMessage(WebSocketChannel channel, BufferedBinaryMessage message) { CloseMessage closeMessage = new CloseMessage(message.getData().getResource()); this.session.handleClose(CloseStatus.create(closeMessage.getCode(), closeMessage.getReason())); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/AppCacheManifestTransformerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/AppCacheManifestTransformerTests.java index d58f0fb81c..24ce532e49 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/AppCacheManifestTransformerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/AppCacheManifestTransformerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 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. @@ -37,12 +37,13 @@ import static org.springframework.web.testfixture.http.server.reactive.MockServe * @author Rossen Stoyanchev * @author Brian Clozel */ +@SuppressWarnings("deprecation") public class AppCacheManifestTransformerTests { private static final Duration TIMEOUT = Duration.ofSeconds(5); - private AppCacheManifestTransformer transformer; + private final AppCacheManifestTransformer transformer = new AppCacheManifestTransformer(); private ResourceTransformerChain chain; @@ -57,7 +58,6 @@ public class AppCacheManifestTransformerTests { ResourceResolverChain resolverChain = new DefaultResourceResolverChain(resolvers); this.chain = new DefaultResourceTransformerChain(resolverChain, Collections.emptyList()); - this.transformer = new AppCacheManifestTransformer(); this.transformer.setResourceUrlProvider(createUrlProvider(resolvers)); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceUrlProviderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceUrlProviderTests.java index c4ffa23a1c..ec5d45344a 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceUrlProviderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceUrlProviderTests.java @@ -158,6 +158,8 @@ public class ResourceUrlProviderTests { assertThat(parentUrlProvider.getHandlerMap()).isEmpty(); ResourceUrlProvider childUrlProvider = childContext.getBean(ResourceUrlProvider.class); assertThat(childUrlProvider.getHandlerMap()).hasKeySatisfying(pathPatternStringOf("/resources/**")); + childContext.close(); + parentContext.close(); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/ComplexWebApplicationContext.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/ComplexWebApplicationContext.java index 9c00d19500..be08292460 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/ComplexWebApplicationContext.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/ComplexWebApplicationContext.java @@ -266,6 +266,7 @@ public class ComplexWebApplicationContext extends StaticWebApplicationContext { } @Override + @SuppressWarnings("deprecation") public long getLastModified(HttpServletRequest request, Object delegate) { return ((MyHandler) delegate).lastModified(); } @@ -286,6 +287,7 @@ public class ComplexWebApplicationContext extends StaticWebApplicationContext { } @Override + @SuppressWarnings("deprecation") public long getLastModified(HttpServletRequest request, Object delegate) { return -1; } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistryTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistryTests.java index 0551598c49..cce273a249 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistryTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -33,7 +33,6 @@ import org.springframework.web.accept.ContentNegotiationManager; import org.springframework.web.context.support.GenericWebApplicationContext; import org.springframework.web.servlet.HandlerMapping; import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping; -import org.springframework.web.servlet.resource.AppCacheManifestTransformer; import org.springframework.web.servlet.resource.CachingResourceResolver; import org.springframework.web.servlet.resource.CachingResourceTransformer; import org.springframework.web.servlet.resource.CssLinkResourceTransformer; @@ -163,13 +162,14 @@ public class ResourceHandlerRegistryTests { } @Test + @SuppressWarnings("deprecation") public void resourceChainWithVersionResolver() throws Exception { VersionResourceResolver versionResolver = new VersionResourceResolver() .addFixedVersionStrategy("fixed", "/**/*.js") .addContentVersionStrategy("/**"); this.registration.resourceChain(true).addResolver(versionResolver) - .addTransformer(new AppCacheManifestTransformer()); + .addTransformer(new org.springframework.web.servlet.resource.AppCacheManifestTransformer()); ResourceHttpRequestHandler handler = getHandler("/resources/**"); List resolvers = handler.getResourceResolvers(); @@ -183,17 +183,19 @@ public class ResourceHandlerRegistryTests { assertThat(transformers).hasSize(3); assertThat(transformers.get(0)).isInstanceOf(CachingResourceTransformer.class); assertThat(transformers.get(1)).isInstanceOf(CssLinkResourceTransformer.class); - assertThat(transformers.get(2)).isInstanceOf(AppCacheManifestTransformer.class); + assertThat(transformers.get(2)).isInstanceOf(org.springframework.web.servlet.resource.AppCacheManifestTransformer.class); } @Test + @SuppressWarnings("deprecation") public void resourceChainWithOverrides() throws Exception { CachingResourceResolver cachingResolver = Mockito.mock(CachingResourceResolver.class); VersionResourceResolver versionResolver = Mockito.mock(VersionResourceResolver.class); WebJarsResourceResolver webjarsResolver = Mockito.mock(WebJarsResourceResolver.class); PathResourceResolver pathResourceResolver = new PathResourceResolver(); CachingResourceTransformer cachingTransformer = Mockito.mock(CachingResourceTransformer.class); - AppCacheManifestTransformer appCacheTransformer = Mockito.mock(AppCacheManifestTransformer.class); + org.springframework.web.servlet.resource.AppCacheManifestTransformer appCacheTransformer = + Mockito.mock(org.springframework.web.servlet.resource.AppCacheManifestTransformer.class); CssLinkResourceTransformer cssLinkTransformer = new CssLinkResourceTransformer(); this.registration.setCachePeriod(3600) diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/AppCacheManifestTransformerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/AppCacheManifestTransformerTests.java index 4b12502b8e..2b321fa7bd 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/AppCacheManifestTransformerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/AppCacheManifestTransformerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 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. @@ -38,9 +38,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Brian Clozel * @author Rossen Stoyanchev */ +@SuppressWarnings("deprecation") public class AppCacheManifestTransformerTests { - private AppCacheManifestTransformer transformer; + private final AppCacheManifestTransformer transformer = new AppCacheManifestTransformer(); private ResourceTransformerChain chain; @@ -59,7 +60,6 @@ public class AppCacheManifestTransformerTests { ResourceResolverChain resolverChain = new DefaultResourceResolverChain(resolvers); this.chain = new DefaultResourceTransformerChain(resolverChain, Collections.emptyList()); - this.transformer = new AppCacheManifestTransformer(); this.transformer.setResourceUrlProvider(createUrlProvider(resolvers)); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolverTests.java index ec619d54aa..4534036b6f 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 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. @@ -34,7 +34,6 @@ import org.springframework.web.accept.FixedContentNegotiationStrategy; import org.springframework.web.accept.HeaderContentNegotiationStrategy; import org.springframework.web.accept.MappingMediaTypeFileExtensionResolver; import org.springframework.web.accept.ParameterContentNegotiationStrategy; -import org.springframework.web.accept.PathExtensionContentNegotiationStrategy; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.support.StaticWebApplicationContext; @@ -312,11 +311,12 @@ public class ContentNegotiatingViewResolverTests { } @Test + @SuppressWarnings("deprecation") public void resolveViewNameFilename() throws Exception { request.setRequestURI("/test.html"); ContentNegotiationManager manager = - new ContentNegotiationManager(new PathExtensionContentNegotiationStrategy()); + new ContentNegotiationManager(new org.springframework.web.accept.PathExtensionContentNegotiationStrategy()); ViewResolver viewResolverMock1 = mock(ViewResolver.class, "viewResolver1"); ViewResolver viewResolverMock2 = mock(ViewResolver.class, "viewResolver2"); @@ -348,7 +348,8 @@ public class ContentNegotiatingViewResolverTests { request.setRequestURI("/test.json"); Map mapping = Collections.singletonMap("json", MediaType.APPLICATION_JSON); - PathExtensionContentNegotiationStrategy pathStrategy = new PathExtensionContentNegotiationStrategy(mapping); + org.springframework.web.accept.PathExtensionContentNegotiationStrategy pathStrategy = + new org.springframework.web.accept.PathExtensionContentNegotiationStrategy(mapping); viewResolver.setContentNegotiationManager(new ContentNegotiationManager(pathStrategy)); ViewResolver viewResolverMock1 = mock(ViewResolver.class);