Skip to content

Commit

Permalink
Merge branch '2.6.x' into 2.7.x
Browse files Browse the repository at this point in the history
Closes gh-31177
  • Loading branch information
wilkinsona committed May 26, 2022
2 parents b3a4982 + ee45fd2 commit 455ee0c
Show file tree
Hide file tree
Showing 70 changed files with 151 additions and 187 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.springframework.boot.build.classpath;

import java.io.IOException;
import java.util.TreeSet;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -52,7 +51,7 @@ public FileCollection getClasspath() {
}

@TaskAction
public void checkForProhibitedDependencies() throws IOException {
public void checkForProhibitedDependencies() {
TreeSet<String> prohibited = this.classpath.getResolvedConfiguration().getResolvedArtifacts().stream()
.map((artifact) -> artifact.getModuleVersion().getId()).filter(this::prohibited)
.map((id) -> id.getGroup() + ":" + id.getName()).collect(Collectors.toCollection(TreeSet::new));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class MavenExec extends JavaExec {

private File projectDir;

public MavenExec() throws IOException {
public MavenExec() {
setClasspath(mavenConfiguration(getProject()));
args("--batch-mode");
setMain("org.apache.maven.cli.MavenCli");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class BomPluginIntegrationTests {
private File buildFile;

@BeforeEach
void setup(@TempDir File projectDir) throws IOException {
void setup(@TempDir File projectDir) {
this.projectDir = projectDir;
this.buildFile = new File(this.projectDir, "build.gradle");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class OptionalDependenciesPluginIntegrationTests {
private File buildFile;

@BeforeEach
void setup(@TempDir File projectDir) throws IOException {
void setup(@TempDir File projectDir) {
this.projectDir = projectDir;
this.buildFile = new File(this.projectDir, "build.gradle");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ class TestFailuresPluginIntegrationTests {
private File projectDir;

@BeforeEach
void setup(@TempDir File projectDir) throws IOException {
void setup(@TempDir File projectDir) {
this.projectDir = projectDir;
}

@Test
void singleProject() throws IOException {
void singleProject() {
createProject(this.projectDir);
BuildResult result = GradleRunner.create().withDebug(true).withProjectDir(this.projectDir)
.withArguments("build").withPluginClasspath().buildAndFail();
Expand All @@ -59,7 +59,7 @@ void singleProject() throws IOException {
}

@Test
void multiProject() throws IOException {
void multiProject() {
createMultiProjectBuild();
BuildResult result = GradleRunner.create().withDebug(true).withProjectDir(this.projectDir)
.withArguments("build").withPluginClasspath().buildAndFail();
Expand All @@ -69,7 +69,7 @@ void multiProject() throws IOException {
}

@Test
void multiProjectContinue() throws IOException {
void multiProjectContinue() {
createMultiProjectBuild();
BuildResult result = GradleRunner.create().withDebug(true).withProjectDir(this.projectDir)
.withArguments("build", "--continue").withPluginClasspath().buildAndFail();
Expand All @@ -81,7 +81,7 @@ void multiProjectContinue() throws IOException {
}

@Test
void multiProjectParallel() throws IOException {
void multiProjectParallel() {
createMultiProjectBuild();
BuildResult result = GradleRunner.create().withDebug(true).withProjectDir(this.projectDir)
.withArguments("build", "--parallel", "--stacktrace").withPluginClasspath().buildAndFail();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ public AuditListener auditListener(AuditEventRepository auditEventRepository) {
@Bean
@ConditionalOnClass(name = "org.springframework.security.authentication.event.AbstractAuthenticationEvent")
@ConditionalOnMissingBean(AbstractAuthenticationAuditListener.class)
public AuthenticationAuditListener authenticationAuditListener() throws Exception {
public AuthenticationAuditListener authenticationAuditListener() {
return new AuthenticationAuditListener();
}

@Bean
@ConditionalOnClass(name = "org.springframework.security.access.event.AbstractAuthorizationEvent")
@ConditionalOnMissingBean(AbstractAuthorizationAuditListener.class)
public AuthorizationAuditListener authorizationAuditListener() throws Exception {
public AuthorizationAuditListener authorizationAuditListener() {
return new AuthorizationAuditListener();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,21 +240,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
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 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 @@ -249,7 +249,7 @@ void hikariDataSourceConfigurationPropertiesBeanCanBeSerialized() {

@Test
@SuppressWarnings("unchecked")
void endpointResponseUsesToStringOfCharSequenceAsPropertyValue() throws IOException {
void endpointResponseUsesToStringOfCharSequenceAsPropertyValue() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withInitializer((context) -> {
ConfigurableEnvironment environment = context.getEnvironment();
environment.getPropertySources().addFirst(new MapPropertySource("test",
Expand All @@ -267,7 +267,7 @@ void endpointResponseUsesToStringOfCharSequenceAsPropertyValue() throws IOExcept

@Test
@SuppressWarnings("unchecked")
void endpointResponseUsesPlaceholderForComplexValueAsPropertyValue() throws IOException {
void endpointResponseUsesPlaceholderForComplexValueAsPropertyValue() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withInitializer((context) -> {
ConfigurableEnvironment environment = context.getEnvironment();
environment.getPropertySources().addFirst(new MapPropertySource("test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void outcomeTagIsUnknownWhenResponseStatusIsInUnknownSeries() throws IOException
}

@Test
void clientNameTagIsHostOfRequestUri() throws IOException {
void clientNameTagIsHostOfRequestUri() {
ClientHttpRequest request = mock(ClientHttpRequest.class);
given(request.getURI()).willReturn(URI.create("https://example.org"));
Tag tag = RestTemplateExchangeTags.clientName(request);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 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 All @@ -16,8 +16,6 @@

package org.springframework.boot.autoconfigure.cache;

import java.io.IOException;

import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.spring.cache.HazelcastCacheManager;

Expand Down Expand Up @@ -50,8 +48,8 @@
class HazelcastCacheConfiguration {

@Bean
HazelcastCacheManager cacheManager(CacheManagerCustomizers customizers, HazelcastInstance existingHazelcastInstance)
throws IOException {
HazelcastCacheManager cacheManager(CacheManagerCustomizers customizers,
HazelcastInstance existingHazelcastInstance) {
HazelcastCacheManager cacheManager = new HazelcastCacheManager(existingHazelcastInstance);
return customizers.customize(cacheManager);
}
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 @@ -65,8 +65,8 @@ org.apache.activemq.artemis.core.config.Configuration artemisConfiguration() {
@Bean(initMethod = "start", destroyMethod = "stop")
@ConditionalOnMissingBean
EmbeddedActiveMQ embeddedActiveMq(org.apache.activemq.artemis.core.config.Configuration configuration,
JMSConfiguration jmsConfiguration, ObjectProvider<ArtemisConfigurationCustomizer> configurationCustomizers)
throws Exception {
JMSConfiguration jmsConfiguration,
ObjectProvider<ArtemisConfigurationCustomizer> configurationCustomizers) {
for (JMSQueueConfiguration queueConfiguration : jmsConfiguration.getQueueConfigurations()) {
String queueName = queueConfiguration.getName();
configuration.addAddressConfiguration(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private void setSchema(InMemoryDirectoryServerConfig config, Resource resource)
}
}

private void importLdif(ApplicationContext applicationContext) throws LDAPException {
private void importLdif(ApplicationContext applicationContext) {
String location = this.embeddedProperties.getLdif();
if (StringUtils.hasText(location)) {
try {
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 @@ -82,7 +82,7 @@ private String getLogBaseDir(JtaProperties jtaProperties) {

@Bean(initMethod = "init", destroyMethod = "close")
@ConditionalOnMissingBean(TransactionManager.class)
UserTransactionManager atomikosTransactionManager(UserTransactionService userTransactionService) throws Exception {
UserTransactionManager atomikosTransactionManager(UserTransactionService userTransactionService) {
UserTransactionManager manager = new UserTransactionManager();
manager.setStartupTransactionService(false);
manager.setForceShutdown(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 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 @@ -77,8 +77,7 @@ private void ensureWebSocketComponents(Server server, ServletContext servletCont
ReflectionUtils.invokeMethod(ensureWebSocketComponents, null, server, servletContext);
}

private void ensureContainer(Class<?> container, ServletContext servletContext)
throws ClassNotFoundException {
private void ensureContainer(Class<?> container, ServletContext servletContext) {
Method ensureContainer = ReflectionUtils.findMethod(container, "ensureContainer", ServletContext.class);
ReflectionUtils.invokeMethod(ensureContainer, null, servletContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void getSettingsWithPlatformDoesNotTouchDataSource() {
@ParameterizedTest
@EnumSource(value = DatabaseDriver.class, mode = Mode.EXCLUDE, names = { "FIREBIRD", "GAE", "HANA", "INFORMIX",
"JTDS", "PHOENIX", "REDSHIFT", "TERADATA", "TESTCONTAINERS", "UNKNOWN" })
void batchSchemaCanBeLocated(DatabaseDriver driver) throws IOException, SQLException {
void batchSchemaCanBeLocated(DatabaseDriver driver) throws SQLException {
DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
BatchProperties properties = new BatchProperties();
DataSource dataSource = mock(DataSource.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Mono<Book> getBookdById(String id) {
static class SecurityConfig {

@Bean
SecurityWebFilterChain springWebFilterChain(ServerHttpSecurity http) throws Exception {
SecurityWebFilterChain springWebFilterChain(ServerHttpSecurity http) {
return http.csrf((spec) -> spec.disable())
// Demonstrate that method security works
// Best practice to use both for defense in depth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.springframework.boot.autoconfigure.jmx;

import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;

import org.junit.jupiter.api.Test;
Expand All @@ -38,7 +37,7 @@ class ParentAwareNamingStrategyTests {
private ApplicationContextRunner contextRunner = new ApplicationContextRunner();

@Test
void objectNameMatchesManagedResourceByDefault() throws MalformedObjectNameException {
void objectNameMatchesManagedResourceByDefault() {
this.contextRunner.withBean("testManagedResource", TestManagedResource.class).run((context) -> {
ParentAwareNamingStrategy strategy = new ParentAwareNamingStrategy(new AnnotationJmxAttributeSource());
strategy.setApplicationContext(context);
Expand All @@ -48,7 +47,7 @@ void objectNameMatchesManagedResourceByDefault() throws MalformedObjectNameExcep
}

@Test
void uniqueObjectNameAddsIdentityProperty() throws MalformedObjectNameException {
void uniqueObjectNameAddsIdentityProperty() {
this.contextRunner.withBean("testManagedResource", TestManagedResource.class).run((context) -> {
ParentAwareNamingStrategy strategy = new ParentAwareNamingStrategy(new AnnotationJmxAttributeSource());
strategy.setApplicationContext(context);
Expand All @@ -62,7 +61,7 @@ void uniqueObjectNameAddsIdentityProperty() throws MalformedObjectNameException
}

@Test
void sameBeanInParentContextAddsContextProperty() throws MalformedObjectNameException {
void sameBeanInParentContextAddsContextProperty() {
this.contextRunner.withBean("testManagedResource", TestManagedResource.class).run((parent) -> this.contextRunner
.withBean("testManagedResource", TestManagedResource.class).withParent(parent).run((context) -> {
ParentAwareNamingStrategy strategy = new ParentAwareNamingStrategy(
Expand All @@ -77,7 +76,7 @@ void sameBeanInParentContextAddsContextProperty() throws MalformedObjectNameExce
}

@Test
void uniqueObjectNameAndSameBeanInParentContextOnlyAddsIdentityProperty() throws MalformedObjectNameException {
void uniqueObjectNameAndSameBeanInParentContextOnlyAddsIdentityProperty() {
this.contextRunner.withBean("testManagedResource", TestManagedResource.class).run((parent) -> this.contextRunner
.withBean("testManagedResource", TestManagedResource.class).withParent(parent).run((context) -> {
ParentAwareNamingStrategy strategy = new ParentAwareNamingStrategy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ static class CustomDriverConfiguration {
private String name = UUID.randomUUID().toString();

@Bean
SimpleDriverDataSource dataSource() throws SQLException {
SimpleDriverDataSource dataSource() {
SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
dataSource.setDriverClass(CustomH2Driver.class);
dataSource.setUrl(String.format("jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false", this.name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void tomcatMinSpareThreadsMatchesProtocolDefault() throws Exception {
}

@Test
void tomcatMaxHttpPostSizeMatchesConnectorDefault() throws Exception {
void tomcatMaxHttpPostSizeMatchesConnectorDefault() {
assertThat(this.properties.getTomcat().getMaxHttpFormPostSize().toBytes())
.isEqualTo(getDefaultConnector().getMaxPostSize());
}
Expand All @@ -384,13 +384,13 @@ void tomcatBackgroundProcessorDelayMatchesEngineDefault() {
}

@Test
void tomcatMaxHttpFormPostSizeMatchesConnectorDefault() throws Exception {
void tomcatMaxHttpFormPostSizeMatchesConnectorDefault() {
assertThat(this.properties.getTomcat().getMaxHttpFormPostSize().toBytes())
.isEqualTo(getDefaultConnector().getMaxPostSize());
}

@Test
void tomcatUriEncodingMatchesConnectorDefault() throws Exception {
void tomcatUriEncodingMatchesConnectorDefault() {
assertThat(this.properties.getTomcat().getUriEncoding().name())
.isEqualTo(getDefaultConnector().getURIEncoding());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.eclipse.aether.graph.Dependency;
import org.eclipse.aether.graph.Exclusion;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.resolution.ArtifactResolutionException;
import org.eclipse.aether.resolution.ArtifactResult;
import org.eclipse.aether.resolution.DependencyRequest;
import org.eclipse.aether.resolution.DependencyResult;
Expand Down Expand Up @@ -119,7 +118,7 @@ public Object grab(Map args, Map... dependencyMaps) {
classLoader.addURL(file.toURI().toURL());
}
}
catch (ArtifactResolutionException | MalformedURLException ex) {
catch (MalformedURLException ex) {
throw new DependencyResolutionFailedException(ex);
}
return null;
Expand Down Expand Up @@ -286,7 +285,7 @@ public URI[] resolve(Map args, List depsInfo, Map... dependencyMaps) {
}
}

private List<File> resolve(List<Dependency> dependencies) throws ArtifactResolutionException {
private List<File> resolve(List<Dependency> dependencies) {
try {
CollectRequest collectRequest = getCollectRequest(dependencies);
DependencyRequest dependencyRequest = getDependencyRequest(collectRequest);
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 All @@ -17,7 +17,6 @@
package org.springframework.boot.devtools.tests;

import java.io.File;
import java.io.IOException;

import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.client.StandardHttpRequestRetryHandler;
Expand Down Expand Up @@ -153,7 +152,7 @@ void createAControllerAndThenDeleteIt(ApplicationLauncher applicationLauncher) t
.isEqualTo(HttpStatus.NOT_FOUND);
}

static Object[] parameters() throws IOException {
static Object[] parameters() {
Directories directories = new Directories(buildOutput, temp);
return new Object[] { new Object[] { new LocalApplicationLauncher(directories) },
new Object[] { new ExplodedRemoteApplicationLauncher(directories) },
Expand Down

0 comments on commit 455ee0c

Please sign in to comment.