From 4d0f1729cbd2862cd869032bf5c92cad6e0bcfca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Fri, 10 Jan 2025 18:07:30 +0100 Subject: [PATCH] Restore deprecated constructor for binary compatibility support Code that compiles against the non-deprecated version does not see the new constructor that has been introduced. As such, there is no way for them to migrate to it without resorting to reflection. This commit restores the deprecated constructor so that people can try the latest version more easily. Closes gh-34238 --- .../test/util/JsonPathExpectationsHelper.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/spring-test/src/main/java/org/springframework/test/util/JsonPathExpectationsHelper.java b/spring-test/src/main/java/org/springframework/test/util/JsonPathExpectationsHelper.java index a7e8ec4e529..fdd432c7671 100644 --- a/spring-test/src/main/java/org/springframework/test/util/JsonPathExpectationsHelper.java +++ b/spring-test/src/main/java/org/springframework/test/util/JsonPathExpectationsHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-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. @@ -82,6 +82,18 @@ public class JsonPathExpectationsHelper { this.configuration = (configuration != null) ? configuration : Configuration.defaultConfiguration(); } + /** + * Construct a new {@code JsonPathExpectationsHelper}. + * @param expression the {@link JsonPath} expression; never {@code null} or empty + * @param args arguments to parameterize the {@code JsonPath} expression with, + * using formatting specifiers defined in {@link String#format(String, Object...)} + * @deprecated in favor of calling {@link String#formatted(Object...)} upfront + */ + @Deprecated(since = "6.2", forRemoval = true) + public JsonPathExpectationsHelper(String expression, Object... args) { + this(expression.formatted(args), (Configuration) null); + } + /** * Evaluate the JSON path expression against the supplied {@code content}