From c598f0565ac48bbbff59e731ef0ab766cf69368b Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 13 Sep 2023 13:52:27 +0200 Subject: [PATCH] Deprecate CommandLinePropertySource and associated implementations Closes gh-31207 --- .../context/support/BeanDefinitionDslTests.kt | 6 +++--- .../springframework/core/env/CommandLinePropertySource.java | 2 ++ .../core/env/JOptCommandLinePropertySource.java | 2 ++ .../core/env/SimpleCommandLinePropertySource.java | 4 +++- .../core/env/JOptCommandLinePropertySourceTests.java | 3 ++- .../core/env/SimpleCommandLinePropertySourceTests.java | 1 + 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/spring-context/src/test/kotlin/org/springframework/context/support/BeanDefinitionDslTests.kt b/spring-context/src/test/kotlin/org/springframework/context/support/BeanDefinitionDslTests.kt index 5ac22c8d64f..5716ab8156f 100644 --- a/spring-context/src/test/kotlin/org/springframework/context/support/BeanDefinitionDslTests.kt +++ b/spring-context/src/test/kotlin/org/springframework/context/support/BeanDefinitionDslTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-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. @@ -23,7 +23,6 @@ import org.junit.jupiter.api.Test import org.springframework.beans.factory.NoSuchBeanDefinitionException import org.springframework.beans.factory.getBean import org.springframework.context.support.BeanDefinitionDsl.* -import org.springframework.core.env.SimpleCommandLinePropertySource import org.springframework.core.env.get import org.springframework.core.testfixture.env.MockPropertySource import java.util.stream.Collectors @@ -77,6 +76,7 @@ class BeanDefinitionDslTests { } @Test + @Suppress("DEPRECATION") fun `Declare beans using environment condition with the functional Kotlin DSL`() { val beans = beans { bean() @@ -90,7 +90,7 @@ class BeanDefinitionDslTests { } val context = GenericApplicationContext().apply { - environment.propertySources.addFirst(SimpleCommandLinePropertySource("--name=foofoo")) + environment.propertySources.addFirst(org.springframework.core.env.SimpleCommandLinePropertySource("--name=foofoo")) beans.initialize(this) refresh() } diff --git a/spring-core/src/main/java/org/springframework/core/env/CommandLinePropertySource.java b/spring-core/src/main/java/org/springframework/core/env/CommandLinePropertySource.java index c317f5e2dc7..7819e7146f5 100644 --- a/spring-core/src/main/java/org/springframework/core/env/CommandLinePropertySource.java +++ b/spring-core/src/main/java/org/springframework/core/env/CommandLinePropertySource.java @@ -204,7 +204,9 @@ import org.springframework.util.StringUtils; * @see PropertySource * @see SimpleCommandLinePropertySource * @see JOptCommandLinePropertySource + * @deprecated since 6.1 with no plans for a replacement */ +@Deprecated(since = "6.1") public abstract class CommandLinePropertySource extends EnumerablePropertySource { /** The default name given to {@link CommandLinePropertySource} instances: {@value}. */ diff --git a/spring-core/src/main/java/org/springframework/core/env/JOptCommandLinePropertySource.java b/spring-core/src/main/java/org/springframework/core/env/JOptCommandLinePropertySource.java index 2eb456b1760..679bca5b143 100644 --- a/spring-core/src/main/java/org/springframework/core/env/JOptCommandLinePropertySource.java +++ b/spring-core/src/main/java/org/springframework/core/env/JOptCommandLinePropertySource.java @@ -61,7 +61,9 @@ import org.springframework.util.StringUtils; * @see CommandLinePropertySource * @see joptsimple.OptionParser * @see joptsimple.OptionSet + * @deprecated since 6.1 with no plans for a replacement */ +@Deprecated(since = "6.1") public class JOptCommandLinePropertySource extends CommandLinePropertySource { /** diff --git a/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLinePropertySource.java b/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLinePropertySource.java index c4f34a13e50..154fc9cf661 100644 --- a/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLinePropertySource.java +++ b/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLinePropertySource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-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. @@ -83,7 +83,9 @@ import org.springframework.util.StringUtils; * @since 3.1 * @see CommandLinePropertySource * @see JOptCommandLinePropertySource + * @deprecated since 6.1 with no plans for a replacement */ +@Deprecated(since = "6.1") public class SimpleCommandLinePropertySource extends CommandLinePropertySource { /** diff --git a/spring-core/src/test/java/org/springframework/core/env/JOptCommandLinePropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/JOptCommandLinePropertySourceTests.java index 8a11ab6cceb..9f6c3563343 100644 --- a/spring-core/src/test/java/org/springframework/core/env/JOptCommandLinePropertySourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/JOptCommandLinePropertySourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-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. @@ -31,6 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Sam Brannen * @since 3.1 */ +@SuppressWarnings("deprecation") class JOptCommandLinePropertySourceTests { @Test diff --git a/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java index a4404332b7a..c936558ff31 100644 --- a/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java @@ -29,6 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Sam Brannen * @since 3.1 */ +@SuppressWarnings("deprecation") class SimpleCommandLinePropertySourceTests { @Test