Fix checkstyle RedundantModifier test violations

pull/17066/head
Phillip Webb 6 years ago
parent cde4f0d688
commit 266d6334b2

@ -75,7 +75,7 @@
<propertyExpansion>main.basedir=${main.basedir}</propertyExpansion>
<sourceDirectories>${basedir}</sourceDirectories>
<includes>**/*</includes>
<excludes>.git/**/*,target/**/,**/.flattened-pom.xml</excludes>
<excludes>.git/**/*,target/**/,**/.flattened-pom.xml,**/*.class,**/spring-boot-gradle-plugin/build/**</excludes>
</configuration>
<goals>
<goal>check</goal>

@ -63,7 +63,7 @@ class ConditionsReportEndpointTests {
private final ConfigurableApplicationContext context;
public Config(ConfigurableApplicationContext context) {
Config(ConfigurableApplicationContext context) {
this.context = context;
}

@ -392,7 +392,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
private Foo self;
public SelfReferential() {
SelfReferential() {
this.self = this;
}

@ -266,7 +266,7 @@ class ConfigurationPropertiesReportEndpointTests {
private Duration duration = Duration.ofSeconds(10);
public TestProperties() {
TestProperties() {
this.secrets.put("mine", "myPrivateThing");
this.secrets.put("yours", "yourPrivateThing");
this.listItems.add(new ListItem());

@ -57,7 +57,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class WebFluxEndpointIntegrationTests
extends AbstractWebEndpointIntegrationTests<AnnotationConfigReactiveWebServerApplicationContext> {
public WebFluxEndpointIntegrationTests() {
WebFluxEndpointIntegrationTests() {
super(WebFluxEndpointIntegrationTests::createApplicationContext,
WebFluxEndpointIntegrationTests::applyAuthenticatedConfiguration);

@ -67,7 +67,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class MvcWebEndpointIntegrationTests
extends AbstractWebEndpointIntegrationTests<AnnotationConfigServletWebServerApplicationContext> {
public MvcWebEndpointIntegrationTests() {
MvcWebEndpointIntegrationTests() {
super(MvcWebEndpointIntegrationTests::createApplicationContext,
MvcWebEndpointIntegrationTests::applyAuthenticatedConfiguration);
}

@ -83,7 +83,7 @@ class MailHealthIndicatorTests {
public static class SuccessTransport extends Transport {
public SuccessTransport(Session session, URLName urlName) {
SuccessTransport(Session session, URLName urlName) {
super(session, urlName);
}

@ -477,7 +477,7 @@ class ConditionalOnBeanTests {
private String value;
public ExampleBean(String value) {
ExampleBean(String value) {
this.value = value;
}
@ -490,7 +490,7 @@ class ConditionalOnBeanTests {
public static class CustomExampleBean extends ExampleBean {
public CustomExampleBean() {
CustomExampleBean() {
super("custom subclass");
}
@ -498,7 +498,7 @@ class ConditionalOnBeanTests {
public static class OtherExampleBean extends ExampleBean {
public OtherExampleBean() {
OtherExampleBean() {
super("other subclass");
}

@ -400,7 +400,7 @@ class JacksonAutoConfigurationTests {
public static class MyDateFormat extends SimpleDateFormat {
public MyDateFormat() {
MyDateFormat() {
super("yyyy-MM-dd HH:mm:ss");
}

@ -77,7 +77,7 @@ class JerseyAutoConfigurationCustomFilterContextPathTests {
return "Hello " + this.msg;
}
public Application() {
Application() {
register(Application.class);
}

@ -76,7 +76,7 @@ class JerseyAutoConfigurationCustomFilterPathTests {
return "Hello " + this.msg;
}
public Application() {
Application() {
register(Application.class);
}

@ -57,7 +57,7 @@ class JerseyAutoConfigurationCustomLoadOnStartupTests {
@MinimalWebConfiguration
public static class Application extends ResourceConfig {
public Application() {
Application() {
register(Application.class);
}

@ -75,7 +75,7 @@ class JerseyAutoConfigurationCustomObjectMapperProviderTests {
return new Message("Jersey", null);
}
public Application() {
Application() {
register(Application.class);
}
@ -91,7 +91,7 @@ class JerseyAutoConfigurationCustomObjectMapperProviderTests {
private String body;
public Message(String subject, String body) {
Message(String subject, String body) {
this.subject = subject;
this.body = body;
}

@ -76,7 +76,7 @@ class JerseyAutoConfigurationCustomServletContextPathTests {
return "Hello " + this.msg;
}
public Application() {
Application() {
register(Application.class);
}

@ -76,7 +76,7 @@ class JerseyAutoConfigurationCustomServletPathTests {
return "Hello " + this.msg;
}
public Application() {
Application() {
register(Application.class);
}

@ -74,7 +74,7 @@ class JerseyAutoConfigurationDefaultFilterPathTests {
return "Hello " + this.msg;
}
public Application() {
Application() {
register(Application.class);
}

@ -69,7 +69,7 @@ class JerseyAutoConfigurationDefaultServletPathTests {
@Value("${message:World}")
private String msg;
public Application() {
Application() {
register(Application.class);
}

@ -77,7 +77,7 @@ class JerseyAutoConfigurationObjectMapperProviderTests {
return new Message("Jersey", null);
}
public Application() {
Application() {
register(Application.class);
}
@ -93,11 +93,10 @@ class JerseyAutoConfigurationObjectMapperProviderTests {
private String body;
public Message() {
Message() {
}
public Message(String subject, String body) {
Message(String subject, String body) {
this.subject = subject;
this.body = body;
}

@ -74,7 +74,7 @@ class JerseyAutoConfigurationWithoutApplicationPathTests {
return "Hello " + this.msg;
}
public Application() {
Application() {
register(Application.class);
}

@ -373,7 +373,7 @@ abstract class AbstractJpaAutoConfigurationTests {
private final DataSource dataSource;
public TestConfigurationWithCustomPersistenceUnitManager(DataSource dataSource) {
TestConfigurationWithCustomPersistenceUnitManager(DataSource dataSource) {
this.dataSource = dataSource;
}

@ -87,7 +87,7 @@ import static org.mockito.Mockito.mock;
*/
class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigurationTests {
public HibernateJpaAutoConfigurationTests() {
HibernateJpaAutoConfigurationTests() {
super(HibernateJpaAutoConfiguration.class);
}

@ -388,7 +388,7 @@ class QuartzAutoConfigurationTests {
public static class ComponentThatUsesScheduler {
public ComponentThatUsesScheduler(Scheduler scheduler) {
ComponentThatUsesScheduler(Scheduler scheduler) {
Assert.notNull(scheduler, "Scheduler must not be null");
}

@ -103,7 +103,7 @@ class SecurityFilterAutoConfigurationEarlyInitializationTests {
private static final long serialVersionUID = 1L;
public JacksonModuleBean(DeserializerBean myDeser) {
JacksonModuleBean(DeserializerBean myDeser) {
addDeserializer(SourceType.class, myDeser);
}
@ -115,7 +115,7 @@ class SecurityFilterAutoConfigurationEarlyInitializationTests {
@Autowired
ConversionService conversionService;
public DeserializerBean() {
DeserializerBean() {
super(SourceType.class);
}

@ -60,7 +60,8 @@ public class SpringApplicationLauncher {
Map<String, Object> defaultProperties = new HashMap<>();
defaultProperties.put("spring.groovy.template.check-template-location", "false");
Class<?> applicationClass = this.classLoader.loadClass(getSpringApplicationClassName());
Constructor<?> constructor = applicationClass.getConstructor(Class[].class);
Constructor<?> constructor = applicationClass.getDeclaredConstructor(Class[].class);
constructor.setAccessible(true);
Object application = constructor.newInstance((Object) sources);
applicationClass.getMethod("setDefaultProperties", Map.class).invoke(application, defaultProperties);
Method method = applicationClass.getMethod("run", String[].class);

@ -122,7 +122,7 @@ class SpringApplicationLauncherTests {
private static String[] args;
public TestSpringApplication(Class<?>[] sources) {
TestSpringApplication(Class<?>[] sources) {
TestSpringApplication.sources = sources;
}

@ -59,7 +59,7 @@ class InitCommandTests extends AbstractHttpClientMockTests {
MockitoAnnotations.initMocks(this);
}
public InitCommandTests() {
InitCommandTests() {
InitializrService initializrService = new InitializrService(this.http);
this.handler = new TestableInitCommandOptionHandler(initializrService);
this.command = new InitCommand(this.handler);

@ -90,7 +90,7 @@ class ClassPathFileSystemWatcherTests {
public final Environment environment;
public Config(Environment environment) {
Config(Environment environment) {
this.environment = environment;
}

@ -72,7 +72,7 @@ class RestartScopeInitializerTests {
public static class ScopeTestBean implements ApplicationListener<ContextRefreshedEvent> {
public ScopeTestBean() {
ScopeTestBean() {
createCount.incrementAndGet();
}

@ -49,7 +49,7 @@ class LocalHostWebClientTests {
@Captor
private ArgumentCaptor<WebRequest> requestCaptor;
public LocalHostWebClientTests() {
LocalHostWebClientTests() {
MockitoAnnotations.initMocks(this);
}

@ -50,7 +50,7 @@ class LocalHostWebConnectionHtmlUnitDriverTests {
@Mock
private WebClient webClient;
public LocalHostWebConnectionHtmlUnitDriverTests() {
LocalHostWebConnectionHtmlUnitDriverTests() {
MockitoAnnotations.initMocks(this);
given(this.webClient.getOptions()).willReturn(new WebClientOptions());
given(this.webClient.getWebConsole()).willReturn(new WebConsole());
@ -108,7 +108,7 @@ class LocalHostWebConnectionHtmlUnitDriverTests {
public class TestLocalHostWebConnectionHtmlUnitDriver extends LocalHostWebConnectionHtmlUnitDriver {
public TestLocalHostWebConnectionHtmlUnitDriver(Environment environment) {
TestLocalHostWebConnectionHtmlUnitDriver(Environment environment) {
super(environment);
}

@ -21,6 +21,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Constructor;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
@ -42,6 +43,7 @@ import org.springframework.boot.loader.archive.Archive.EntryFilter;
import org.springframework.boot.loader.archive.ExplodedArchive;
import org.springframework.boot.loader.archive.JarFileArchive;
import org.springframework.boot.loader.util.SystemPropertyUtils;
import org.springframework.util.Assert;
/**
* {@link Launcher} for archives with user-configured classpath and main class via a
@ -73,6 +75,14 @@ import org.springframework.boot.loader.util.SystemPropertyUtils;
*/
public class PropertiesLauncher extends Launcher {
private static final Class<?>[] PARENT_ONLY_PARAMS = new Class<?>[] { ClassLoader.class };
private static final Class<?>[] URLS_AND_PARENT_PARAMS = new Class<?>[] { URL[].class, ClassLoader.class };
private static final Class<?>[] NO_PARAMS = new Class<?>[] {};
private static final URL[] NO_URLS = new URL[0];
private static final String DEBUG = "loader.debug";
/**
@ -339,7 +349,7 @@ public class PropertiesLauncher extends Launcher {
for (Archive archive : archives) {
urls.add(archive.getUrl());
}
ClassLoader loader = new LaunchedURLClassLoader(urls.toArray(new URL[0]), getClass().getClassLoader());
ClassLoader loader = new LaunchedURLClassLoader(urls.toArray(NO_URLS), getClass().getClassLoader());
debug("Classpath: " + urls);
String customLoaderClassName = getProperty("loader.classLoader");
if (customLoaderClassName != null) {
@ -350,22 +360,29 @@ public class PropertiesLauncher extends Launcher {
}
@SuppressWarnings("unchecked")
private ClassLoader wrapWithCustomClassLoader(ClassLoader parent, String loaderClassName) throws Exception {
Class<ClassLoader> loaderClass = (Class<ClassLoader>) Class.forName(loaderClassName, true, parent);
try {
return loaderClass.getConstructor(ClassLoader.class).newInstance(parent);
private ClassLoader wrapWithCustomClassLoader(ClassLoader parent, String className) throws Exception {
Class<ClassLoader> type = (Class<ClassLoader>) Class.forName(className, true, parent);
ClassLoader classLoader = newClassLoader(type, PARENT_ONLY_PARAMS, parent);
if (classLoader == null) {
classLoader = newClassLoader(type, URLS_AND_PARENT_PARAMS, NO_URLS, parent);
}
catch (NoSuchMethodException ex) {
// Ignore and try with URLs
if (classLoader == null) {
classLoader = newClassLoader(type, NO_PARAMS);
}
Assert.notNull(classLoader, "Unable to create class loader for " + className);
return classLoader;
}
private ClassLoader newClassLoader(Class<ClassLoader> loaderClass, Class<?>[] parameterTypes, Object... initargs)
throws Exception {
try {
return loaderClass.getConstructor(URL[].class, ClassLoader.class).newInstance(new URL[0], parent);
Constructor<ClassLoader> constructor = loaderClass.getDeclaredConstructor(parameterTypes);
constructor.setAccessible(true);
return constructor.newInstance(initargs);
}
catch (NoSuchMethodException ex) {
// Ignore and try without any arguments
return null;
}
return loaderClass.newInstance();
}
private String getProperty(String propertyKey) throws Exception {

@ -360,7 +360,7 @@ class PropertiesLauncherTests {
public static class TestLoader extends URLClassLoader {
public TestLoader(ClassLoader parent) {
TestLoader(ClassLoader parent) {
super(new URL[0], parent);
}

@ -125,8 +125,7 @@ class ConfigurationPropertiesBeanRegistrarTests {
@ConfigurationProperties(prefix = "bar")
public static class BarProperties {
public BarProperties(String foo) {
BarProperties(String foo) {
}
}
@ -134,12 +133,10 @@ class ConfigurationPropertiesBeanRegistrarTests {
@ConfigurationProperties(prefix = "bing")
public static class BingProperties {
public BingProperties() {
BingProperties() {
}
public BingProperties(String foo) {
BingProperties(String foo) {
}
}

@ -470,7 +470,7 @@ class CollectionBinderTests {
public static class MyCustomNoDefaultConstructorList extends ArrayList<String> {
public MyCustomNoDefaultConstructorList(List<String> items) {
MyCustomNoDefaultConstructorList(List<String> items) {
addAll(items);
}

@ -149,7 +149,7 @@ class ConstructorParametersBinderTests {
private final ExampleEnum enumValue;
public ExampleValueBean(int intValue, long longValue, boolean booleanValue, String stringValue,
ExampleValueBean(int intValue, long longValue, boolean booleanValue, String stringValue,
ExampleEnum enumValue) {
this.intValue = intValue;
this.longValue = longValue;
@ -191,11 +191,11 @@ class ConstructorParametersBinderTests {
@SuppressWarnings("unused")
public static class MultipleConstructorsBean {
public MultipleConstructorsBean(int intValue) {
MultipleConstructorsBean(int intValue) {
this(intValue, 23L, "hello");
}
public MultipleConstructorsBean(int intValue, long longValue, String stringValue) {
MultipleConstructorsBean(int intValue, long longValue, String stringValue) {
}
}
@ -204,7 +204,7 @@ class ConstructorParametersBinderTests {
private final String name;
public ExampleAbstractBean(String name) {
ExampleAbstractBean(String name) {
this.name = name;
}
@ -216,8 +216,7 @@ class ConstructorParametersBinderTests {
public static class DefaultConstructorBean {
public DefaultConstructorBean() {
DefaultConstructorBean() {
}
}
@ -226,7 +225,7 @@ class ConstructorParametersBinderTests {
private final ExampleValueBean valueBean;
public ExampleNestedBean(ExampleValueBean valueBean) {
ExampleNestedBean(ExampleValueBean valueBean) {
this.valueBean = valueBean;
}
@ -244,7 +243,7 @@ class ConstructorParametersBinderTests {
private final List<String> customList;
public ExampleDefaultValueBean(@DefaultValue("5") int intValue,
ExampleDefaultValueBean(@DefaultValue("5") int intValue,
@DefaultValue({ "a", "b", "c" }) List<String> stringsList,
@DefaultValue("x,y,z") List<String> customList) {
this.intValue = intValue;

@ -758,7 +758,7 @@ class JavaBeanBinderTests {
private String value;
public ExampleWithNonDefaultConstructor(String value) {
ExampleWithNonDefaultConstructor(String value) {
this.value = value;
}

@ -605,10 +605,10 @@ class MapBinderTests {
private String pattern;
public Foo() {
Foo() {
}
public Foo(String pattern) {
Foo(String pattern) {
this.pattern = pattern;
}
@ -668,7 +668,7 @@ class MapBinderTests {
public static class MyCustomNoDefaultConstructorMap extends HashMap<String, String> {
public MyCustomNoDefaultConstructorMap(Map<String, String> items) {
MyCustomNoDefaultConstructorMap(Map<String, String> items) {
putAll(items);
}

@ -167,7 +167,7 @@ class ServletWebServerMvcIntegrationTests {
private final Environment env;
public AdvancedConfig(Environment env) {
AdvancedConfig(Environment env) {
this.env = env;
}

@ -193,7 +193,7 @@ class SpringBootServletInitializerTests {
@Configuration(proxyBeanMethods = false)
public static class WithErrorPageFilterNotRegistered extends SpringBootServletInitializer {
public WithErrorPageFilterNotRegistered() {
WithErrorPageFilterNotRegistered() {
setRegisterErrorPageFilter(false);
}

@ -61,7 +61,7 @@ class EmbeddedServerContainerInvocationContextProvider
private final Path tempDir;
public EmbeddedServerContainerInvocationContextProvider() throws IOException {
EmbeddedServerContainerInvocationContextProvider() throws IOException {
this.tempDir = Files.createTempDirectory("embedded-servlet-container-tests");
}
@ -99,7 +99,7 @@ class EmbeddedServerContainerInvocationContextProvider
private final AbstractApplicationLauncher launcher;
public EmbeddedServletContainerInvocationContext(String name, AbstractApplicationLauncher launcher) {
EmbeddedServletContainerInvocationContext(String name, AbstractApplicationLauncher launcher) {
this.name = name;
this.launcher = launcher;
}

@ -3,7 +3,6 @@
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<suppress files="[\\/]src[\\/]test[\\/]" checks="RedundantModifier" />
<suppress files="SpringApplicationTests\.java" checks="FinalClass" />
<suppress files=".+Configuration\.java" checks="HideUtilityClassConstructor" />
<suppress files=".+Application\.java" checks="HideUtilityClassConstructor" />
@ -38,4 +37,5 @@
<suppress files="RemoteUrlPropertyExtractorTests\.java" checks="IllegalImport" />
<suppress files="SampleLogbackApplication\.java" checks="IllegalImport" />
<suppress files="FlywayAutoConfigurationTests\.java" checks="IllegalImport" />
<suppress files="JerseyAutoConfigurationServletContainerTests" checks="RedundantModifier" />
</suppressions>

Loading…
Cancel
Save