From 7df2e2a8d2a845984cde806232181da486dcf7bd Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 19 Apr 2023 17:23:49 +0200 Subject: [PATCH] Remove APIs deprecated for removal in 6.1 This is the first commit that removes deprecated APIs. Subsequent commits will remove additional deprecated APIs. See gh-29449 --- .../support/ConcurrentExecutorAdapter.java | 61 ------- .../java/org/springframework/util/Assert.java | 123 +------------ .../jdbc/datasource/init/ScriptUtils.java | 169 +----------------- .../datasource/init/ScriptUtilsUnitTests.java | 69 ++++--- .../web/reactive/server/ExchangeResult.java | 12 +- .../org/springframework/http/HttpMethod.java | 13 -- .../org/springframework/http/HttpRequest.java | 15 +- ...ttpComponentsClientHttpRequestFactory.java | 23 +-- .../client/reactive/ClientHttpResponse.java | 14 +- ...ttpRequestMethodNotSupportedException.java | 38 +--- .../web/util/UriComponentsBuilderTests.java | 7 - .../reactive/MockClientHttpRequest.java | 9 +- .../function/client/ClientResponse.java | 13 +- 13 files changed, 58 insertions(+), 508 deletions(-) delete mode 100644 spring-core/src/main/java/org/springframework/core/task/support/ConcurrentExecutorAdapter.java diff --git a/spring-core/src/main/java/org/springframework/core/task/support/ConcurrentExecutorAdapter.java b/spring-core/src/main/java/org/springframework/core/task/support/ConcurrentExecutorAdapter.java deleted file mode 100644 index 016b2d0460b4..000000000000 --- a/spring-core/src/main/java/org/springframework/core/task/support/ConcurrentExecutorAdapter.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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. - * 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.core.task.support; - -import java.util.concurrent.Executor; - -import org.springframework.core.task.TaskExecutor; -import org.springframework.util.Assert; - -/** - * Adapter that exposes the {@link java.util.concurrent.Executor} interface for - * any Spring {@link org.springframework.core.task.TaskExecutor}. - * - *

This adapter is less useful since Spring 3.0, since TaskExecutor itself - * extends the {@code Executor} interface. The adapter is only relevant for - * hiding the {@code TaskExecutor} nature of a given object, solely - * exposing the standard {@code Executor} interface to a client. - * - * @author Juergen Hoeller - * @since 2.5 - * @see java.util.concurrent.Executor - * @see org.springframework.core.task.TaskExecutor - * @deprecated {@code ConcurrentExecutorAdapter} is obsolete and will be removed - * in Spring Framework 6.1 - */ -@Deprecated(since = "6.0.5", forRemoval = true) -public class ConcurrentExecutorAdapter implements Executor { - - private final TaskExecutor taskExecutor; - - - /** - * Create a new ConcurrentExecutorAdapter for the given Spring TaskExecutor. - * @param taskExecutor the Spring TaskExecutor to wrap - */ - public ConcurrentExecutorAdapter(TaskExecutor taskExecutor) { - Assert.notNull(taskExecutor, "TaskExecutor must not be null"); - this.taskExecutor = taskExecutor; - } - - - @Override - public void execute(Runnable command) { - this.taskExecutor.execute(command); - } - -} diff --git a/spring-core/src/main/java/org/springframework/util/Assert.java b/spring-core/src/main/java/org/springframework/util/Assert.java index c006ea6634fd..ad045071d486 100644 --- a/spring-core/src/main/java/org/springframework/util/Assert.java +++ b/spring-core/src/main/java/org/springframework/util/Assert.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 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. @@ -98,17 +98,6 @@ public static void state(boolean expression, Supplier messageSupplier) { } } - /** - * Assert a boolean expression, throwing an {@code IllegalStateException} - * if the expression evaluates to {@code false}. - * @deprecated as of 4.3.7, in favor of {@link #state(boolean, String)}; - * to be removed in 6.1 - */ - @Deprecated(forRemoval = true) - public static void state(boolean expression) { - state(expression, "[Assertion failed] - this state invariant must be true"); - } - /** * Assert a boolean expression, throwing an {@code IllegalArgumentException} * if the expression evaluates to {@code false}. @@ -141,17 +130,6 @@ public static void isTrue(boolean expression, Supplier messageSupplier) } } - /** - * Assert a boolean expression, throwing an {@code IllegalArgumentException} - * if the expression evaluates to {@code false}. - * @deprecated as of 4.3.7, in favor of {@link #isTrue(boolean, String)}; - * to be removed in 6.1 - */ - @Deprecated(forRemoval = true) - public static void isTrue(boolean expression) { - isTrue(expression, "[Assertion failed] - this expression must be true"); - } - /** * Assert that an object is {@code null}. *

Assert.isNull(value, "The value must be null");
@@ -182,16 +160,6 @@ public static void isNull(@Nullable Object object, Supplier messageSuppl } } - /** - * Assert that an object is {@code null}. - * @deprecated as of 4.3.7, in favor of {@link #isNull(Object, String)}; - * to be removed in 6.1 - */ - @Deprecated(forRemoval = true) - public static void isNull(@Nullable Object object) { - isNull(object, "[Assertion failed] - the object argument must be null"); - } - /** * Assert that an object is not {@code null}. *
Assert.notNull(clazz, "The class must not be null");
@@ -223,16 +191,6 @@ public static void notNull(@Nullable Object object, Supplier messageSupp } } - /** - * Assert that an object is not {@code null}. - * @deprecated as of 4.3.7, in favor of {@link #notNull(Object, String)}; - * to be removed in 6.1 - */ - @Deprecated(forRemoval = true) - public static void notNull(@Nullable Object object) { - notNull(object, "[Assertion failed] - this argument is required; it must not be null"); - } - /** * Assert that the given String is not empty; that is, * it must not be {@code null} and not the empty String. @@ -268,18 +226,6 @@ public static void hasLength(@Nullable String text, Supplier messageSupp } } - /** - * Assert that the given String is not empty; that is, - * it must not be {@code null} and not the empty String. - * @deprecated as of 4.3.7, in favor of {@link #hasLength(String, String)}; - * to be removed in 6.1 - */ - @Deprecated(forRemoval = true) - public static void hasLength(@Nullable String text) { - hasLength(text, - "[Assertion failed] - this String argument must have length; it must not be null or empty"); - } - /** * Assert that the given String contains valid text content; that is, it must not * be {@code null} and must contain at least one non-whitespace character. @@ -315,18 +261,6 @@ public static void hasText(@Nullable String text, Supplier messageSuppli } } - /** - * Assert that the given String contains valid text content; that is, it must not - * be {@code null} and must contain at least one non-whitespace character. - * @deprecated as of 4.3.7, in favor of {@link #hasText(String, String)}; - * to be removed in 6.1 - */ - @Deprecated(forRemoval = true) - public static void hasText(@Nullable String text) { - hasText(text, - "[Assertion failed] - this String argument must have text; it must not be null, empty, or blank"); - } - /** * Assert that the given text does not contain the given substring. *
Assert.doesNotContain(name, "rod", "Name must not contain 'rod'");
@@ -361,17 +295,6 @@ public static void doesNotContain(@Nullable String textToSearch, String substrin } } - /** - * Assert that the given text does not contain the given substring. - * @deprecated as of 4.3.7, in favor of {@link #doesNotContain(String, String, String)}; - * to be removed in 6.1 - */ - @Deprecated(forRemoval = true) - public static void doesNotContain(@Nullable String textToSearch, String substring) { - doesNotContain(textToSearch, substring, - () -> "[Assertion failed] - this String argument must not contain the substring [" + substring + "]"); - } - /** * Assert that an array contains elements; that is, it must not be * {@code null} and must contain at least one element. @@ -404,17 +327,6 @@ public static void notEmpty(@Nullable Object[] array, Supplier messageSu } } - /** - * Assert that an array contains elements; that is, it must not be - * {@code null} and must contain at least one element. - * @deprecated as of 4.3.7, in favor of {@link #notEmpty(Object[], String)}; - * to be removed in 6.1 - */ - @Deprecated(forRemoval = true) - public static void notEmpty(@Nullable Object[] array) { - notEmpty(array, "[Assertion failed] - this array must not be empty: it must contain at least 1 element"); - } - /** * Assert that an array contains no {@code null} elements. *

Note: Does not complain if the array is empty! @@ -455,16 +367,6 @@ public static void noNullElements(@Nullable Object[] array, Supplier mes } } - /** - * Assert that an array contains no {@code null} elements. - * @deprecated as of 4.3.7, in favor of {@link #noNullElements(Object[], String)}; - * to be removed in 6.1 - */ - @Deprecated(forRemoval = true) - public static void noNullElements(@Nullable Object[] array) { - noNullElements(array, "[Assertion failed] - this array must not contain any null elements"); - } - /** * Assert that a collection contains elements; that is, it must not be * {@code null} and must contain at least one element. @@ -499,18 +401,6 @@ public static void notEmpty(@Nullable Collection collection, Supplier } } - /** - * Assert that a collection contains elements; that is, it must not be - * {@code null} and must contain at least one element. - * @deprecated as of 4.3.7, in favor of {@link #notEmpty(Collection, String)}; - * to be removed in 6.1 - */ - @Deprecated(forRemoval = true) - public static void notEmpty(@Nullable Collection collection) { - notEmpty(collection, - "[Assertion failed] - this collection must not be empty: it must contain at least 1 element"); - } - /** * Assert that a collection contains no {@code null} elements. *

Note: Does not complain if the collection is empty! @@ -584,17 +474,6 @@ public static void notEmpty(@Nullable Map map, Supplier messageSup } } - /** - * Assert that a Map contains entries; that is, it must not be {@code null} - * and must contain at least one entry. - * @deprecated as of 4.3.7, in favor of {@link #notEmpty(Map, String)}; - * to be removed in 6.1 - */ - @Deprecated(forRemoval = true) - public static void notEmpty(@Nullable Map map) { - notEmpty(map, "[Assertion failed] - this map must not be empty; it must contain at least one entry"); - } - /** * Assert that the provided object is an instance of the provided class. *

Assert.instanceOf(Foo.class, foo, "Foo expected");
diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java index b51f01eca1dc..cf1d803b6101 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 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. @@ -330,53 +330,7 @@ static String readScript(EncodedResource resource, @Nullable String separator, } } - /** - * Read a script from the provided {@code LineNumberReader}, using the supplied - * comment prefix and statement separator, and build a {@code String} containing - * the lines. - *

Lines beginning with the comment prefix are excluded from the - * results; however, line comments anywhere else — for example, within - * a statement — will be included in the results. - * @param lineNumberReader the {@code LineNumberReader} containing the script - * to be processed - * @param commentPrefix the prefix that identifies comments in the SQL script - * (typically "--") - * @param separator the statement separator in the SQL script (typically ";") - * @param blockCommentEndDelimiter the end block comment delimiter - * @return a {@code String} containing the script lines - * @throws IOException in case of I/O errors - * @deprecated as of Spring Framework 5.2.16 with no plans for replacement. - * This is an internal API and will likely be removed in Spring Framework 6.0. - */ - @Deprecated - public static String readScript(LineNumberReader lineNumberReader, @Nullable String commentPrefix, - @Nullable String separator, @Nullable String blockCommentEndDelimiter) throws IOException { - - String[] commentPrefixes = (commentPrefix != null) ? new String[] { commentPrefix } : null; - return readScript(lineNumberReader, commentPrefixes, separator, blockCommentEndDelimiter); - } - - /** - * Read a script from the provided {@code LineNumberReader}, using the supplied - * comment prefixes and statement separator, and build a {@code String} containing - * the lines. - *

Lines beginning with one of the comment prefixes are excluded - * from the results; however, line comments anywhere else — for example, - * within a statement — will be included in the results. - * @param lineNumberReader the {@code LineNumberReader} containing the script - * to be processed - * @param commentPrefixes the prefixes that identify comments in the SQL script - * (typically "--") - * @param separator the statement separator in the SQL script (typically ";") - * @param blockCommentEndDelimiter the end block comment delimiter - * @return a {@code String} containing the script lines - * @throws IOException in case of I/O errors - * @since 5.2 - * @deprecated as of Spring Framework 5.2.16 with no plans for replacement. - * This is an internal API and will likely be removed in Spring Framework 6.0. - */ - @Deprecated - public static String readScript(LineNumberReader lineNumberReader, @Nullable String[] commentPrefixes, + private static String readScript(LineNumberReader lineNumberReader, @Nullable String[] commentPrefixes, @Nullable String separator, @Nullable String blockCommentEndDelimiter) throws IOException { String currentStatement = lineNumberReader.readLine(); @@ -410,28 +364,6 @@ private static void appendSeparatorToScriptIfNecessary(StringBuilder scriptBuild } } - /** - * Determine if the provided SQL script contains the specified delimiter. - *

This method is intended to be used to find the string delimiting each - * SQL statement — for example, a ';' character. - *

Any occurrence of the delimiter within the script will be ignored if it - * is within a literal block of text enclosed in single quotes - * ({@code '}) or double quotes ({@code "}), if it is escaped with a backslash - * ({@code \}), or if it is within a single-line comment or block comment. - * @param script the SQL script to search within - * @param delimiter the statement delimiter to search for - * @see #DEFAULT_COMMENT_PREFIXES - * @see #DEFAULT_BLOCK_COMMENT_START_DELIMITER - * @see #DEFAULT_BLOCK_COMMENT_END_DELIMITER - * @deprecated as of Spring Framework 5.2.16 with no plans for replacement. - * This is an internal API and will likely be removed in Spring Framework 6.0. - */ - @Deprecated - public static boolean containsSqlScriptDelimiters(String script, String delimiter) { - return containsStatementSeparator(null, script, delimiter, DEFAULT_COMMENT_PREFIXES, - DEFAULT_BLOCK_COMMENT_START_DELIMITER, DEFAULT_BLOCK_COMMENT_END_DELIMITER); - } - /** * Determine if the provided SQL script contains the specified statement separator. *

This method is intended to be used to find the string separating each @@ -452,7 +384,7 @@ public static boolean containsSqlScriptDelimiters(String script, String delimite * (typically "*/") * @since 5.2.16 */ - private static boolean containsStatementSeparator(@Nullable EncodedResource resource, String script, + static boolean containsStatementSeparator(@Nullable EncodedResource resource, String script, String separator, String[] commentPrefixes, String blockCommentStartDelimiter, String blockCommentEndDelimiter) throws ScriptException { @@ -511,96 +443,6 @@ else if (script.startsWith(blockCommentStartDelimiter, i)) { return false; } - /** - * Split an SQL script into separate statements delimited by the provided - * separator character. Each individual statement will be added to the - * provided {@code List}. - *

Within the script, {@value #DEFAULT_COMMENT_PREFIX} will be used as the - * comment prefix; any text beginning with the comment prefix and extending to - * the end of the line will be omitted from the output. Similarly, - * {@value #DEFAULT_BLOCK_COMMENT_START_DELIMITER} and - * {@value #DEFAULT_BLOCK_COMMENT_END_DELIMITER} will be used as the - * start and end block comment delimiters: any text enclosed - * in a block comment will be omitted from the output. In addition, multiple - * adjacent whitespace characters will be collapsed into a single space. - * @param script the SQL script - * @param separator character separating each statement (typically a ';') - * @param statements the list that will contain the individual statements - * @throws ScriptException if an error occurred while splitting the SQL script - * @see #splitSqlScript(String, String, List) - * @see #splitSqlScript(EncodedResource, String, String, String, String, String, List) - * @deprecated as of Spring Framework 5.2.16 with no plans for replacement. - * This is an internal API and will likely be removed in Spring Framework 6.0. - */ - @Deprecated - public static void splitSqlScript(String script, char separator, List statements) throws ScriptException { - splitSqlScript(script, String.valueOf(separator), statements); - } - - /** - * Split an SQL script into separate statements delimited by the provided - * separator string. Each individual statement will be added to the - * provided {@code List}. - *

Within the script, {@value #DEFAULT_COMMENT_PREFIX} will be used as the - * comment prefix; any text beginning with the comment prefix and extending to - * the end of the line will be omitted from the output. Similarly, - * {@value #DEFAULT_BLOCK_COMMENT_START_DELIMITER} and - * {@value #DEFAULT_BLOCK_COMMENT_END_DELIMITER} will be used as the - * start and end block comment delimiters: any text enclosed - * in a block comment will be omitted from the output. In addition, multiple - * adjacent whitespace characters will be collapsed into a single space. - * @param script the SQL script - * @param separator text separating each statement - * (typically a ';' or newline character) - * @param statements the list that will contain the individual statements - * @throws ScriptException if an error occurred while splitting the SQL script - * @see #splitSqlScript(String, char, List) - * @see #splitSqlScript(EncodedResource, String, String, String, String, String, List) - * @deprecated as of Spring Framework 5.2.16 with no plans for replacement. - * This is an internal API and will likely be removed in Spring Framework 6.0. - */ - @Deprecated - public static void splitSqlScript(String script, String separator, List statements) throws ScriptException { - splitSqlScript(null, script, separator, DEFAULT_COMMENT_PREFIX, DEFAULT_BLOCK_COMMENT_START_DELIMITER, - DEFAULT_BLOCK_COMMENT_END_DELIMITER, statements); - } - - /** - * Split an SQL script into separate statements delimited by the provided - * separator string. Each individual statement will be added to the provided - * {@code List}. - *

Within the script, the provided {@code commentPrefix} will be honored: - * any text beginning with the comment prefix and extending to the end of the - * line will be omitted from the output. Similarly, the provided - * {@code blockCommentStartDelimiter} and {@code blockCommentEndDelimiter} - * delimiters will be honored: any text enclosed in a block comment will be - * omitted from the output. In addition, multiple adjacent whitespace characters - * will be collapsed into a single space. - * @param resource the resource from which the script was read - * @param script the SQL script - * @param separator text separating each statement - * (typically a ';' or newline character) - * @param commentPrefix the prefix that identifies SQL line comments - * (typically "--") - * @param blockCommentStartDelimiter the start block comment delimiter; - * never {@code null} or empty - * @param blockCommentEndDelimiter the end block comment delimiter; - * never {@code null} or empty - * @param statements the list that will contain the individual statements - * @throws ScriptException if an error occurred while splitting the SQL script - * @deprecated as of Spring Framework 5.2.16 with no plans for replacement. - * This is an internal API and will likely be removed in Spring Framework 6.0. - */ - @Deprecated - public static void splitSqlScript(@Nullable EncodedResource resource, String script, - String separator, String commentPrefix, String blockCommentStartDelimiter, - String blockCommentEndDelimiter, List statements) throws ScriptException { - - Assert.hasText(commentPrefix, "'commentPrefix' must not be null or empty"); - splitSqlScript(resource, script, separator, new String[] { commentPrefix }, - blockCommentStartDelimiter, blockCommentEndDelimiter, statements); - } - /** * Split an SQL script into separate statements delimited by the provided * separator string. Each individual statement will be added to the provided @@ -625,11 +467,8 @@ public static void splitSqlScript(@Nullable EncodedResource resource, String scr * @param statements the list that will contain the individual statements * @throws ScriptException if an error occurred while splitting the SQL script * @since 5.2 - * @deprecated as of Spring Framework 5.2.16 with no plans for replacement. - * This is an internal API and will likely be removed in Spring Framework 6.0. */ - @Deprecated - public static void splitSqlScript(@Nullable EncodedResource resource, String script, + static void splitSqlScript(@Nullable EncodedResource resource, String script, String separator, String[] commentPrefixes, String blockCommentStartDelimiter, String blockCommentEndDelimiter, List statements) throws ScriptException { diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/ScriptUtilsUnitTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/ScriptUtilsUnitTests.java index 7c9202cceec2..6d861a0dce95 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/ScriptUtilsUnitTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/ScriptUtilsUnitTests.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. @@ -26,14 +26,14 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.support.EncodedResource; +import org.springframework.lang.Nullable; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.jdbc.datasource.init.ScriptUtils.DEFAULT_BLOCK_COMMENT_END_DELIMITER; import static org.springframework.jdbc.datasource.init.ScriptUtils.DEFAULT_BLOCK_COMMENT_START_DELIMITER; +import static org.springframework.jdbc.datasource.init.ScriptUtils.DEFAULT_COMMENT_PREFIX; import static org.springframework.jdbc.datasource.init.ScriptUtils.DEFAULT_COMMENT_PREFIXES; import static org.springframework.jdbc.datasource.init.ScriptUtils.DEFAULT_STATEMENT_SEPARATOR; -import static org.springframework.jdbc.datasource.init.ScriptUtils.containsSqlScriptDelimiters; -import static org.springframework.jdbc.datasource.init.ScriptUtils.splitSqlScript; /** * Unit tests for {@link ScriptUtils}. @@ -46,11 +46,10 @@ * @since 4.0.3 * @see ScriptUtilsIntegrationTests */ -public class ScriptUtilsUnitTests { +class ScriptUtilsUnitTests { @Test - @SuppressWarnings("deprecation") - public void splitSqlScriptDelimitedWithSemicolon() { + void splitSqlScriptDelimitedWithSemicolon() { String rawStatement1 = "insert into customer (id, name)\nvalues (1, 'Rod ; Johnson'), (2, 'Adrian \n Collier')"; String cleanedStatement1 = "insert into customer (id, name) values (1, 'Rod ; Johnson'), (2, 'Adrian \n Collier')"; String rawStatement2 = "insert into orders(id, order_date, customer_id)\nvalues (1, '2008-01-02', 2)"; @@ -68,8 +67,7 @@ public void splitSqlScriptDelimitedWithSemicolon() { } @Test - @SuppressWarnings("deprecation") - public void splitSqlScriptDelimitedWithNewLine() { + void splitSqlScriptDelimitedWithNewLine() { String statement1 = "insert into customer (id, name) values (1, 'Rod ; Johnson'), (2, 'Adrian \n Collier')"; String statement2 = "insert into orders(id, order_date, customer_id) values (1, '2008-01-02', 2)"; String statement3 = "insert into orders(id, order_date, customer_id) values (1, '2008-01-02', 2)"; @@ -84,8 +82,7 @@ public void splitSqlScriptDelimitedWithNewLine() { } @Test - @SuppressWarnings("deprecation") - public void splitSqlScriptDelimitedWithNewLineButDefaultDelimiterSpecified() { + void splitSqlScriptDelimitedWithNewLineButDefaultDelimiterSpecified() { String statement1 = "do something"; String statement2 = "do something else"; @@ -99,8 +96,7 @@ public void splitSqlScriptDelimitedWithNewLineButDefaultDelimiterSpecified() { } @Test // SPR-13218 - @SuppressWarnings("deprecation") - public void splitScriptWithSingleQuotesNestedInsideDoubleQuotes() { + void splitScriptWithSingleQuotesNestedInsideDoubleQuotes() { String statement1 = "select '1' as \"Dogbert's owner's\" from dual"; String statement2 = "select '2' as \"Dilbert's\" from dual"; @@ -114,8 +110,7 @@ public void splitScriptWithSingleQuotesNestedInsideDoubleQuotes() { } @Test // SPR-11560 - @SuppressWarnings("deprecation") - public void readAndSplitScriptWithMultipleNewlinesAsSeparator() throws Exception { + void readAndSplitScriptWithMultipleNewlinesAsSeparator() throws Exception { String script = readScript("db-test-data-multi-newline.sql"); List statements = new ArrayList<>(); splitSqlScript(script, "\n\n", statements); @@ -127,24 +122,23 @@ public void readAndSplitScriptWithMultipleNewlinesAsSeparator() throws Exception } @Test - public void readAndSplitScriptContainingComments() throws Exception { + void readAndSplitScriptContainingComments() throws Exception { String script = readScript("test-data-with-comments.sql"); splitScriptContainingComments(script, DEFAULT_COMMENT_PREFIXES); } @Test - public void readAndSplitScriptContainingCommentsWithWindowsLineEnding() throws Exception { + void readAndSplitScriptContainingCommentsWithWindowsLineEnding() throws Exception { String script = readScript("test-data-with-comments.sql").replaceAll("\n", "\r\n"); splitScriptContainingComments(script, DEFAULT_COMMENT_PREFIXES); } @Test - public void readAndSplitScriptContainingCommentsWithMultiplePrefixes() throws Exception { + void readAndSplitScriptContainingCommentsWithMultiplePrefixes() throws Exception { String script = readScript("test-data-with-multi-prefix-comments.sql"); splitScriptContainingComments(script, "--", "#", "^"); } - @SuppressWarnings("deprecation") private void splitScriptContainingComments(String script, String... commentPrefixes) { List statements = new ArrayList<>(); splitSqlScript(null, script, ";", commentPrefixes, DEFAULT_BLOCK_COMMENT_START_DELIMITER, @@ -160,11 +154,10 @@ private void splitScriptContainingComments(String script, String... commentPrefi } @Test // SPR-10330 - @SuppressWarnings("deprecation") - public void readAndSplitScriptContainingCommentsWithLeadingTabs() throws Exception { + void readAndSplitScriptContainingCommentsWithLeadingTabs() throws Exception { String script = readScript("test-data-with-comments-and-leading-tabs.sql"); List statements = new ArrayList<>(); - splitSqlScript(script, ';', statements); + splitSqlScript(script, ";", statements); String statement1 = "insert into customer (id, name) values (1, 'Sam Brannen')"; String statement2 = "insert into orders(id, order_date, customer_id) values (1, '2013-06-08', 1)"; @@ -174,11 +167,10 @@ public void readAndSplitScriptContainingCommentsWithLeadingTabs() throws Excepti } @Test // SPR-9531 - @SuppressWarnings("deprecation") - public void readAndSplitScriptContainingMultiLineComments() throws Exception { + void readAndSplitScriptContainingMultiLineComments() throws Exception { String script = readScript("test-data-with-multi-line-comments.sql"); List statements = new ArrayList<>(); - splitSqlScript(script, ';', statements); + splitSqlScript(script, ";", statements); String statement1 = "INSERT INTO users(first_name, last_name) VALUES('Juergen', 'Hoeller')"; String statement2 = "INSERT INTO users(first_name, last_name) VALUES( 'Sam' , 'Brannen' )"; @@ -187,11 +179,10 @@ public void readAndSplitScriptContainingMultiLineComments() throws Exception { } @Test - @SuppressWarnings("deprecation") - public void readAndSplitScriptContainingMultiLineNestedComments() throws Exception { + void readAndSplitScriptContainingMultiLineNestedComments() throws Exception { String script = readScript("test-data-with-multi-line-nested-comments.sql"); List statements = new ArrayList<>(); - splitSqlScript(script, ';', statements); + splitSqlScript(script, ";", statements); String statement1 = "INSERT INTO users(first_name, last_name) VALUES('Juergen', 'Hoeller')"; String statement2 = "INSERT INTO users(first_name, last_name) VALUES( 'Sam' , 'Brannen' )"; @@ -237,16 +228,36 @@ public void readAndSplitScriptContainingMultiLineNestedComments() throws Excepti ~/* double " quotes */\n insert into colors(color_num) values(42);~ | ; | true ~/* double \\" quotes */\n insert into colors(color_num) values(42);~ | ; | true """) - @SuppressWarnings("deprecation") - public void containsStatementSeparator(String script, String delimiter, boolean expected) { + void containsStatementSeparator(String script, String delimiter, boolean expected) { // Indirectly tests ScriptUtils.containsStatementSeparator(EncodedResource, String, String, String[], String, String). assertThat(containsSqlScriptDelimiters(script, delimiter)).isEqualTo(expected); } + private String readScript(String path) throws Exception { EncodedResource resource = new EncodedResource(new ClassPathResource(path, getClass())); return ScriptUtils.readScript(resource, DEFAULT_STATEMENT_SEPARATOR, DEFAULT_COMMENT_PREFIXES, DEFAULT_BLOCK_COMMENT_END_DELIMITER); } + + private static void splitSqlScript(String script, String separator, List statements) throws ScriptException { + splitSqlScript(null, script, separator, new String[] { DEFAULT_COMMENT_PREFIX }, + DEFAULT_BLOCK_COMMENT_START_DELIMITER, DEFAULT_BLOCK_COMMENT_END_DELIMITER, statements); + } + + private static void splitSqlScript(@Nullable EncodedResource resource, String script, + String separator, String[] commentPrefixes, String blockCommentStartDelimiter, + String blockCommentEndDelimiter, List statements) throws ScriptException { + + ScriptUtils.splitSqlScript(resource, script, separator, commentPrefixes, + blockCommentStartDelimiter, blockCommentEndDelimiter, statements); + } + + + private static boolean containsSqlScriptDelimiters(String script, String delimiter) { + return ScriptUtils.containsStatementSeparator(null, script, delimiter, DEFAULT_COMMENT_PREFIXES, + DEFAULT_BLOCK_COMMENT_START_DELIMITER, DEFAULT_BLOCK_COMMENT_END_DELIMITER); + } + } diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/ExchangeResult.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/ExchangeResult.java index 65cd21e9a0bc..6da41a7abac9 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/ExchangeResult.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/ExchangeResult.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 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. @@ -176,16 +176,6 @@ public HttpStatusCode getStatus() { return this.response.getStatusCode(); } - /** - * Return the HTTP status code as an integer. - * @since 5.1.10 - * @deprecated as of 6.0, in favor of {@link #getStatus()} - */ - @Deprecated(since = "6.0", forRemoval = true) - public int getRawStatusCode() { - return getStatus().value(); - } - /** * Return the response headers received from the server. */ diff --git a/spring-web/src/main/java/org/springframework/http/HttpMethod.java b/spring-web/src/main/java/org/springframework/http/HttpMethod.java index c223a3d1bdce..0267fb519a79 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpMethod.java +++ b/spring-web/src/main/java/org/springframework/http/HttpMethod.java @@ -127,19 +127,6 @@ public static HttpMethod valueOf(String method) { }; } - /** - * Resolve the given method value to an {@code HttpMethod}. - * @param method the method value as a String - * @return the corresponding {@code HttpMethod}, or {@code null} if not found - * @since 4.2.4 - * @deprecated in favor of {@link #valueOf(String)} - */ - @Nullable - @Deprecated(since = "6.0", forRemoval = true) - public static HttpMethod resolve(@Nullable String method) { - return (method != null ? valueOf(method) : null); - } - /** * Return the name of this method, e.g. "GET", "POST". diff --git a/spring-web/src/main/java/org/springframework/http/HttpRequest.java b/spring-web/src/main/java/org/springframework/http/HttpRequest.java index f1219a01ca60..62ea73fad5d0 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/HttpRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 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. @@ -34,19 +34,6 @@ public interface HttpRequest extends HttpMessage { */ HttpMethod getMethod(); - /** - * Return the HTTP method of the request as a String value. - * @return the HTTP method as a plain String - * @since 5.0 - * @see #getMethod() - * @deprecated as of Spring Framework 6.0 in favor of {@link #getMethod()} and - * {@link HttpMethod#name()} - */ - @Deprecated(since = "6.0", forRemoval = true) - default String getMethodValue() { - return getMethod().name(); - } - /** * Return the URI of the request (including a query string if any, * but only if it is well-formed for a URI representation). diff --git a/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java b/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java index f1bc8145d5b1..c3872a4ceb76 100644 --- a/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java +++ b/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 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. @@ -22,8 +22,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.BiFunction; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.hc.client5.http.classic.HttpClient; import org.apache.hc.client5.http.classic.methods.HttpDelete; import org.apache.hc.client5.http.classic.methods.HttpGet; @@ -41,7 +39,6 @@ import org.apache.hc.core5.http.ClassicHttpRequest; import org.apache.hc.core5.http.io.SocketConfig; import org.apache.hc.core5.http.protocol.HttpContext; -import org.apache.hc.core5.util.Timeout; import org.springframework.beans.factory.DisposableBean; import org.springframework.http.HttpMethod; @@ -66,9 +63,6 @@ */ public class HttpComponentsClientHttpRequestFactory implements ClientHttpRequestFactory, DisposableBean { - private static final Log logger = LogFactory.getLog(HttpComponentsClientHttpRequestFactory.class); - - private HttpClient httpClient; private boolean bufferRequestBody = true; @@ -147,21 +141,6 @@ public void setConnectionRequestTimeout(int connectionRequestTimeout) { this.connectionRequestTimeout = connectionRequestTimeout; } - /** - * As of version 6.0, setting this property has no effect. - *

To change the socket read timeout, use {@link SocketConfig.Builder#setSoTimeout(Timeout)}, - * supply the resulting {@link SocketConfig} to - * {@link org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder#setDefaultSocketConfig(SocketConfig)}, - * use the resulting connection manager for - * {@link org.apache.hc.client5.http.impl.classic.HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)}, - * and supply the built {@link HttpClient} to {@link #HttpComponentsClientHttpRequestFactory(HttpClient)}. - * @deprecated as of 6.0, in favor of {@link SocketConfig.Builder#setSoTimeout(Timeout)}, see above. - */ - @Deprecated(since = "6.0", forRemoval = true) - public void setReadTimeout(int timeout) { - logger.warn("HttpComponentsClientHttpRequestFactory.setReadTimeout has no effect"); - } - /** * Indicates whether this request factory should buffer the request body internally. *

Default is {@code true}. When sending large amounts of data via POST or PUT, it is diff --git a/spring-web/src/main/java/org/springframework/http/client/reactive/ClientHttpResponse.java b/spring-web/src/main/java/org/springframework/http/client/reactive/ClientHttpResponse.java index 3db5d31edaa2..f4c022e8be1d 100644 --- a/spring-web/src/main/java/org/springframework/http/client/reactive/ClientHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/client/reactive/ClientHttpResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 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. @@ -46,18 +46,6 @@ default String getId() { */ HttpStatusCode getStatusCode(); - /** - * Return the HTTP status code as an integer. - * @return the HTTP status as an integer value - * @since 5.0.6 - * @see #getStatusCode() - * @deprecated as of 6.0, in favor of {@link #getStatusCode()} - */ - @Deprecated(since = "6.0", forRemoval = true) - default int getRawStatusCode() { - return getStatusCode().value(); - } - /** * Return a read-only map of response cookies received from the server. */ diff --git a/spring-web/src/main/java/org/springframework/web/HttpRequestMethodNotSupportedException.java b/spring-web/src/main/java/org/springframework/web/HttpRequestMethodNotSupportedException.java index 7fa420b67506..cf667bae3e40 100644 --- a/spring-web/src/main/java/org/springframework/web/HttpRequestMethodNotSupportedException.java +++ b/spring-web/src/main/java/org/springframework/web/HttpRequestMethodNotSupportedException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 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. @@ -36,6 +36,7 @@ * specific request method. * * @author Juergen Hoeller + * @author Sam Brannen * @since 2.0 */ @SuppressWarnings("serial") @@ -50,7 +51,7 @@ public class HttpRequestMethodNotSupportedException extends ServletException imp /** - * Create a new HttpRequestMethodNotSupportedException. + * Create a new {@code HttpRequestMethodNotSupportedException}. * @param method the unsupported HTTP request method */ public HttpRequestMethodNotSupportedException(String method) { @@ -58,18 +59,7 @@ public HttpRequestMethodNotSupportedException(String method) { } /** - * Create a new HttpRequestMethodNotSupportedException. - * @param method the unsupported HTTP request method - * @param msg the detail message - * @deprecated in favor of {@link #HttpRequestMethodNotSupportedException(String, Collection)} - */ - @Deprecated(since = "6.0", forRemoval = true) - public HttpRequestMethodNotSupportedException(String method, String msg) { - this(method, null, msg); - } - - /** - * Create a new HttpRequestMethodNotSupportedException. + * Create a new {@code HttpRequestMethodNotSupportedException}. * @param method the unsupported HTTP request method * @param supportedMethods the actually supported HTTP methods (possibly {@code null}) */ @@ -78,26 +68,12 @@ public HttpRequestMethodNotSupportedException(String method, @Nullable Collectio } /** - * Create a new HttpRequestMethodNotSupportedException. + * Create a new {@code HttpRequestMethodNotSupportedException}. * @param method the unsupported HTTP request method * @param supportedMethods the actually supported HTTP methods (possibly {@code null}) - * @deprecated in favor of {@link #HttpRequestMethodNotSupportedException(String, Collection)} - */ - @Deprecated(since = "6.0", forRemoval = true) - public HttpRequestMethodNotSupportedException(String method, @Nullable String[] supportedMethods) { - this(method, supportedMethods, "Request method '" + method + "' is not supported"); - } - - /** - * Create a new HttpRequestMethodNotSupportedException. - * @param method the unsupported HTTP request method - * @param supportedMethods the actually supported HTTP methods - * @param msg the detail message - * @deprecated in favor of {@link #HttpRequestMethodNotSupportedException(String, Collection)} */ - @Deprecated(since = "6.0", forRemoval = true) - public HttpRequestMethodNotSupportedException(String method, @Nullable String[] supportedMethods, String msg) { - super(msg); + private HttpRequestMethodNotSupportedException(String method, @Nullable String[] supportedMethods) { + super("Request method '" + method + "' is not supported"); this.method = method; this.supportedMethods = supportedMethods; diff --git a/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java b/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java index 611863db420f..3461bbd34952 100644 --- a/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java @@ -684,13 +684,6 @@ public HttpMethod getMethod() { return HttpMethod.GET; } - @SuppressWarnings("removal") - @Override - @Deprecated - public String getMethodValue() { - return "GET"; - } - @Override public URI getURI() { return UriComponentsBuilder.fromUriString("/").build().toUri(); diff --git a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/client/reactive/MockClientHttpRequest.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/client/reactive/MockClientHttpRequest.java index e117b6ce2b39..daeefdf13f9f 100644 --- a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/client/reactive/MockClientHttpRequest.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/client/reactive/MockClientHttpRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 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. @@ -95,13 +95,6 @@ public HttpMethod getMethod() { return this.httpMethod; } - @SuppressWarnings("removal") - @Override - @Deprecated - public String getMethodValue() { - return this.httpMethod.name(); - } - @Override public URI getURI() { return this.url; diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java index 9701942caeec..1789b9009ba4 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 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. @@ -57,17 +57,6 @@ public interface ClientResponse { */ HttpStatusCode statusCode(); - /** - * Return the raw status code of this response. - * @return the HTTP status as an integer value - * @since 5.1 - * @deprecated as of 6.0, in favor of {@link #statusCode()} - */ - @Deprecated(since = "6.0", forRemoval = true) - default int rawStatusCode() { - return statusCode().value(); - } - /** * Return the headers of this response. */