Remove deprecated code that was to be removed in 3.2

Closes gh-36034
This commit is contained in:
Andy Wilkinson
2023-06-23 17:28:22 +01:00
parent 50d8b20d6c
commit b645eb32ac
93 changed files with 117 additions and 4580 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.boot.context.properties.bind.ConstructorBinding;
import org.springframework.core.annotation.AliasFor;
import org.springframework.stereotype.Indexed;

View File

@@ -1,52 +0,0 @@
/*
* 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.
* 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.properties;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation that can be used to indicate which constructor to use when binding
* configuration properties using constructor arguments rather than by calling setters. A
* single parameterized constructor implicitly indicates that constructor binding should
* be used unless the constructor is annotated with `@Autowired`.
* <p>
* Note: To use constructor binding the class must be enabled using
* {@link EnableConfigurationProperties @EnableConfigurationProperties} or configuration
* property scanning. Constructor binding cannot be used with beans that are created by
* the regular Spring mechanisms (e.g.
* {@link org.springframework.stereotype.Component @Component} beans, beans created via
* {@link org.springframework.context.annotation.Bean @Bean} methods or beans loaded using
* {@link org.springframework.context.annotation.Import @Import}).
*
* @author Phillip Webb
* @since 2.2.0
* @see ConfigurationProperties
* @deprecated since 3.0.0 for removal in 3.2.0 in favor of
* {@link org.springframework.boot.context.properties.bind.ConstructorBinding}
*/
@Target({ ElementType.CONSTRUCTOR, ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Deprecated(since = "3.0.0", forRemoval = true)
@org.springframework.boot.context.properties.bind.ConstructorBinding
public @interface ConstructorBinding {
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 the original author or authors.
* Copyright 2019-2023 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.context.properties;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.boot.context.properties.bind.ConstructorBinding;
/**
* Helper class to programmatically bind configuration properties that use constructor

View File

@@ -16,14 +16,9 @@
package org.springframework.boot.jackson;
import java.util.Collection;
import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.module.SimpleModule;
import org.springframework.context.ApplicationContext;
import org.springframework.util.Assert;
/**
* Spring Bean and Jackson {@link Module} to find and
* {@link SimpleModule#setMixInAnnotation(Class, Class) register}
@@ -36,22 +31,6 @@ import org.springframework.util.Assert;
*/
public class JsonMixinModule extends SimpleModule {
public JsonMixinModule() {
}
/**
* Create a new {@link JsonMixinModule} instance.
* @param context the source application context
* @param basePackages the packages to check for annotated classes
* @deprecated since 3.0.0 in favor of
* {@link #registerEntries(JsonMixinModuleEntries, ClassLoader)}
*/
@Deprecated(since = "3.0.0", forRemoval = true)
public JsonMixinModule(ApplicationContext context, Collection<String> basePackages) {
Assert.notNull(context, "Context must not be null");
registerEntries(JsonMixinModuleEntries.scan(context, basePackages), context.getClassLoader());
}
/**
* Register the specified {@link JsonMixinModuleEntries entries}.
* @param entries the entries to register to this instance

View File

@@ -1,41 +0,0 @@
/*
* 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.
* 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.web.client;
import java.util.function.Supplier;
import org.springframework.http.client.ClientHttpRequestFactory;
/**
* A supplier for {@link ClientHttpRequestFactory} that detects the preferred candidate
* based on the available implementations on the classpath.
*
* @author Stephane Nicoll
* @author Moritz Halbritter
* @since 2.1.0
* @deprecated since 3.0.0 for removal in 3.2.0 in favor of
* {@link ClientHttpRequestFactories}
*/
@Deprecated(since = "3.0.0", forRemoval = true)
public class ClientHttpRequestFactorySupplier implements Supplier<ClientHttpRequestFactory> {
@Override
public ClientHttpRequestFactory get() {
return ClientHttpRequestFactories.get(ClientHttpRequestFactorySettings.DEFAULTS);
}
}

View File

@@ -325,8 +325,9 @@ public class RestTemplateBuilder {
}
/**
* Set the {@link ClientHttpRequestFactorySupplier} that should be called each time we
* {@link #build()} a new {@link RestTemplate} instance.
* Set the request factory function that should be called to provide a
* {@link ClientHttpRequestFactory} each time we {@link #build()} a new
* {@link RestTemplate} instance.
* @param requestFactoryFunction the settings to request factory function
* @return a new builder instance
* @since 3.0.0

View File

@@ -39,6 +39,7 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.boot.web.server.AbstractConfigurableWebServerFactory;
import org.springframework.boot.web.server.Cookie;
import org.springframework.boot.web.server.MimeMappings;
import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.util.Assert;
@@ -335,14 +336,12 @@ public abstract class AbstractServletWebServerFactory extends AbstractConfigurab
configureSessionCookie(servletContext.getSessionCookieConfig());
}
@SuppressWarnings("removal")
private void configureSessionCookie(SessionCookieConfig config) {
Session.Cookie cookie = this.session.getCookie();
Cookie cookie = this.session.getCookie();
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
map.from(cookie::getName).to(config::setName);
map.from(cookie::getDomain).to(config::setDomain);
map.from(cookie::getPath).to(config::setPath);
map.from(cookie::getComment).to(config::setComment);
map.from(cookie::getHttpOnly).to(config::setHttpOnly);
map.from(cookie::getSecure).to(config::setSecure);
map.from(cookie::getMaxAge).asInt(Duration::getSeconds).to(config::setMaxAge);

View File

@@ -21,8 +21,9 @@ import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.Set;
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.boot.convert.DurationUnit;
import org.springframework.boot.web.server.Cookie;
/**
* Session properties.
@@ -44,6 +45,7 @@ public class Session {
*/
private File storeDir;
@NestedConfigurationProperty
private final Cookie cookie = new Cookie();
private final SessionStoreDirectory sessionStoreDirectory = new SessionStoreDirectory();
@@ -101,34 +103,6 @@ public class Session {
return this.sessionStoreDirectory;
}
/**
* Session cookie properties.
*/
public static class Cookie extends org.springframework.boot.web.server.Cookie {
/**
* Comment for the session cookie.
*/
private String comment;
/**
* Return the comment for the session cookie.
* @return the session cookie comment
* @deprecated since 3.0.0 without replacement
*/
@Deprecated(since = "3.0.0", forRemoval = true)
@DeprecatedConfigurationProperty
public String getComment() {
return this.comment;
}
@Deprecated(since = "3.0.0", forRemoval = true)
public void setComment(String comment) {
this.comment = comment;
}
}
/**
* Available session tracking modes (mirrors
* {@link jakarta.servlet.SessionTrackingMode}.

View File

@@ -233,24 +233,6 @@ class ConfigurationPropertiesBeanTests {
.isNotNull();
}
@Test
void forValueObjectWithDeprecatedConstructorBindingAnnotatedClassReturnsBean() {
ConfigurationPropertiesBean propertiesBean = ConfigurationPropertiesBean
.forValueObject(DeprecatedConstructorBindingOnConstructor.class, "valueObjectBean");
assertThat(propertiesBean.getName()).isEqualTo("valueObjectBean");
assertThat(propertiesBean.getInstance()).isNull();
assertThat(propertiesBean.getType()).isEqualTo(DeprecatedConstructorBindingOnConstructor.class);
assertThat(propertiesBean.asBindTarget().getBindMethod()).isEqualTo(BindMethod.VALUE_OBJECT);
assertThat(propertiesBean.getAnnotation()).isNotNull();
Bindable<?> target = propertiesBean.asBindTarget();
assertThat(target.getType())
.isEqualTo(ResolvableType.forClass(DeprecatedConstructorBindingOnConstructor.class));
assertThat(target.getValue()).isNull();
assertThat(BindConstructorProvider.DEFAULT.getBindConstructor(DeprecatedConstructorBindingOnConstructor.class,
false))
.isNotNull();
}
@Test
void forValueObjectWithRecordReturnsBean() {
Class<?> implicitConstructorBinding = new ByteBuddy(ClassFileVersion.JAVA_V16).makeRecord()
@@ -558,20 +540,6 @@ class ConfigurationPropertiesBeanTests {
}
@ConfigurationProperties
@SuppressWarnings("removal")
static class DeprecatedConstructorBindingOnConstructor {
DeprecatedConstructorBindingOnConstructor(String name) {
this(name, -1);
}
@org.springframework.boot.context.properties.ConstructorBinding
DeprecatedConstructorBindingOnConstructor(String name, int age) {
}
}
@ConfigurationProperties
static class ConstructorBindingOnMultipleConstructors {

View File

@@ -17,7 +17,6 @@
package org.springframework.boot.jackson;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import com.fasterxml.jackson.databind.Module;
@@ -35,7 +34,6 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
import org.springframework.util.ClassUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
/**
* Tests for {@link JsonMixinModule}.
@@ -53,14 +51,6 @@ class JsonMixinModuleTests {
}
}
@Test
@Deprecated(since = "3.0.0", forRemoval = true)
@SuppressWarnings("removal")
void createWhenContextIsNullShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> new JsonMixinModule(null, Collections.emptyList()))
.withMessageContaining("Context must not be null");
}
@Test
void jsonWithModuleWithRenameMixInClassShouldBeMixedIn() throws Exception {
load(RenameMixInClass.class);

View File

@@ -120,11 +120,6 @@ class TomcatServletWebServerFactoryTests extends AbstractServletWebServerFactory
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
}
@Override
protected boolean isCookieCommentSupported() {
return false;
}
// JMX MBean names clash if you get more than one Engine with the same name...
@Test
void tomcatEngineNames() {

View File

@@ -204,10 +204,6 @@ public abstract class AbstractServletWebServerFactoryTests {
}
}
protected boolean isCookieCommentSupported() {
return true;
}
@Test
void startServlet() throws Exception {
AbstractServletWebServerFactory factory = getFactory();
@@ -870,13 +866,11 @@ public abstract class AbstractServletWebServerFactoryTests {
}
@Test
@SuppressWarnings("removal")
void sessionCookieConfiguration() {
AbstractServletWebServerFactory factory = getFactory();
factory.getSession().getCookie().setName("testname");
factory.getSession().getCookie().setDomain("testdomain");
factory.getSession().getCookie().setPath("/testpath");
factory.getSession().getCookie().setComment("testcomment");
factory.getSession().getCookie().setHttpOnly(true);
factory.getSession().getCookie().setSecure(true);
factory.getSession().getCookie().setMaxAge(Duration.ofSeconds(60));
@@ -886,9 +880,6 @@ public abstract class AbstractServletWebServerFactoryTests {
assertThat(sessionCookieConfig.getName()).isEqualTo("testname");
assertThat(sessionCookieConfig.getDomain()).isEqualTo("testdomain");
assertThat(sessionCookieConfig.getPath()).isEqualTo("/testpath");
if (isCookieCommentSupported()) {
assertThat(sessionCookieConfig.getComment()).isEqualTo("testcomment");
}
assertThat(sessionCookieConfig.isHttpOnly()).isTrue();
assertThat(sessionCookieConfig.isSecure()).isTrue();
assertThat(sessionCookieConfig.getMaxAge()).isEqualTo(60);
@@ -1143,7 +1134,6 @@ public abstract class AbstractServletWebServerFactoryTests {
}
@Test
@SuppressWarnings("removal")
void sessionConfiguration() {
AbstractServletWebServerFactory factory = getFactory();
factory.getSession().setTimeout(Duration.ofSeconds(123));
@@ -1151,7 +1141,6 @@ public abstract class AbstractServletWebServerFactoryTests {
factory.getSession().getCookie().setName("testname");
factory.getSession().getCookie().setDomain("testdomain");
factory.getSession().getCookie().setPath("/testpath");
factory.getSession().getCookie().setComment("testcomment");
factory.getSession().getCookie().setHttpOnly(true);
factory.getSession().getCookie().setSecure(true);
factory.getSession().getCookie().setMaxAge(Duration.ofMinutes(1));
@@ -1163,9 +1152,6 @@ public abstract class AbstractServletWebServerFactoryTests {
assertThat(servletContext.getSessionCookieConfig().getName()).isEqualTo("testname");
assertThat(servletContext.getSessionCookieConfig().getDomain()).isEqualTo("testdomain");
assertThat(servletContext.getSessionCookieConfig().getPath()).isEqualTo("/testpath");
if (isCookieCommentSupported()) {
assertThat(servletContext.getSessionCookieConfig().getComment()).isEqualTo("testcomment");
}
assertThat(servletContext.getSessionCookieConfig().isHttpOnly()).isTrue();
assertThat(servletContext.getSessionCookieConfig().isSecure()).isTrue();
assertThat(servletContext.getSessionCookieConfig().getMaxAge()).isEqualTo(60);