Commit Graph

32088 Commits

Author SHA1 Message Date
Sam Brannen
98cef503fb Remove obsolete TODO
See gh-10976
2025-05-21 15:37:04 +02:00
Sam Brannen
362fe12704 Polishing 2025-05-21 15:36:58 +02:00
Brian Clozel
2af0323c21 Use Content-Type charset in JAXB message converters
Prior to this commit, the JAXB message converters would only rely on the
encoding declaration inside the XML document for reading the document.
This would then use the default UTF-8 encoding, even if the HTTP message
has the `"application/xml;charset=iso-8859-1"` Content-Type.

This commit ensures that both `Jaxb2CollectionHttpMessageConverter` and
`Jaxb2RootElementHttpMessageConverter` use the encoding declared in the
HTTP Content-Type, if present.

Fixes gh-34745
2025-05-19 16:57:57 +02:00
Brian Clozel
fdab8fabd2 Avoid duplicate Content-Type in MockHttpServletRequest
Fixes gh-34913
2025-05-19 12:04:46 +02:00
Brian Clozel
ae8b45a290 Next development version (v6.2.8-SNAPSHOT) 2025-05-15 11:07:25 +02:00
rstoyanchev
ee62701f56 Make use of PatternMatchUtils ignoreCase option
Closes gh-34801
2025-05-15 08:18:56 +01:00
Juergen Hoeller
fa168ca78a Revise FactoryBean locking behavior for strict/lenient consistency
After the bootstrap phase (and with spring.locking.strict=true during the bootstrap phase), getSingletonFactoryBeanForTypeCheck always locks. In a background bootstrap thread, it never locks. Otherwise, it tries locking and explicitly resolves the bean class for subsequent type-based resolution (even for a component-scanned class) when it fails to acquire the lock. Furthermore, getObjectFromFactoryBean follows the same locking algorithm for post-processing.

Closes gh-34902
2025-05-15 01:45:09 +02:00
rstoyanchev
3c228a5c1d Add missing @since tags in PatternMatchUtils
See: gh-34801
2025-05-14 15:15:50 +01:00
Juergen Hoeller
9bf6b8cddf Upgrade to Reactor 2024.0.6
Closes gh-34898
2025-05-14 15:03:28 +02:00
Patrick Strawderman
37ecdd1437 Forward more methods to underlying InputStream in NonClosingInputStream
NonClosingInputStream extends FilterInputStream, which does not forward some
newer InputStream methods such as transferTo and readAllBytes. Specific InputStream
implementations may have more optimized methods (e.g., FileInputStream).

Closes gh-34893

Signed-off-by: Patrick Strawderman <pstrawderman@netflix.com>
2025-05-14 09:58:23 +02:00
Juergen Hoeller
73f1c5a189 Polishing 2025-05-13 16:08:57 +02:00
Juergen Hoeller
4d296fb4ca Upgrade to Micrometer 1.14.7
Includes Jackson 2.18.4, Jetty 12.0.21, Netty 4.1.121, Apache HttpClient 5.4.4, Checkstyle 10.23.1

