Remove most deprecated APIs that were due for removal in 4.0

Support for rest controller, controler, and servlet endpoints has
been kept for now.

Issue: 45600
This commit is contained in:
Andy Wilkinson
2025-06-10 20:11:08 +01:00
committed by Phillip Webb
parent bf385649ec
commit a78797a2ba
192 changed files with 94 additions and 10953 deletions

View File

@@ -26,7 +26,6 @@ import org.springframework.boot.buildpack.platform.docker.TotalProgressEvent;
import org.springframework.boot.buildpack.platform.docker.TotalProgressPullListener;
import org.springframework.boot.buildpack.platform.docker.TotalProgressPushListener;
import org.springframework.boot.buildpack.platform.docker.UpdateListener;
import org.springframework.boot.buildpack.platform.docker.configuration.DockerConnectionConfiguration;
import org.springframework.boot.buildpack.platform.docker.configuration.DockerRegistryAuthentication;
import org.springframework.boot.buildpack.platform.docker.configuration.ResolvedDockerHost;
import org.springframework.boot.buildpack.platform.docker.transport.DockerEngineException;
@@ -64,20 +63,6 @@ public class Builder {
this(BuildLog.toSystemOut());
}
/**
* Create a new builder instance.
* @param dockerConfiguration the docker configuration
* @since 2.4.0
* @deprecated since 3.5.0 for removal in 4.0.0 in favor of
* {@link #Builder(BuilderDockerConfiguration)}
*/
@Deprecated(since = "3.5.0", forRemoval = true)
@SuppressWarnings("removal")
public Builder(
org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration dockerConfiguration) {
this(BuildLog.toSystemOut(), dockerConfiguration);
}
/**
* Create a new builder instance.
* @param dockerConfiguration the docker configuration
@@ -95,33 +80,6 @@ public class Builder {
this(log, new DockerApi(null, BuildLogAdapter.get(log)), null);
}
/**
* Create a new builder instance.
* @param log a logger used to record output
* @param dockerConfiguration the docker configuration
* @since 2.4.0
* @deprecated since 3.5.0 for removal in 4.0.0 in favor of
* {@link #Builder(BuildLog, BuilderDockerConfiguration)}
*/
@Deprecated(since = "3.5.0", forRemoval = true)
@SuppressWarnings("removal")
public Builder(BuildLog log,
org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration dockerConfiguration) {
this(log, adaptDeprecatedConfiguration(dockerConfiguration));
}
@SuppressWarnings("removal")
private static BuilderDockerConfiguration adaptDeprecatedConfiguration(
org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration configuration) {
if (configuration == null) {
return null;
}
DockerConnectionConfiguration connection = org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration.DockerHostConfiguration
.asConnectionConfiguration(configuration.getHost());
return new BuilderDockerConfiguration(connection, configuration.isBindHostToBuilder(),
configuration.getBuilderRegistryAuthentication(), configuration.getPublishRegistryAuthentication());
}
/**
* Create a new builder instance.
* @param log a logger used to record output

View File

@@ -90,21 +90,6 @@ public class DockerApi {
this(HttpTransport.create((DockerConnectionConfiguration) null), DockerLog.toSystemOut());
}
/**
* Create a new {@link DockerApi} instance.
* @param dockerHost the Docker daemon host information
* @since 2.4.0
* @deprecated since 3.5.0 for removal in 4.0.0 in favor of
* {@link #DockerApi(DockerConnectionConfiguration, DockerLog)}
*/
@Deprecated(since = "3.5.0", forRemoval = true)
@SuppressWarnings("removal")
public DockerApi(
org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration.DockerHostConfiguration dockerHost) {
this(org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration.DockerHostConfiguration
.asConnectionConfiguration(dockerHost), DockerLog.toSystemOut());
}
/**
* Create a new {@link DockerApi} instance.
* @param connectionConfiguration the connection configuration to use

View File

@@ -1,193 +0,0 @@
/*
* Copyright 2012-2025 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.buildpack.platform.docker.configuration;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* Docker configuration options.
*
* @author Wei Jiang
* @author Scott Frederick
* @since 2.4.0
* @deprecated since 3.5.0 for removal in 4.0.0 in favor of
* {@link org.springframework.boot.buildpack.platform.build.BuilderDockerConfiguration}.
*/
@Deprecated(since = "3.5.0", forRemoval = true)
@SuppressWarnings("removal")
public final class DockerConfiguration {
private final DockerHostConfiguration host;
private final DockerRegistryAuthentication builderAuthentication;
private final DockerRegistryAuthentication publishAuthentication;
private final boolean bindHostToBuilder;
public DockerConfiguration() {
this(null, null, null, false);
}
private DockerConfiguration(DockerHostConfiguration host, DockerRegistryAuthentication builderAuthentication,
DockerRegistryAuthentication publishAuthentication, boolean bindHostToBuilder) {
this.host = host;
this.builderAuthentication = builderAuthentication;
this.publishAuthentication = publishAuthentication;
this.bindHostToBuilder = bindHostToBuilder;
}
public DockerHostConfiguration getHost() {
return this.host;
}
public boolean isBindHostToBuilder() {
return this.bindHostToBuilder;
}
public DockerRegistryAuthentication getBuilderRegistryAuthentication() {
return this.builderAuthentication;
}
public DockerRegistryAuthentication getPublishRegistryAuthentication() {
return this.publishAuthentication;
}
public DockerConfiguration withHost(String address, boolean secure, String certificatePath) {
Assert.notNull(address, "'address' must not be null");
return new DockerConfiguration(DockerHostConfiguration.forAddress(address, secure, certificatePath),
this.builderAuthentication, this.publishAuthentication, this.bindHostToBuilder);
}
public DockerConfiguration withContext(String context) {
Assert.notNull(context, "'context' must not be null");
return new DockerConfiguration(DockerHostConfiguration.forContext(context), this.builderAuthentication,
this.publishAuthentication, this.bindHostToBuilder);
}
public DockerConfiguration withBindHostToBuilder(boolean bindHostToBuilder) {
return new DockerConfiguration(this.host, this.builderAuthentication, this.publishAuthentication,
bindHostToBuilder);
}
public DockerConfiguration withBuilderRegistryTokenAuthentication(String token) {
Assert.notNull(token, "'token' must not be null");
return new DockerConfiguration(this.host, new DockerRegistryTokenAuthentication(token),
this.publishAuthentication, this.bindHostToBuilder);
}
public DockerConfiguration withBuilderRegistryUserAuthentication(String username, String password, String url,
String email) {
Assert.notNull(username, "'username' must not be null");
Assert.notNull(password, "'password' must not be null");
return new DockerConfiguration(this.host, new DockerRegistryUserAuthentication(username, password, url, email),
this.publishAuthentication, this.bindHostToBuilder);
}
public DockerConfiguration withPublishRegistryTokenAuthentication(String token) {
Assert.notNull(token, "'token' must not be null");
return new DockerConfiguration(this.host, this.builderAuthentication,
new DockerRegistryTokenAuthentication(token), this.bindHostToBuilder);
}
public DockerConfiguration withPublishRegistryUserAuthentication(String username, String password, String url,
String email) {
Assert.notNull(username, "'username' must not be null");
Assert.notNull(password, "'password' must not be null");
return new DockerConfiguration(this.host, this.builderAuthentication,
new DockerRegistryUserAuthentication(username, password, url, email), this.bindHostToBuilder);
}
public DockerConfiguration withEmptyPublishRegistryAuthentication() {
return new DockerConfiguration(this.host, this.builderAuthentication,
new DockerRegistryUserAuthentication("", "", "", ""), this.bindHostToBuilder);
}
/**
* Docker host configuration.
*
* @deprecated since 3.5.0 for removal in 4.0.0 in favor of
* {@link DockerHostConfiguration}
*/
@Deprecated(since = "3.5.0", forRemoval = true)
public static class DockerHostConfiguration {
private final String address;
private final String context;
private final boolean secure;
private final String certificatePath;
public DockerHostConfiguration(String address, String context, boolean secure, String certificatePath) {
this.address = address;
this.context = context;
this.secure = secure;
this.certificatePath = certificatePath;
}
public String getAddress() {
return this.address;
}
public String getContext() {
return this.context;
}
public boolean isSecure() {
return this.secure;
}
public String getCertificatePath() {
return this.certificatePath;
}
public static DockerHostConfiguration forAddress(String address) {
return new DockerHostConfiguration(address, null, false, null);
}
public static DockerHostConfiguration forAddress(String address, boolean secure, String certificatePath) {
return new DockerHostConfiguration(address, null, secure, certificatePath);
}
static DockerHostConfiguration forContext(String context) {
return new DockerHostConfiguration(null, context, false, null);
}
/**
* Adapts a {@link DockerHostConfiguration} to a
* {@link DockerConnectionConfiguration}.
* @param configuration the configuration to adapt
* @return the adapted configuration
* @since 3.5.0
*/
public static DockerConnectionConfiguration asConnectionConfiguration(DockerHostConfiguration configuration) {
if (configuration != null && StringUtils.hasLength(configuration.context)) {
return new DockerConnectionConfiguration.Context(configuration.context);
}
if (configuration != null && StringUtils.hasLength(configuration.address)) {
return new DockerConnectionConfiguration.Host(configuration.address, configuration.secure,
configuration.certificatePath);
}
return null;
}
}
}

