mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-05 00:56:58 +08:00
Merge branch '2.7.x'
This commit is contained in:
commit
4bb5ba2bd0
@ -28,6 +28,7 @@ import java.util.Map;
|
||||
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.Task;
|
||||
import org.gradle.api.file.DirectoryProperty;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.OutputDirectory;
|
||||
|
@ -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.
|
||||
|
@ -44,21 +44,11 @@ public class GangliaProperties {
|
||||
*/
|
||||
private Duration step = Duration.ofMinutes(1);
|
||||
|
||||
/**
|
||||
* Base time unit used to report rates.
|
||||
*/
|
||||
private TimeUnit rateUnits;
|
||||
|
||||
/**
|
||||
* Base time unit used to report durations.
|
||||
*/
|
||||
private TimeUnit durationUnits = TimeUnit.MILLISECONDS;
|
||||
|
||||
/**
|
||||
* Ganglia protocol version. Must be either 3.1 or 3.0.
|
||||
*/
|
||||
private String protocolVersion;
|
||||
|
||||
/**
|
||||
* UDP addressing mode, either unicast or multicast.
|
||||
*/
|
||||
|
@ -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.
|
||||
@ -62,6 +62,7 @@ class CompositeHandlerAdapter implements HandlerAdapter {
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public long getLastModified(HttpServletRequest request, Object handler) {
|
||||
Optional<HandlerAdapter> adapter = getAdapter(handler);
|
||||
return adapter.map((handlerAdapter) -> handlerAdapter.getLastModified(request, handler)).orElse(0L);
|
||||
|
@ -124,26 +124,27 @@ class MvcWebEndpointIntegrationTests
|
||||
private RequestMatchResult getMatchResult(String servletPath, boolean isPatternParser) {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.setServletPath(servletPath);
|
||||
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext();
|
||||
if (isPatternParser) {
|
||||
context.register(WebMvcConfiguration.class);
|
||||
try (AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext()) {
|
||||
if (isPatternParser) {
|
||||
context.register(WebMvcConfiguration.class);
|
||||
}
|
||||
else {
|
||||
context.register(PathMatcherWebMvcConfiguration.class);
|
||||
}
|
||||
context.register(TestEndpointConfiguration.class);
|
||||
context.refresh();
|
||||
WebMvcEndpointHandlerMapping bean = context.getBean(WebMvcEndpointHandlerMapping.class);
|
||||
try {
|
||||
// Setup request attributes
|
||||
ServletRequestPathUtils.parseAndCache(request);
|
||||
// Trigger initLookupPath
|
||||
bean.getHandler(request);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
return bean.match(request, "/spring");
|
||||
}
|
||||
else {
|
||||
context.register(PathMatcherWebMvcConfiguration.class);
|
||||
}
|
||||
context.register(TestEndpointConfiguration.class);
|
||||
context.refresh();
|
||||
WebMvcEndpointHandlerMapping bean = context.getBean(WebMvcEndpointHandlerMapping.class);
|
||||
try {
|
||||
// Setup request attributes
|
||||
ServletRequestPathUtils.parseAndCache(request);
|
||||
// Trigger initLookupPath
|
||||
bean.getHandler(request);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
return bean.match(request, "/spring");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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.
|
||||
@ -17,10 +17,11 @@
|
||||
package org.springframework.boot.autoconfigure.data.redis;
|
||||
|
||||
import io.lettuce.core.resource.ClientResources;
|
||||
import io.lettuce.core.resource.ClientResources.Builder;
|
||||
|
||||
/**
|
||||
* Callback interface that can be implemented by beans wishing to customize the
|
||||
* {@link ClientResources} via a {@link ClientResources.Builder} whilst retaining default
|
||||
* {@link ClientResources} via a {@link Builder} whilst retaining default
|
||||
* auto-configuration.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
@ -29,9 +30,9 @@ import io.lettuce.core.resource.ClientResources;
|
||||
public interface ClientResourcesBuilderCustomizer {
|
||||
|
||||
/**
|
||||
* Customize the {@link ClientResources.Builder}.
|
||||
* Customize the {@link Builder}.
|
||||
* @param clientResourcesBuilder the builder to customize
|
||||
*/
|
||||
void customize(ClientResources.Builder clientResourcesBuilder);
|
||||
void customize(Builder clientResourcesBuilder);
|
||||
|
||||
}
|
||||
|
@ -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.
|
||||
@ -17,6 +17,7 @@
|
||||
package org.springframework.boot.autoconfigure.elasticsearch;
|
||||
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.config.RequestConfig.Builder;
|
||||
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
|
||||
import org.elasticsearch.client.RestClientBuilder;
|
||||
|
||||
@ -52,11 +53,11 @@ public interface RestClientBuilderCustomizer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Customize the {@link RequestConfig.Builder}.
|
||||
* Customize the {@link Builder}.
|
||||
* @param builder the builder
|
||||
* @since 2.3.0
|
||||
*/
|
||||
default void customize(RequestConfig.Builder builder) {
|
||||
default void customize(Builder builder) {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -325,10 +325,6 @@ public class FlywayAutoConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
private String normalizePrefix(String location) {
|
||||
return location.replace("filesystem:", "file:");
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public FlywayMigrationInitializer flywayInitializer(Flyway flyway,
|
||||
|
@ -48,13 +48,6 @@ public class FlywayProperties {
|
||||
*/
|
||||
private boolean enabled = true;
|
||||
|
||||
/**
|
||||
* Whether to check that migration scripts location exists. Should be set to false
|
||||
* when using a wildcard location or a remote-hosted location such as S3 or GCS.
|
||||
*/
|
||||
@Deprecated
|
||||
private boolean checkLocation = true;
|
||||
|
||||
/**
|
||||
* Whether to fail if a location of migration scripts doesn't exist.
|
||||
*/
|
||||
|
@ -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.
|
||||
@ -28,15 +28,15 @@ import org.springframework.boot.r2dbc.EmbeddedDatabaseConnection;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Initialize a {@link ConnectionFactoryOptions.Builder} based on {@link R2dbcProperties}.
|
||||
* Initialize a {@link Builder} based on {@link R2dbcProperties}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
class ConnectionFactoryOptionsInitializer {
|
||||
|
||||
/**
|
||||
* Initialize a {@link io.r2dbc.spi.ConnectionFactoryOptions.Builder
|
||||
* ConnectionFactoryOptions.Builder} using the specified properties.
|
||||
* Initialize a {@link Builder ConnectionFactoryOptions.Builder} using the specified
|
||||
* properties.
|
||||
* @param properties the properties to use to initialize the builder
|
||||
* @param embeddedDatabaseConnection the embedded connection to use as a fallback
|
||||
* @return an initialized builder
|
||||
|
@ -157,7 +157,7 @@ class ReactiveOAuth2ResourceServerAutoConfigurationTests {
|
||||
.getBean(SupplierReactiveJwtDecoder.class);
|
||||
Mono<ReactiveJwtDecoder> reactiveJwtDecoderSupplier = (Mono<ReactiveJwtDecoder>) ReflectionTestUtils
|
||||
.getField(supplierReactiveJwtDecoder, "jwtDecoderMono");
|
||||
ReactiveJwtDecoder reactiveJwtDecoder = reactiveJwtDecoderSupplier.block(TIMEOUT);
|
||||
reactiveJwtDecoderSupplier.block(TIMEOUT);
|
||||
});
|
||||
// The last request is to the JWK Set endpoint to look up the algorithm
|
||||
assertThat(this.server.getRequestCount()).isEqualTo(1);
|
||||
@ -180,7 +180,7 @@ class ReactiveOAuth2ResourceServerAutoConfigurationTests {
|
||||
.getBean(SupplierReactiveJwtDecoder.class);
|
||||
Mono<ReactiveJwtDecoder> reactiveJwtDecoderSupplier = (Mono<ReactiveJwtDecoder>) ReflectionTestUtils
|
||||
.getField(supplierReactiveJwtDecoder, "jwtDecoderMono");
|
||||
ReactiveJwtDecoder reactiveJwtDecoder = reactiveJwtDecoderSupplier.block(TIMEOUT);
|
||||
reactiveJwtDecoderSupplier.block(TIMEOUT);
|
||||
});
|
||||
// The last request is to the JWK Set endpoint to look up the algorithm
|
||||
assertThat(this.server.getRequestCount()).isEqualTo(2);
|
||||
@ -203,7 +203,7 @@ class ReactiveOAuth2ResourceServerAutoConfigurationTests {
|
||||
.getBean(SupplierReactiveJwtDecoder.class);
|
||||
Mono<ReactiveJwtDecoder> reactiveJwtDecoderSupplier = (Mono<ReactiveJwtDecoder>) ReflectionTestUtils
|
||||
.getField(supplierReactiveJwtDecoder, "jwtDecoderMono");
|
||||
ReactiveJwtDecoder reactiveJwtDecoder = reactiveJwtDecoderSupplier.block(TIMEOUT);
|
||||
reactiveJwtDecoderSupplier.block(TIMEOUT);
|
||||
});
|
||||
// The last request is to the JWK Set endpoint to look up the algorithm
|
||||
assertThat(this.server.getRequestCount()).isEqualTo(3);
|
||||
@ -420,7 +420,6 @@ class ReactiveOAuth2ResourceServerAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
void autoConfigurationShouldConfigureIssuerAndAudienceJwtValidatorIfPropertyProvided() throws Exception {
|
||||
this.server = new MockWebServer();
|
||||
@ -490,7 +489,6 @@ class ReactiveOAuth2ResourceServerAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
void autoConfigurationShouldConfigureAudienceValidatorIfPropertyProvidedAndPublicKey() throws Exception {
|
||||
this.server = new MockWebServer();
|
||||
|
@ -149,7 +149,7 @@ class OAuth2ResourceServerAutoConfigurationTests {
|
||||
SupplierJwtDecoder supplierJwtDecoderBean = context.getBean(SupplierJwtDecoder.class);
|
||||
Supplier<JwtDecoder> jwtDecoderSupplier = (Supplier<JwtDecoder>) ReflectionTestUtils
|
||||
.getField(supplierJwtDecoderBean, "jwtDecoderSupplier");
|
||||
JwtDecoder jwtDecoder = jwtDecoderSupplier.get();
|
||||
jwtDecoderSupplier.get();
|
||||
});
|
||||
// The last request is to the JWK Set endpoint to look up the algorithm
|
||||
assertThat(this.server.getRequestCount()).isEqualTo(2);
|
||||
@ -171,7 +171,7 @@ class OAuth2ResourceServerAutoConfigurationTests {
|
||||
SupplierJwtDecoder supplierJwtDecoderBean = context.getBean(SupplierJwtDecoder.class);
|
||||
Supplier<JwtDecoder> jwtDecoderSupplier = (Supplier<JwtDecoder>) ReflectionTestUtils
|
||||
.getField(supplierJwtDecoderBean, "jwtDecoderSupplier");
|
||||
JwtDecoder jwtDecoder = jwtDecoderSupplier.get();
|
||||
jwtDecoderSupplier.get();
|
||||
});
|
||||
// The last request is to the JWK Set endpoint to look up the algorithm
|
||||
assertThat(this.server.getRequestCount()).isEqualTo(3);
|
||||
@ -194,7 +194,7 @@ class OAuth2ResourceServerAutoConfigurationTests {
|
||||
SupplierJwtDecoder supplierJwtDecoderBean = context.getBean(SupplierJwtDecoder.class);
|
||||
Supplier<JwtDecoder> jwtDecoderSupplier = (Supplier<JwtDecoder>) ReflectionTestUtils
|
||||
.getField(supplierJwtDecoderBean, "jwtDecoderSupplier");
|
||||
JwtDecoder jwtDecoder = jwtDecoderSupplier.get();
|
||||
jwtDecoderSupplier.get();
|
||||
});
|
||||
// The last request is to the JWK Set endpoint to look up the algorithm
|
||||
assertThat(this.server.getRequestCount()).isEqualTo(4);
|
||||
@ -433,7 +433,6 @@ class OAuth2ResourceServerAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
void autoConfigurationShouldConfigureAudienceAndIssuerJwtValidatorIfPropertyProvided() throws Exception {
|
||||
this.server = new MockWebServer();
|
||||
@ -502,7 +501,6 @@ class OAuth2ResourceServerAutoConfigurationTests {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
void autoConfigurationShouldConfigureAudienceValidatorIfPropertyProvidedAndPublicKey() throws Exception {
|
||||
this.server = new MockWebServer();
|
||||
|
@ -280,9 +280,11 @@ class Saml2RelyingPartyAutoConfigurationTests {
|
||||
|
||||
private void setupMockResponse(MockWebServer server, Resource resourceBody) throws Exception {
|
||||
try (InputStream metadataSource = resourceBody.getInputStream()) {
|
||||
Buffer metadataBuffer = new Buffer().readFrom(metadataSource);
|
||||
MockResponse metadataResponse = new MockResponse().setBody(metadataBuffer);
|
||||
server.enqueue(metadataResponse);
|
||||
try (Buffer metadataBuffer = new Buffer()) {
|
||||
metadataBuffer.readFrom(metadataSource);
|
||||
MockResponse metadataResponse = new MockResponse().setBody(metadataBuffer);
|
||||
server.enqueue(metadataResponse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
@ -17,8 +17,6 @@
|
||||
package org.springframework.boot.autoconfigure.web.reactive;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@ -44,9 +42,6 @@ class ReactiveMultipartAutoConfigurationTests {
|
||||
private final ReactiveWebApplicationContextRunner contextRunner = new ReactiveWebApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(ReactiveMultipartAutoConfiguration.class));
|
||||
|
||||
private static final Path DEFAULT_FILE_STORAGE_DIRECTORY = Paths.get(System.getProperty("java.io.tmpdir"),
|
||||
"spring-multipart");
|
||||
|
||||
@Test
|
||||
void shouldNotProvideCustomizerForNonReactiveApp() {
|
||||
new WebApplicationContextRunner()
|
||||
|
@ -838,6 +838,7 @@ class WebMvcAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
void useSuffixPatternMatch() {
|
||||
this.contextRunner.withPropertyValues("spring.mvc.pathmatch.matching-strategy=ant-path-matcher",
|
||||
"spring.mvc.pathmatch.use-suffix-pattern:true",
|
||||
|
@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Tests for {@link AetherGrapeEngine}.
|
||||
* Tests for {@link MavenResolverGrapeEngine}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
|
@ -25,6 +25,7 @@ import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
public class MyDemoBean implements ApplicationListener<ApplicationStartedEvent> {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private ServletContext servletContext;
|
||||
|
||||
@Override
|
||||
|
@ -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.
|
||||
@ -28,12 +28,15 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
/**
|
||||
* Tests for {@link MockBean} with abstract class and generics.
|
||||
*
|
||||
* @param <T> type of thing
|
||||
* @param <U> type of something
|
||||
* @author Madhura Bhave
|
||||
*/
|
||||
@SpringBootTest(classes = AbstractMockBeanOnGenericTests.TestConfiguration.class)
|
||||
abstract class AbstractMockBeanOnGenericTests<T extends AbstractMockBeanOnGenericTests.Thing<U>, U extends AbstractMockBeanOnGenericTests.Something> {
|
||||
|
||||
@Autowired
|
||||
@SuppressWarnings("unused")
|
||||
private T thing;
|
||||
|
||||
@MockBean
|
||||
|
@ -451,11 +451,6 @@ public class DockerApi {
|
||||
}
|
||||
}
|
||||
|
||||
String getCapturedDigest() {
|
||||
Assert.hasText(this.digest, "No digest found");
|
||||
return this.digest;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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.
|
||||
@ -59,7 +59,8 @@ public class InspectedContent implements Content {
|
||||
FileCopyUtils.copy((byte[]) this.content, outputStream);
|
||||
}
|
||||
else if (this.content instanceof File) {
|
||||
FileCopyUtils.copy(new FileInputStream((File) this.content), outputStream);
|
||||
InputStream inputStream = new FileInputStream((File) this.content);
|
||||
FileCopyUtils.copy(inputStream, outputStream);
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("Unknown content type");
|
||||
|
@ -163,7 +163,6 @@ final class JavaPluginAction implements PluginApplicationAction {
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void configureArtifactPublication(TaskProvider<BootJar> bootJar) {
|
||||
this.singlePublishedArtifact.addJarCandidate(bootJar);
|
||||
}
|
||||
|
@ -105,7 +105,6 @@ class WarPluginAction implements PluginApplicationAction {
|
||||
.configure((buildImage) -> buildImage.getArchiveFile().set(bootWar.get().getArchiveFile()));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void configureArtifactPublication(TaskProvider<BootWar> bootWar) {
|
||||
this.singlePublishedArtifact.addWarCandidate(bootWar);
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public class Repackager extends Packager {
|
||||
public void repackage(File destination, Libraries libraries, LaunchScript launchScript, FileTime lastModifiedTime)
|
||||
throws IOException {
|
||||
Assert.isTrue(destination != null && !destination.isDirectory(), "Invalid destination");
|
||||
Layout layout = getLayout(); // get layout early
|
||||
getLayout(); // get layout early
|
||||
destination = destination.getAbsoluteFile();
|
||||
File source = getSource();
|
||||
if (isAlreadyPackaged() && source.equals(destination)) {
|
||||
|
@ -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.
|
||||
@ -24,7 +24,6 @@ import sun.misc.Signal;
|
||||
* @author Dave Syer
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public final class SignalUtils {
|
||||
|
||||
private static final Signal SIG_INT = new Signal("INT");
|
||||
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.context.config;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.MutablePropertySources;
|
||||
import org.springframework.core.env.PropertySource;
|
||||
|
||||
/**
|
||||
* Internal {@link PropertySource} implementation used by
|
||||
* {@link ConfigFileApplicationListener} to filter out properties for specific operations.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class FilteredPropertySource extends PropertySource<PropertySource<?>> {
|
||||
|
||||
private final Set<String> filteredProperties;
|
||||
|
||||
FilteredPropertySource(PropertySource<?> original, Set<String> filteredProperties) {
|
||||
super(original.getName(), original);
|
||||
this.filteredProperties = filteredProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getProperty(String name) {
|
||||
if (this.filteredProperties.contains(name)) {
|
||||
return null;
|
||||
}
|
||||
return getSource().getProperty(name);
|
||||
}
|
||||
|
||||
static void apply(ConfigurableEnvironment environment, String propertySourceName, Set<String> filteredProperties,
|
||||
Consumer<PropertySource<?>> operation) {
|
||||
MutablePropertySources propertySources = environment.getPropertySources();
|
||||
PropertySource<?> original = propertySources.get(propertySourceName);
|
||||
if (original == null) {
|
||||
operation.accept(null);
|
||||
return;
|
||||
}
|
||||
propertySources.replace(propertySourceName, new FilteredPropertySource(original, filteredProperties));
|
||||
try {
|
||||
operation.accept(original);
|
||||
}
|
||||
finally {
|
||||
propertySources.replace(propertySourceName, original);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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.
|
||||
@ -149,12 +149,9 @@ public class ValidationBindHandler extends AbstractBindHandler {
|
||||
|
||||
private final ConfigurationPropertyName name;
|
||||
|
||||
private final Object target;
|
||||
|
||||
protected ValidationResult(ConfigurationPropertyName name, Object target) {
|
||||
super(target, null);
|
||||
this.name = name;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,103 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.context.config;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.MapPropertySource;
|
||||
import org.springframework.core.env.PropertySource;
|
||||
import org.springframework.mock.env.MockEnvironment;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link FilteredPropertySource}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class FilteredPropertySourceTests {
|
||||
|
||||
@Test
|
||||
void applyWhenHasNoSourceShouldRunOperation() {
|
||||
ConfigurableEnvironment environment = new MockEnvironment();
|
||||
TestOperation operation = new TestOperation();
|
||||
FilteredPropertySource.apply(environment, "test", Collections.emptySet(), operation);
|
||||
assertThat(operation.isCalled()).isTrue();
|
||||
assertThat(operation.getOriginal()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void applyWhenHasSourceShouldRunWithReplacedSource() {
|
||||
ConfigurableEnvironment environment = new MockEnvironment();
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("regular", "regularValue");
|
||||
map.put("filtered", "filteredValue");
|
||||
PropertySource<?> propertySource = new MapPropertySource("test", map);
|
||||
environment.getPropertySources().addFirst(propertySource);
|
||||
TestOperation operation = new TestOperation(() -> {
|
||||
assertThat(environment.containsProperty("regular")).isTrue();
|
||||
assertThat(environment.containsProperty("filtered")).isFalse();
|
||||
});
|
||||
FilteredPropertySource.apply(environment, "test", Collections.singleton("filtered"), operation);
|
||||
assertThat(operation.isCalled()).isTrue();
|
||||
assertThat(operation.getOriginal()).isSameAs(propertySource);
|
||||
assertThat(environment.getPropertySources().get("test")).isSameAs(propertySource);
|
||||
|
||||
}
|
||||
|
||||
static class TestOperation implements Consumer<PropertySource<?>> {
|
||||
|
||||
private boolean called;
|
||||
|
||||
private PropertySource<?> original;
|
||||
|
||||
private Runnable operation;
|
||||
|
||||
TestOperation() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
TestOperation(Runnable operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(PropertySource<?> original) {
|
||||
this.called = true;
|
||||
this.original = original;
|
||||
if (this.operation != null) {
|
||||
this.operation.run();
|
||||
}
|
||||
}
|
||||
|
||||
boolean isCalled() {
|
||||
return this.called;
|
||||
}
|
||||
|
||||
PropertySource<?> getOriginal() {
|
||||
return this.original;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -476,7 +476,6 @@ class ConfigurationPropertiesTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
void loadWhenEnvironmentPrefixSetShouldBind() {
|
||||
MutablePropertySources sources = this.context.getEnvironment().getPropertySources();
|
||||
sources.replace(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME,
|
||||
|
@ -456,6 +456,7 @@ class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests {
|
||||
*/
|
||||
static class Nested {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static final Log logger = LogFactory.getLog(Nested.class);
|
||||
|
||||
}
|
||||
|
@ -81,7 +81,8 @@ class PaketoBuilderTests {
|
||||
ImageReference imageReference = ImageReference.of(ImageName.of(imageName));
|
||||
BuildResult result = buildImage(imageName);
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (GenericContainer<?> container = new GenericContainer<>(imageName).withExposedPorts(8080)) {
|
||||
try (GenericContainer<?> container = new GenericContainer<>(imageName)) {
|
||||
container.withExposedPorts(8080);
|
||||
container.waitingFor(Wait.forHttp("/test")).start();
|
||||
ContainerConfig config = container.getContainerInfo().getConfig();
|
||||
assertLabelsMatchManifestAttributes(config);
|
||||
@ -109,8 +110,9 @@ class PaketoBuilderTests {
|
||||
ImageReference imageReference = ImageReference.of(ImageName.of(imageName));
|
||||
BuildResult result = buildImage(imageName);
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (GenericContainer<?> container = new GenericContainer<>(imageName).withCommand("--server.port=9090")
|
||||
.withExposedPorts(9090)) {
|
||||
try (GenericContainer<?> container = new GenericContainer<>(imageName)) {
|
||||
container.withCommand("--server.port=9090");
|
||||
container.withExposedPorts(9090);
|
||||
container.waitingFor(Wait.forHttp("/test")).start();
|
||||
}
|
||||
finally {
|
||||
@ -125,14 +127,16 @@ class PaketoBuilderTests {
|
||||
ImageReference imageReference = ImageReference.of(ImageName.of(imageName));
|
||||
BuildResult result = buildImage(imageName);
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (GenericContainer<?> container = new GenericContainer<>(imageName).withExposedPorts(8080)) {
|
||||
try (GenericContainer<?> container = new GenericContainer<>(imageName)) {
|
||||
container.withExposedPorts(8080);
|
||||
container.waitingFor(Wait.forHttp("/test")).start();
|
||||
container.stop();
|
||||
}
|
||||
this.gradleBuild.expectDeprecationMessages("BOM table is deprecated");
|
||||
result = buildImage(imageName);
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (GenericContainer<?> container = new GenericContainer<>(imageName).withExposedPorts(8080)) {
|
||||
try (GenericContainer<?> container = new GenericContainer<>(imageName)) {
|
||||
container.withExposedPorts(8080);
|
||||
container.waitingFor(Wait.forHttp("/test")).start();
|
||||
}
|
||||
finally {
|
||||
@ -148,7 +152,8 @@ class PaketoBuilderTests {
|
||||
ImageReference imageReference = ImageReference.of(ImageName.of(imageName));
|
||||
BuildResult result = buildImage(imageName, "assemble", "bootDistZip");
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (GenericContainer<?> container = new GenericContainer<>(imageName).withExposedPorts(8080)) {
|
||||
try (GenericContainer<?> container = new GenericContainer<>(imageName)) {
|
||||
container.withExposedPorts(8080);
|
||||
container.waitingFor(Wait.forHttp("/test")).start();
|
||||
ContainerConfig config = container.getContainerInfo().getConfig();
|
||||
ImageAssertions.assertThat(config).buildMetadata((metadata) -> {
|
||||
@ -181,7 +186,8 @@ class PaketoBuilderTests {
|
||||
ImageReference imageReference = ImageReference.of(ImageName.of(imageName));
|
||||
BuildResult result = buildImage(imageName, "assemble", "bootDistZip");
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (GenericContainer<?> container = new GenericContainer<>(imageName).withExposedPorts(8080)) {
|
||||
try (GenericContainer<?> container = new GenericContainer<>(imageName)) {
|
||||
container.withExposedPorts(8080);
|
||||
container.waitingFor(Wait.forHttp("/test")).start();
|
||||
ContainerConfig config = container.getContainerInfo().getConfig();
|
||||
ImageAssertions.assertThat(config).buildMetadata((metadata) -> {
|
||||
@ -216,7 +222,8 @@ class PaketoBuilderTests {
|
||||
ImageReference imageReference = ImageReference.of(ImageName.of(imageName));
|
||||
BuildResult result = buildImage(imageName);
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (GenericContainer<?> container = new GenericContainer<>(imageName).withExposedPorts(8080)) {
|
||||
try (GenericContainer<?> container = new GenericContainer<>(imageName)) {
|
||||
container.withExposedPorts(8080);
|
||||
container.waitingFor(Wait.forHttp("/test")).start();
|
||||
ContainerConfig config = container.getContainerInfo().getConfig();
|
||||
assertLabelsMatchManifestAttributes(config);
|
||||
@ -245,7 +252,8 @@ class PaketoBuilderTests {
|
||||
ImageReference imageReference = ImageReference.of(ImageName.of(imageName));
|
||||
BuildResult result = buildImage(imageName);
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (GenericContainer<?> container = new GenericContainer<>(imageName).withExposedPorts(8080)) {
|
||||
try (GenericContainer<?> container = new GenericContainer<>(imageName)) {
|
||||
container.withExposedPorts(8080);
|
||||
container.waitingFor(Wait.forHttp("/test")).start();
|
||||
ContainerConfig config = container.getContainerInfo().getConfig();
|
||||
ImageAssertions.assertThat(config).buildMetadata((metadata) -> {
|
||||
|
@ -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.
|
||||
@ -26,6 +26,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@ -81,12 +82,13 @@ class SampleSessionHazelcastApplicationTests {
|
||||
return "Basic " + Base64.getEncoder().encodeToString("user:password".getBytes());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private ResponseEntity<Map<String, Object>> getSessions() {
|
||||
HttpHeaders headers = getHeaders(null);
|
||||
RequestEntity<Object> request = new RequestEntity<>(headers, HttpMethod.GET,
|
||||
URI.create("/actuator/sessions?username=user"));
|
||||
return (ResponseEntity<Map<String, Object>>) (ResponseEntity) this.restTemplate.exchange(request, Map.class);
|
||||
ParameterizedTypeReference<Map<String, Object>> stringObjectMap = new ParameterizedTypeReference<Map<String, Object>>() {
|
||||
};
|
||||
return this.restTemplate.exchange(request, stringObjectMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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.
|
||||
@ -26,6 +26,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@ -94,12 +95,13 @@ class SampleSessionJdbcApplicationTests {
|
||||
return "Basic " + Base64.getEncoder().encodeToString("user:password".getBytes());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private ResponseEntity<Map<String, Object>> getSessions() {
|
||||
HttpHeaders headers = getHeaders(null);
|
||||
RequestEntity<Object> request = new RequestEntity<>(headers, HttpMethod.GET,
|
||||
URI.create("/actuator/sessions?username=user"));
|
||||
return (ResponseEntity<Map<String, Object>>) (ResponseEntity) this.restTemplate.exchange(request, Map.class);
|
||||
ParameterizedTypeReference<Map<String, Object>> stringObjectMap = new ParameterizedTypeReference<Map<String, Object>>() {
|
||||
};
|
||||
return this.restTemplate.exchange(request, stringObjectMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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.
|
||||
@ -30,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@ -83,10 +84,11 @@ public class SampleSessionMongoApplicationTests {
|
||||
return new RequestEntity<>(headers, HttpMethod.GET, uri);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private ResponseEntity<Map<String, Object>> getSessions() {
|
||||
RequestEntity<Object> request = getRequestEntity(URI.create("/actuator/sessions?username=user"));
|
||||
return (ResponseEntity<Map<String, Object>>) (ResponseEntity) this.restTemplate.exchange(request, Map.class);
|
||||
ParameterizedTypeReference<Map<String, Object>> stringObjectMap = new ParameterizedTypeReference<Map<String, Object>>() {
|
||||
};
|
||||
return this.restTemplate.exchange(request, stringObjectMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.boot.testsupport.testcontainers.RedisContainer;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@ -81,10 +82,11 @@ public class SampleSessionRedisApplicationTests {
|
||||
return new RequestEntity<>(headers, HttpMethod.GET, uri);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private ResponseEntity<Map<String, Object>> getSessions() {
|
||||
RequestEntity<Object> request = getRequestEntity(URI.create("/actuator/sessions?username=user"));
|
||||
return (ResponseEntity<Map<String, Object>>) (ResponseEntity) this.restTemplate.exchange(request, Map.class);
|
||||
ParameterizedTypeReference<Map<String, Object>> stringObjectMap = new ParameterizedTypeReference<Map<String, Object>>() {
|
||||
};
|
||||
return this.restTemplate.exchange(request, stringObjectMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,10 +22,4 @@
|
||||
<url-pattern>/</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- Disables Servlet Container welcome file handling. Needed for compatibility
|
||||
with Servlet 3.0 and Tomcat 7.0 -->
|
||||
<welcome-file-list>
|
||||
<welcome-file></welcome-file>
|
||||
</welcome-file-list>
|
||||
|
||||
</web-app>
|
||||
|
Loading…
Reference in New Issue
Block a user