Closes gh-34889
2025-05-13 16:08:31 +02:00
Juergen Hoeller
6a9444473f Clarify CompositePropertySource behavior for EnumerablePropertySource contract
Closes gh-34886
2025-05-13 16:08:03 +02:00
Sam Brannen
03ae97b2eb Introduce Spring property for default escape character for placeholders
Spring Framework 6.2 introduced support for an escape character for
property placeholders (by default '\'). However, as of Spring Framework
6.2.6, there was no way to either escape the escape character or disable
escape character support.

For example, given a `username` property configured with the value of
`Jane.Smith` and a `DOMAIN\${username}` configuration string, property
placeholder replacement used to result in `DOMAIN\Jane.Smith` prior to
6.2 but now results in `DOMAIN${username}`. Similarly, an attempt to
escape the escape character via `DOMAIN\\${username}` results in
`DOMAIN\${username}`.

In theory, one should be able to disable use of an escape character
altogether, and that is currently possible by invoking
setEscapeCharacter(null) on AbstractPropertyResolver and
PlaceholderConfigurerSupport (the superclass of
PropertySourcesPlaceholderConfigurer).

However, in reality, there are two hurdles.

- As of 6.2.6, an invocation of setEscapeCharacter(null) on a
  PropertySourcesPlaceholderConfigurer applied to its internal
  top-level PropertySourcesPropertyResolver but not to any nested
  PropertySourcesPropertyResolver, which means that the `null` escape
  character could not be effectively applied.

- Users may not have an easy way to explicitly set the escape character
  to `null` for a PropertyResolver or
  PropertySourcesPlaceholderConfigurer. For example, Spring Boot
  auto-configures a PropertySourcesPlaceholderConfigurer with the
  default escape character enabled.

This first issue above has recently been addressed by gh-34861.

This commit therefore addresses the second issue as follows.

- To allow developers to easily revert to the pre-6.2 behavior without
  changes to code or configuration strings, this commit introduces a
  `spring.placeholder.escapeCharacter.default` property for use with
  SpringProperties which globally sets the default escape character that
  is automatically configured in AbstractPropertyResolver and
  PlaceholderConfigurerSupport.

- Setting the property to an empty string sets the default escape
  character to `null`, effectively disabling the default support for
  escape characters.

    spring.placeholder.escapeCharacter.default =

- Setting the property to any other character sets the default escape
  character to that specific character.

    spring.placeholder.escapeCharacter.default = ~

- Setting the property to a string containing more than one character
  results in an exception.

- Developers are still able to configure an explicit escape character
  in AbstractPropertyResolver and PlaceholderConfigurerSupport if they
  choose to do so.

- Third-party components that wish to rely on the same feature can
  invoke AbstractPropertyResolver.getDefaultEscapeCharacter() to obtain
  the globally configured default escape character.

See gh-9628
See gh-34315
See gh-34861
Closes gh-34865
2025-05-13 13:37:30 +02:00
Sam Brannen
e34cdc2a55 Improve Javadoc for property placeholder support 2025-05-12 17:25:49 +02:00
Sam Brannen
8b1b9ef9e5 Stop redefining placeholder syntax constants in PlaceholderConfigurerSupport 2025-05-12 17:21:37 +02:00
Sam Brannen
efdaae02e0 Add test for late binding from Environment property sources
This new test serves as a "regression test" for behavior tested in
Spring Boot.

See gh-34861
2025-05-11 16:41:19 +02:00
Sam Brannen
49ffb833a3 Sort methods to align with PropertySource declaration order
See gh-34861
2025-05-11 15:48:00 +02:00
Sam Brannen
065e50a444 Override containsProperty() in FallbackEnvironmentPropertySource
This commit overrides containsProperty() in
FallbackEnvironmentPropertySource for consistency with the
implementation of ConfigurableEnvironmentPropertySource.

See gh-34861
2025-05-11 15:44:51 +02:00
Sam Brannen
7135527765 Always obtain fresh PropertySources in ConfigurableEnvironmentPropertySource
Although it's unlikely that the implementation of getPropertySources()
in a ConfigurableEnvironment would be overridden to return a different
MutablePropertySources instance than the one that the
ConfigurableEnvironment typically acts on, it is in fact possible.

In light of that possibility, this commit refactors
ConfigurableEnvironmentPropertySource so that it always obtains a fresh
PropertySources reference.

See gh-34861
2025-05-11 15:30:09 +02:00
Sam Brannen
65e30132f3 Revert "Introduce CompositePropertySource constructor that accepts Iterable<PropertySource>"
This reverts commit 0867dfca33.
2025-05-11 14:10:54 +02:00
Sam Brannen
ebb44a8368 Restore support for non-EnumerablePropertySource in PropertySourcesPlaceholderConfigurer
Commit 3295289e17 fixed a number issues with placeholder resolution in
PropertySourcesPlaceholderConfigurer. However, in doing so, it replaced
a raw PropertySource with a CompositePropertySource which implements
EnumerablePropertySource.

Consequently, all property sources registered in the Environment must
now implement EnumerablePropertySource (which is not an actual
requirement). Otherwise, invocations of getPropertyNames() on the
CompositePropertySource result in an IllegalStateException, and that is
a breaking change which resulted in numerous build failures within the
Spring portfolio.

To address that regression, this commit introduces a private
ConfigurableEnvironmentPropertySource in
PropertySourcesPlaceholderConfigurer which is a "raw" PropertySource
that delegates directly to the PropertySources in a
ConfigurableEnvironment.

This commit also extracts the raw PropertySource for direct Environment
delegation into a new FallbackEnvironmentPropertySource.

See gh-17385
Closes gh-34861
2025-05-11 13:46:11 +02:00
Sam Brannen
3096bb6d0c Polishing 2025-05-11 13:24:40 +02:00
Sam Brannen
2b2a57b4a3 Polish Javadoc 2025-05-10 15:44:08 +02:00
Sam Brannen
3295289e17 Fix placeholder resolution in PropertySourcesPlaceholderConfigurer
Currently, the placeholder resolution algorithm in
PropertySourcesPlaceholderConfigurer fails in several scenarios, and
the root cause for this category of failures has actually existed since
PropertySourcesPlaceholderConfigurer was introduced in Spring Framework
3.1.

Specifically, PropertySourcesPlaceholderConfigurer creates its own
PropertySourcesPropertyResolver that indirectly delegates to another
"nested" PropertySourcesPropertyResolver to interact with
PropertySources from the Environment, which results in double
placeholder parsing and resolution attempts, and that behavior leads to
a whole category of bugs.

For example, #27947 was addressed in Spring Framework 5.3.16, and due
to #34315 and #34326 we have recently realized that additional bugs
exist with placeholder resolution: nested placeholder resolution can
fail when escape characters are used, and it is currently impossible
to disable the escape character support for nested resolution.

To address this category of bugs, we no longer indirectly use or
directly create a "nested" PropertySourcesPropertyResolver in
PropertySourcesPlaceholderConfigurer. Instead, properties from property
sources from the Environment are now accessed directly without
duplicate/nested placeholder resolution.

See gh-27947
See gh-34326
See gh-34862
Closes gh-34861
2025-05-10 15:14:50 +02:00
Sam Brannen
457e876303 Polish reference manual regarding placeholders 2025-05-10 15:10:29 +02:00
Sam Brannen
021bf6e77d Add more tests for escape character support in PlaceholderParser 2025-05-10 14:19:41 +02:00
Sam Brannen
90453643cc Simplify and revise PlaceholderParserTests for consistency 2025-05-10 14:16:49 +02:00
Sam Brannen
5a2cbc1ab3 Polish PropertySourcesPropertyResolverTests 2025-05-09 16:43:04 +02:00
Sam Brannen
348b4cd067 Polish contribution
See gh-34720
2025-05-09 16:32:13 +02:00
Fawzi Essam
9b52cfd7d5 Test escape character support in PropertySourcesPropertyResolver
See gh-34326
See gh-34720
See gh-34861

Signed-off-by: Fawzi Essam <iifawzie@gmail.com>
2025-05-09 16:31:27 +02:00
Sam Brannen
dd6eede243 Properly expand reused collection parameters in R2DBC NamedParameterUtils
Prior to this commit, NamedParameterUtils in spring-r2dbc did not
properly expand reused collection parameters. Specifically, values in a
supplied collection were only expanded in the resulting query once, for
the first occurrence of the named parameter.

To address that, this commit effectively reinstates the original logic
for ExpandedQuery from NamedParameterUtils in the Spring Data R2DBC
project.

94958f5eb6/spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/core/NamedParameterUtils.java (L486)

Closes gh-34768
2025-05-09 14:27:19 +02:00
Sam Brannen
de97e35189 Polish Javadoc and internals of R2DBC support 2025-05-09 14:04:10 +02:00
Sam Brannen
45a2c51fe1 Polish Javadoc for Environment-related components 2025-05-08 10:49:44 +02:00
Sam Brannen
b98c3257af Introduce @⁠Disabled failing test for R2DBC NamedParameterUtils
The last assertion of the new test method currently fails since "foo"
is only bound once.

java.lang.AssertionError:
Expected size: 2 but was: 1 in:
{0="foo"}

See gh-34768
2025-05-07 17:30:07 +02:00
Sam Brannen
ea8ae09cb7 Revise NamedParameterUtilsTests for consistency 2025-05-07 17:24:41 +02:00
Sam Brannen
0abfad870c Polish class-level Javadoc for SpringProperties 2025-05-07 16:14:23 +02:00
Sam Brannen
5a9af9e024 Document AotDetector.AOT_ENABLED flag in SpringProperties
Prior to this commit, the AotDetector.AOT_ENABLED flag was documented
in the reference manual not in the Javadoc for SpringProperties.
2025-05-07 16:14:07 +02:00
Sam Brannen
0867dfca33 Introduce CompositePropertySource constructor that accepts Iterable<PropertySource>
This commit introduces a new constructor for CompositePropertySource
that accepts a `String name` and an Iterable<PropertySource<?>>, which
allows a CompositePropertySource to be constructed from existing
property sources, such as an instance of MutablePropertySources.

Closes gh-34862
2025-05-07 14:25:13 +02:00
Sam Brannen
b4355dc955 Polishing 2025-05-07 12:42:40 +02:00
Sam Brannen
bc91e0ea96 Revise PropertyResolver Javadoc to highlight resolution semantics 2025-05-06 18:50:33 +02:00
Sam Brannen
8599ee6c2b Polish Javadoc 2025-05-06 16:07:46 +02:00
Sam Brannen
bc466022b1 Fix typo in parameter name 2025-05-06 16:07:46 +02:00
Brian Clozel
6f11711e27 Fix HttpClient 5.3.x request config compatibility
As of gh-33806, the HttpComponents client request factory is forward
compatible with the 5.4+ versions of that library for configuring HTTP
request configuration.

This change would not tkae into account configuration set at the Spring
level because it would consider the default `RequestConfig` instance as
a custom one. This commit ensures that Spring sets its own configuration
if no custom configuration was set for all supported HttpComponents
generations.

Fixes gh-34851
2025-05-05 14:38:30 +02:00
rstoyanchev
c067919173 Ensure Fragment can merge attributes
Use a new map when merging as the original may be immutable.

Closes gh-34848
2025-05-02 15:58:51 +01:00
rstoyanchev
ac773d97e9 Polishing contribution
Closes gh-34828
2025-05-02 15:58:51 +01:00
Artur
bd7007227c Provide a working example instead of unclear placeholders
See gh-34828

Signed-off-by: Artur <artur@vaadin.com>
2025-05-02 15:58:51 +01:00
Sam Brannen
e8f873a349 Ensure Bean Overrides are discovered once in hierarchies
Prior to this commit, bean overrides (such as @⁠MockitoBean, etc.) were
discovered multiple times if they were declared:

- at the type-level on an interface that is implemented at more than
  one level in the type hierarchy, the enclosing class hierarchy, or a
  combination of the type and enclosing class hierarchies.

or

- on a field declared in a class which can be reached multiple times
  while traversing the type and enclosing class hierarchies in
  scenarios such as the following: the class (X) in which the field is
  declared is a supertype of an enclosing type of the test class, and X
  is also an enclosing type of a supertype of the test class.

Such scenarios resulted in an IllegalStateException stating that a
duplicate BeanOverrideHandler was discovered.

To address that, this commit revises the search algorithm in
BeanOverrideHandler so that all types (superclasses, enclosing classes,
and implemented interfaces) are only visited once while traversing the
type and enclosing class hierarchies in search of bean override
handlers.

See gh-33925
See gh-34324
Closes gh-34844
2025-05-02 11:26:33 +02:00
Sam Brannen
b943817f3e Close ApplicationContext after test AOT processing
See commit 1c108054ee
Closes gh-34841
2025-05-01 10:50:38 +02:00
Juergen Hoeller
4466548f53 Align parameter javadoc with nullable signature
Closes gh-34845
2025-04-30 17:55:39 +02:00