View File

@@ -76,20 +76,6 @@ public class ResolvedDockerHost extends DockerHost {
}
}
/**
* Create a new {@link ResolvedDockerHost} from the given host configuration.
* @param dockerHostConfiguration the host configuration or {@code null}
* @return the resolved docker host
* @deprecated since 3.5.0 for removal in 4.0.0 in favor of
* {@link #from(DockerConnectionConfiguration)}
*/
@Deprecated(since = "3.5.0", forRemoval = true)
@SuppressWarnings("removal")
public static ResolvedDockerHost from(DockerConfiguration.DockerHostConfiguration dockerHostConfiguration) {
return from(Environment.SYSTEM,
DockerConfiguration.DockerHostConfiguration.asConnectionConfiguration(dockerHostConfiguration));
}
/**
* Create a new {@link ResolvedDockerHost} from the given host configuration.
* @param connectionConfiguration the host configuration or {@code null}

View File

@@ -99,22 +99,6 @@ public interface HttpTransport {
*/
Response head(URI uri) throws IOException;
/**
* Create the most suitable {@link HttpTransport} based on the {@link DockerHost}.
* @param dockerHost the Docker host information
* @return a {@link HttpTransport} instance
* @deprecated since 3.5.0 for removal in 4.0.0 in favor of
* {@link #create(DockerConnectionConfiguration)}
*/
@Deprecated(since = "3.5.0", forRemoval = true)
@SuppressWarnings("removal")
static HttpTransport create(
org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration.DockerHostConfiguration dockerHost) {
ResolvedDockerHost host = ResolvedDockerHost.from(dockerHost);
HttpTransport remote = RemoteHttpClientTransport.createIfPossible(host);
return (remote != null) ? remote : LocalHttpClientTransport.create(host);
}
/**
* Create the most suitable {@link HttpTransport} based on the {@link DockerHost}.
* @param connectionConfiguration the Docker host information

View File

@@ -1,62 +0,0 @@
/*
* Copyright 2012-2025 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.buildpack.platform.docker.configuration;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link DockerConfiguration}.
*
* @author Wei Jiang
* @author Scott Frederick
*/
@SuppressWarnings("removal")
class DockerConfigurationTests {
@Test
void createDockerConfigurationWithDefaults() {
DockerConfiguration configuration = new DockerConfiguration();
assertThat(configuration.getBuilderRegistryAuthentication()).isNull();
}
@Test
void createDockerConfigurationWithUserAuth() {
DockerConfiguration configuration = new DockerConfiguration().withBuilderRegistryUserAuthentication("user",
"secret", "https://docker.example.com", "docker@example.com");
DockerRegistryAuthentication auth = configuration.getBuilderRegistryAuthentication();
assertThat(auth).isNotNull();
assertThat(auth).isInstanceOf(DockerRegistryUserAuthentication.class);
DockerRegistryUserAuthentication userAuth = (DockerRegistryUserAuthentication) auth;
assertThat(userAuth.getUrl()).isEqualTo("https://docker.example.com");
assertThat(userAuth.getUsername()).isEqualTo("user");
assertThat(userAuth.getPassword()).isEqualTo("secret");
assertThat(userAuth.getEmail()).isEqualTo("docker@example.com");
}
@Test
void createDockerConfigurationWithTokenAuth() {
DockerConfiguration configuration = new DockerConfiguration().withBuilderRegistryTokenAuthentication("token");
DockerRegistryAuthentication auth = configuration.getBuilderRegistryAuthentication();
assertThat(auth).isNotNull();
assertThat(auth).isInstanceOf(DockerRegistryTokenAuthentication.class);
DockerRegistryTokenAuthentication tokenAuth = (DockerRegistryTokenAuthentication) auth;
assertThat(tokenAuth.getToken()).isEqualTo("token");
}
}

View File

@@ -47,7 +47,6 @@ import javax.tools.Diagnostic.Kind;
import org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata;
import org.springframework.boot.configurationprocessor.metadata.InvalidConfigurationMetadataException;
import org.springframework.boot.configurationprocessor.metadata.ItemDeprecation;
import org.springframework.boot.configurationprocessor.metadata.ItemHint;
import org.springframework.boot.configurationprocessor.metadata.ItemIgnore;
import org.springframework.boot.configurationprocessor.metadata.ItemMetadata;
@@ -346,19 +345,13 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
return; // Can't process that endpoint
}
String endpointKey = ItemMetadata.newItemMetadataPrefix("management.endpoint.", endpointId);
boolean enabledByDefaultAttribute = (boolean) elementValues.getOrDefault("enableByDefault", true);
String defaultAccess = (!enabledByDefaultAttribute) ? "none"
: (elementValues.getOrDefault("defaultAccess", "unrestricted").toString()).toLowerCase(Locale.ENGLISH);
boolean enabledByDefault = !"none".equals(defaultAccess) && enabledByDefaultAttribute;
String defaultAccess = elementValues.getOrDefault("defaultAccess", "unrestricted")
.toString()
.toLowerCase(Locale.ENGLISH);
String type = this.metadataEnv.getTypeUtils().getQualifiedName(element);
this.metadataCollector.addIfAbsent(ItemMetadata.newGroup(endpointKey, type, type, null));
ItemMetadata accessProperty = ItemMetadata.newProperty(endpointKey, "access", endpointAccessEnum(), type, null,
"Permitted level of access for the %s endpoint.".formatted(endpointId), defaultAccess, null);
this.metadataCollector.add(
ItemMetadata.newProperty(endpointKey, "enabled", Boolean.class.getName(), type, null,
"Whether to enable the %s endpoint.".formatted(endpointId), enabledByDefault,
new ItemDeprecation(null, accessProperty.getName(), "3.4.0")),
(existing) -> checkEnabledValueMatchesExisting(existing, enabledByDefault, type));
this.metadataCollector.add(accessProperty,
(existing) -> checkDefaultAccessValueMatchesExisting(existing, defaultAccess, type));
if (hasMainReadOperation(element)) {
@@ -367,22 +360,12 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
}
}
private void checkEnabledValueMatchesExisting(ItemMetadata existing, boolean enabledByDefault, String sourceType) {
boolean existingDefaultValue = (boolean) existing.getDefaultValue();
if (enabledByDefault != existingDefaultValue) {
throw new IllegalStateException(
"Existing property '%s' from type %s has a conflicting value. Existing value: %b, new value from type %s: %b"
.formatted(existing.getName(), existing.getSourceType(), existingDefaultValue, sourceType,
enabledByDefault));
}
}
private void checkDefaultAccessValueMatchesExisting(ItemMetadata existing, String defaultAccess,
String sourceType) {
String existingDefaultAccess = (String) existing.getDefaultValue();
if (!Objects.equals(defaultAccess, existingDefaultAccess)) {
throw new IllegalStateException(
"Existing property '%s' from type %s has a conflicting value. Existing value: %b, new value from type %s: %b"
"Existing property '%s' from type %s has a conflicting value. Existing value: %s, new value from type %s: %s"
.formatted(existing.getName(), existing.getSourceType(), existingDefaultAccess, sourceType,
defaultAccess));
}

View File

@@ -26,7 +26,6 @@ import org.springframework.boot.configurationprocessor.metadata.Metadata;
import org.springframework.boot.configurationsample.Access;
import org.springframework.boot.configurationsample.endpoint.CamelCaseEndpoint;
import org.springframework.boot.configurationsample.endpoint.CustomPropertiesEndpoint;
import org.springframework.boot.configurationsample.endpoint.DisabledEndpoint;
import org.springframework.boot.configurationsample.endpoint.EnabledEndpoint;
import org.springframework.boot.configurationsample.endpoint.NoAccessEndpoint;
import org.springframework.boot.configurationsample.endpoint.ReadOnlyAccessEndpoint;
@@ -53,18 +52,8 @@ class EndpointMetadataGenerationTests extends AbstractMetadataGenerationTests {
void simpleEndpoint() {
ConfigurationMetadata metadata = compile(SimpleEndpoint.class);
assertThat(metadata).has(Metadata.withGroup("management.endpoint.simple").fromSource(SimpleEndpoint.class));
assertThat(metadata).has(enabledFlag("simple", true));
assertThat(metadata).has(access("simple", Access.UNRESTRICTED));
assertThat(metadata).has(cacheTtl("simple"));
assertThat(metadata.getItems()).hasSize(4);
}
@Test
void disabledEndpoint() {
ConfigurationMetadata metadata = compile(DisabledEndpoint.class);
assertThat(metadata).has(Metadata.withGroup("management.endpoint.disabled").fromSource(DisabledEndpoint.class));
assertThat(metadata).has(enabledFlag("disabled", false));
assertThat(metadata).has(access("disabled", Access.NONE));
assertThat(metadata.getItems()).hasSize(3);
}
@@ -72,18 +61,16 @@ class EndpointMetadataGenerationTests extends AbstractMetadataGenerationTests {
void enabledEndpoint() {
ConfigurationMetadata metadata = compile(EnabledEndpoint.class);
assertThat(metadata).has(Metadata.withGroup("management.endpoint.enabled").fromSource(EnabledEndpoint.class));
assertThat(metadata).has(enabledFlag("enabled", true));
assertThat(metadata).has(access("enabled", Access.UNRESTRICTED));
assertThat(metadata.getItems()).hasSize(3);
assertThat(metadata.getItems()).hasSize(2);
}
@Test
void noAccessEndpoint() {
ConfigurationMetadata metadata = compile(NoAccessEndpoint.class);
assertThat(metadata).has(Metadata.withGroup("management.endpoint.noaccess").fromSource(NoAccessEndpoint.class));
assertThat(metadata).has(enabledFlag("noaccess", false));
assertThat(metadata).has(access("noaccess", Access.NONE));
assertThat(metadata.getItems()).hasSize(3);
assertThat(metadata.getItems()).hasSize(2);
}
@Test
@@ -91,9 +78,8 @@ class EndpointMetadataGenerationTests extends AbstractMetadataGenerationTests {
ConfigurationMetadata metadata = compile(ReadOnlyAccessEndpoint.class);
assertThat(metadata)
.has(Metadata.withGroup("management.endpoint.readonlyaccess").fromSource(ReadOnlyAccessEndpoint.class));
assertThat(metadata).has(enabledFlag("readonlyaccess", true));
assertThat(metadata).has(access("readonlyaccess", Access.READ_ONLY));
assertThat(metadata.getItems()).hasSize(3);
assertThat(metadata.getItems()).hasSize(2);
}
@Test
@@ -101,9 +87,8 @@ class EndpointMetadataGenerationTests extends AbstractMetadataGenerationTests {
ConfigurationMetadata metadata = compile(UnrestrictedAccessEndpoint.class);
assertThat(metadata).has(Metadata.withGroup("management.endpoint.unrestrictedaccess")
.fromSource(UnrestrictedAccessEndpoint.class));
assertThat(metadata).has(enabledFlag("unrestrictedaccess", true));
assertThat(metadata).has(access("unrestrictedaccess", Access.UNRESTRICTED));
assertThat(metadata.getItems()).hasSize(3);
assertThat(metadata.getItems()).hasSize(2);
}
@Test
@@ -114,20 +99,18 @@ class EndpointMetadataGenerationTests extends AbstractMetadataGenerationTests {
assertThat(metadata).has(Metadata.withProperty("management.endpoint.customprops.name")
.ofType(String.class)
.withDefaultValue("test"));
assertThat(metadata).has(enabledFlag("customprops", true));
assertThat(metadata).has(access("customprops", Access.UNRESTRICTED));
assertThat(metadata).has(cacheTtl("customprops"));
assertThat(metadata.getItems()).hasSize(5);
assertThat(metadata.getItems()).hasSize(4);
}
@Test
void specificEndpoint() {
ConfigurationMetadata metadata = compile(SpecificEndpoint.class);
assertThat(metadata).has(Metadata.withGroup("management.endpoint.specific").fromSource(SpecificEndpoint.class));
assertThat(metadata).has(enabledFlag("specific", true));
assertThat(metadata).has(access("specific", Access.UNRESTRICTED));
assertThat(metadata).has(access("specific", Access.READ_ONLY));
assertThat(metadata).has(cacheTtl("specific"));
assertThat(metadata.getItems()).hasSize(4);
assertThat(metadata.getItems()).hasSize(3);
}
@Test
@@ -135,30 +118,27 @@ class EndpointMetadataGenerationTests extends AbstractMetadataGenerationTests {
ConfigurationMetadata metadata = compile(CamelCaseEndpoint.class);
assertThat(metadata)
.has(Metadata.withGroup("management.endpoint.pascal-case").fromSource(CamelCaseEndpoint.class));
assertThat(metadata).has(enabledFlag("PascalCase", "pascal-case", true));
assertThat(metadata).has(defaultAccess("PascalCase", "pascal-case", Access.UNRESTRICTED));
assertThat(metadata.getItems()).hasSize(3);
assertThat(metadata.getItems()).hasSize(2);
}
@Test
void incrementalEndpointBuildChangeGeneralEnabledFlag() {
void incrementalEndpointBuildChangeDefaultAccess() {
TestProject project = new TestProject(IncrementalEndpoint.class);
ConfigurationMetadata metadata = project.compile();
assertThat(metadata)
.has(Metadata.withGroup("management.endpoint.incremental").fromSource(IncrementalEndpoint.class));
assertThat(metadata).has(enabledFlag("incremental", true));
assertThat(metadata).has(access("incremental", Access.UNRESTRICTED));
assertThat(metadata).has(cacheTtl("incremental"));
assertThat(metadata.getItems()).hasSize(4);
assertThat(metadata.getItems()).hasSize(3);
project.replaceText(IncrementalEndpoint.class, "id = \"incremental\"",
"id = \"incremental\", enableByDefault = false");
"id = \"incremental\", defaultAccess = org.springframework.boot.configurationsample.Access.NONE");
metadata = project.compile();
assertThat(metadata)
.has(Metadata.withGroup("management.endpoint.incremental").fromSource(IncrementalEndpoint.class));
assertThat(metadata).has(enabledFlag("incremental", false));
assertThat(metadata).has(access("incremental", Access.NONE));
assertThat(metadata).has(cacheTtl("incremental"));
assertThat(metadata.getItems()).hasSize(4);
assertThat(metadata.getItems()).hasSize(3);
}
@Test
@@ -167,45 +147,40 @@ class EndpointMetadataGenerationTests extends AbstractMetadataGenerationTests {
ConfigurationMetadata metadata = project.compile();
assertThat(metadata)
.has(Metadata.withGroup("management.endpoint.incremental").fromSource(IncrementalEndpoint.class));
assertThat(metadata).has(enabledFlag("incremental", true));
assertThat(metadata).has(access("incremental", Access.UNRESTRICTED));
assertThat(metadata).has(cacheTtl("incremental"));
assertThat(metadata.getItems()).hasSize(4);
assertThat(metadata.getItems()).hasSize(3);
project.replaceText(IncrementalEndpoint.class, "@OptionalParameter String param", "String param");
metadata = project.compile();
assertThat(metadata)
.has(Metadata.withGroup("management.endpoint.incremental").fromSource(IncrementalEndpoint.class));
assertThat(metadata).has(enabledFlag("incremental", true));
assertThat(metadata).has(access("incremental", Access.UNRESTRICTED));
assertThat(metadata.getItems()).hasSize(3);
assertThat(metadata.getItems()).hasSize(2);
}
@Test
void incrementalEndpointBuildEnableSpecificEndpoint() {
void incrementalEndpointBuildChangeAccessOfSpecificEndpoint() {
TestProject project = new TestProject(SpecificEndpoint.class);
ConfigurationMetadata metadata = project.compile();
assertThat(metadata).has(Metadata.withGroup("management.endpoint.specific").fromSource(SpecificEndpoint.class));
assertThat(metadata).has(enabledFlag("specific", true));
assertThat(metadata).has(access("specific", Access.UNRESTRICTED));
assertThat(metadata).has(access("specific", Access.READ_ONLY));
assertThat(metadata).has(cacheTtl("specific"));
assertThat(metadata.getItems()).hasSize(4);
project.replaceText(SpecificEndpoint.class, "enableByDefault = true", "enableByDefault = false");
assertThat(metadata.getItems()).hasSize(3);
project.replaceText(SpecificEndpoint.class, "defaultAccess = Access.READ_ONLY", "defaultAccess = Access.NONE");
metadata = project.compile();
assertThat(metadata).has(Metadata.withGroup("management.endpoint.specific").fromSource(SpecificEndpoint.class));
assertThat(metadata).has(enabledFlag("specific", false));
assertThat(metadata).has(access("specific", Access.NONE));
assertThat(metadata).has(cacheTtl("specific"));
assertThat(metadata.getItems()).hasSize(4);
assertThat(metadata.getItems()).hasSize(3);
}
@Test
void shouldTolerateEndpointWithSameId() {
ConfigurationMetadata metadata = compile(SimpleEndpoint.class, SimpleEndpoint2.class);
assertThat(metadata).has(Metadata.withGroup("management.endpoint.simple").fromSource(SimpleEndpoint.class));
assertThat(metadata).has(enabledFlag("simple", "simple", true));
assertThat(metadata).has(defaultAccess("simple", "simple", Access.UNRESTRICTED));
assertThat(metadata).has(cacheTtl("simple"));
assertThat(metadata.getItems()).hasSize(4);
assertThat(metadata.getItems()).hasSize(3);
}
@Test
@@ -214,18 +189,7 @@ class EndpointMetadataGenerationTests extends AbstractMetadataGenerationTests {
.havingRootCause()
.isInstanceOf(IllegalStateException.class)
.withMessage(
"Existing property 'management.endpoint.simple.enabled' from type org.springframework.boot.configurationsample.endpoint.SimpleEndpoint has a conflicting value. Existing value: true, new value from type org.springframework.boot.configurationsample.endpoint.SimpleEndpoint3: false");
}
private Metadata.MetadataItemCondition enabledFlag(String endpointId, Boolean defaultValue) {
return enabledFlag(endpointId, endpointId, defaultValue);
}
private Metadata.MetadataItemCondition enabledFlag(String endpointId, String endpointSuffix, Boolean defaultValue) {
return Metadata.withEnabledFlag("management.endpoint." + endpointSuffix + ".enabled")
.withDefaultValue(defaultValue)
.withDescription(String.format("Whether to enable the %s endpoint.", endpointId))
.withDeprecation(null, "management.endpoint.%s.access".formatted(endpointSuffix), "3.4.0");
"Existing property 'management.endpoint.simple.access' from type org.springframework.boot.configurationsample.endpoint.SimpleEndpoint has a conflicting value. Existing value: unrestricted, new value from type org.springframework.boot.configurationsample.endpoint.SimpleEndpoint3: none");
}
private Metadata.MetadataItemCondition access(String endpointId, Access defaultValue) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -35,9 +35,6 @@ public @interface Endpoint {
String id() default "";
@Deprecated
boolean enableByDefault() default true;
Access defaultAccess() default Access.UNRESTRICTED;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -35,9 +35,6 @@ public @interface JmxEndpoint {
String id() default "";
@Deprecated
boolean enableByDefault() default true;
Access defaultAccess() default Access.UNRESTRICTED;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -35,9 +35,6 @@ public @interface RestControllerEndpoint {
String id() default "";
@Deprecated
boolean enableByDefault() default true;
Access defaultAccess() default Access.UNRESTRICTED;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -35,9 +35,6 @@ public @interface ServletEndpoint {
String id() default "";
@Deprecated
boolean enableByDefault() default true;
Access defaultAccess() default Access.UNRESTRICTED;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -35,9 +35,6 @@ public @interface WebEndpoint {
String id() default "";
@Deprecated
boolean enableByDefault() default true;
Access defaultAccess() default Access.UNRESTRICTED;
}

View File

@@ -1,30 +0,0 @@
/*
* Copyright 2012-2025 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.configurationsample.endpoint;
import org.springframework.boot.configurationsample.Endpoint;
/**
* An endpoint that is disabled unless configured explicitly.
*
* @author Stephane Nicoll
*/
@SuppressWarnings({ "deprecation", "removal" })
@Endpoint(id = "disabled", enableByDefault = false)
public class DisabledEndpoint {
}

View File

@@ -16,17 +16,17 @@
package org.springframework.boot.configurationsample.endpoint;
import org.springframework.boot.configurationsample.Access;
import org.springframework.boot.configurationsample.Endpoint;
import org.springframework.boot.configurationsample.ReadOperation;
/**
* A simple endpoint with no default override, with the same id as {@link SimpleEndpoint},
* but not enabled by default.
* but with no access by default.
*
* @author Moritz Halbritter
*/
@SuppressWarnings({ "deprecation", "removal" })
@Endpoint(id = "simple", enableByDefault = false)
@Endpoint(id = "simple", defaultAccess = Access.NONE)
public class SimpleEndpoint3 {
@ReadOperation

View File

@@ -16,6 +16,7 @@
package org.springframework.boot.configurationsample.endpoint;
import org.springframework.boot.configurationsample.Access;
import org.springframework.boot.configurationsample.OptionalParameter;
import org.springframework.boot.configurationsample.ReadOperation;
import org.springframework.boot.configurationsample.WebEndpoint;
@@ -26,8 +27,7 @@ import org.springframework.boot.configurationsample.WebEndpoint;
*
* @author Stephane Nicoll
*/
@SuppressWarnings({ "deprecation", "removal" })
@WebEndpoint(id = "specific", enableByDefault = true)
@WebEndpoint(id = "specific", defaultAccess = Access.READ_ONLY)
public class SpecificEndpoint {
@ReadOperation

View File

@@ -84,17 +84,6 @@ public enum TestImage {
CASSANDRA("cassandra", "3.11.10", () -> CassandraContainer.class,
(container) -> ((CassandraContainer) container).withStartupTimeout(Duration.ofMinutes(10))),
/**
* A container image suitable for testing Cassandra using the deprecated
* {@link org.testcontainers.containers.CassandraContainer}.
* @deprecated since 3.4.0 for removal in 4.0.0 in favor of {@link #CASSANDRA}
*/
@SuppressWarnings("deprecation")
@Deprecated(since = "3.4.0", forRemoval = true)
CASSANDRA_DEPRECATED("cassandra", "3.11.10", () -> org.testcontainers.containers.CassandraContainer.class,
(container) -> ((org.testcontainers.containers.CassandraContainer<?>) container)
.withStartupTimeout(Duration.ofMinutes(10))),
/**
* A container image suitable for testing ClickHouse.
*/
@@ -136,16 +125,6 @@ public enum TestImage {
*/
CONFLUENT_KAFKA("confluentinc/cp-kafka", "7.4.0", () -> ConfluentKafkaContainer.class),
/**
* A container image suitable for testing Confluent's distribution of Kafka using the
* deprecated {@link org.testcontainers.containers.KafkaContainer}.
* @deprecated since 3.4.0 for removal in 4.0.0 in favor of {@link #CONFLUENT_KAFKA}
*/
@SuppressWarnings("deprecation")
@Deprecated(since = "3.4.0", forRemoval = true)
CONFLUENT_KAFKA_DEPRECATED("confluentinc/cp-kafka", "7.4.0",
() -> org.testcontainers.containers.KafkaContainer.class),
/**
* A container image suitable for testing LLDAP.
*/