2320 Commits

Author SHA1 Message Date
Vincent Potucek
0d4dfb6c1f Rename exception variables in empty catch blocks
The Spring codebase sometimes ignores exceptions in catch blocks on
purpose. This is often called out by an inline comment.
We should make this more obvious by renaming the exception argument in
the catch block to declare whether the exception is "ignored" or
"expected".

See gh-35047

Signed-off-by: Vincent Potucek <vpotucek@me.com>
[brian.clozel@broadcom.com: rework commit message]
Signed-off-by: Brian Clozel <brian.clozel@broadcom.com>
2025-06-15 16:11:42 +02:00
Sam Brannen
077146d636 Merge branch '6.2.x' 2025-06-09 14:12:45 +02:00
Sam Brannen
18d6a55e3e Polishing and removal of "this." for method invocations 2025-06-09 14:10:30 +02:00
Sam Brannen
5752585bb2 Clean up warnings in build 2025-06-07 12:37:27 +02:00
Sam Brannen
0b4f7f2f9d Remove obsolete code
The hasNullableAnnotation() method was made obsolete in commit
b5d153febf.

See gh-34952
See gh-34261
2025-06-07 12:23:56 +02:00
Sam Brannen
3aa3b81e1c Update copyright headers 2025-06-06 13:49:23 +02:00
Johnny Lim
7f6a7b806e Replace AssertionsForClassTypes with Assertions
Closes gh-34821

Signed-off-by: Johnny Lim <izeye@naver.com>
2025-06-06 13:49:23 +02:00
Sam Brannen
af4fc0118c Update copyright header 2025-06-04 14:53:31 +02:00
rstoyanchev
230540b6da Polishing contribution
Closes gh-34942
2025-06-04 13:46:22 +01:00
Yanming Zhou
f9fa7cc93b Add missing "since" in @Deprecated
See gh-34942

Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
2025-06-04 13:46:22 +01:00
Patrick Strawderman
9501bff1f0 Use HexFormat in CharacterEditor
Use HexFormat to perform conversion for unicode-prefixed Strings in CharacterEditor.

Closes gh-34798

Signed-off-by: Patrick Strawderman <pstrawderman@netflix.com>
2025-06-03 18:20:19 +02:00
Sam Brannen
45ba4ace39 Merge branch '6.2.x' 2025-06-02 17:00:50 +02:00
Sam Brannen
707b7698ce Consistent @⁠Contract expression formatting 2025-06-02 17:00:28 +02:00
Sam Brannen
05d59271d2 Merge branch '6.2.x' 2025-06-02 10:48:28 +02:00
Dmytro Nosan
c2d678879f Fix AOT code generation for autowired inner class constructor
Prior to this commit, argument index handling in
AutowiredArgumentsCodeGenerator suffered from an off-by-one error when
generating code for an autowired inner class constructor.

Since the startIndex is already properly calculated for an inner class in
InstanceSupplierCodeGenerator.buildGetInstanceMethodForConstructor(...),
there is no need to adjust the argument indexes within
AutowiredArgumentsCodeGenerator.generateCode(...).

Closes gh-34974

Signed-off-by: Dmytro Nosan <dimanosan@gmail.com>
2025-06-02 10:43:21 +02:00
Sam Brannen
c5566c947c Merge branch '6.2.x' 2025-05-30 14:55:22 +02:00
Sam Brannen
016294b067 Avoid overriding methods deprecated in JUnit Jupiter 5.13
See gh-34969
2025-05-30 14:54:57 +02:00
Sébastien Deleuze
3290592f58 Remove Kotlin field handling in DependencyDescriptor
The KotlinDelegate#isNullable invocation is unnecessary since this check
is already done by the Nullness#forField one introduced by
b5d153febf.

See gh-34952
See gh-34261
2025-05-28 14:39:44 +02:00
Sébastien Deleuze
a638828157 Merge branch '6.2.x' 2025-05-28 10:31:34 +02:00
Sébastien Deleuze
67ed64a41d Remove not null checks in BeanUtilsKotlinTests 2025-05-28 10:31:07 +02:00
Sébastien Deleuze
d777b70889 Ignore DefaultConstructorMarker in BeanUtils#getParameterNames
Closes gh-34760
2025-05-28 10:12:09 +02:00
Sam Brannen
eb59d911cd Merge branch '6.2.x' 2025-05-27 11:32:25 +02:00
Sam Brannen
472c4012ca Remove obsolete note from Javadoc for BeanDefinitionReader 2025-05-27 11:32:05 +02:00
Juergen Hoeller
b5d153febf Enforce consistent null check on injection points for pre-existing singleton beans
Includes consistent JSpecify nullness check on fields as optional injection points

Closes gh-34952
See gh-34261
2025-05-27 10:25:50 +02:00
Juergen Hoeller
cdfe0895f9 Merge branch '6.2.x' 2025-05-27 09:57:01 +02:00
Juergen Hoeller
d9e261aecd Enforce backwards compatibility for null bean in shortcut code path
Closes gh-34929
2025-05-27 09:47:39 +02:00
Sébastien Deleuze
eed0a3ff59 Allow access to env from SupplierContextDsl
Closes gh-34943
2025-05-26 11:55:34 +02:00
Sébastien Deleuze
e02e67b39f Polish BeanRegistrarDsl Javadoc 2025-05-19 13:09:14 +02:00
Sébastien Deleuze
aa9ab8e545 Add support for callable references to BeanRegistrarDsl
BeanDefinitionDsl is allowing to create a bean from a callable
reference with its parameters autowired by type,
BeanRegistrarDsl should allow that too. For example:

class SampleBeanRegistrar : BeanRegistrarDsl({
    registerBean<MyRepository>()
    registerBean(::myRouter)
})

fun myRouter(myRepository: MyRepository) = router {
    ...
}

Closes gh-34922
2025-05-19 13:09:04 +02:00
Juergen Hoeller
1187bc2016 Merge branch '6.2.x'
# Conflicts:
#	spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java
2025-05-15 01:48:01 +02: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
Juergen Hoeller
46e6783593 Polishing 2025-05-13 16:42:57 +02:00
Sam Brannen
680094d74e Merge branch '6.2.x' 2025-05-13 13:45:37 +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
18756c0701 Merge branch '6.2.x' 2025-05-12 17:27:38 +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
33aeb6ee9c Deprecate [Property|Preferences]PlaceholderConfigurer for removal
PropertyPlaceholderConfigurer and PreferencesPlaceholderConfigurer have
been officially deprecated since Spring Framework 5.2.

Since we no longer expect applications to depend on these outdated
mechanisms, this commit deprecates these classes "for removal" in
Spring Framework 8.0.

Closes gh-34880
2025-05-11 17:03:42 +02:00
Sam Brannen
6878587a33 Merge branch '6.2.x' 2025-05-10 15:44:23 +02:00
Sam Brannen
2b2a57b4a3 Polish Javadoc 2025-05-10 15:44:08 +02:00
Sam Brannen
964d67474c Merge branch '6.2.x' 2025-05-06 16:08:20 +02:00
Sam Brannen
bc466022b1 Fix typo in parameter name 2025-05-06 16:07:46 +02:00
Juergen Hoeller
f2dd7b01cd Consistent final @Nullable declarations 2025-04-22 12:25:01 +02:00
Juergen Hoeller
78f901649e Merge branch '6.2.x'
# Conflicts:
#	spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java
2025-04-22 12:18:44 +02:00
Juergen Hoeller
1841ad3472 Consistently use local copy of volatile mainThreadPrefix field
Closes gh-34746
2025-04-22 12:17:03 +02:00
Seonghun Jeong
d3a5aefdff Improve handling of mainThreadPrefix and remove redundant null check (#34746) 2025-04-22 12:16:34 +02:00
Stéphane Nicoll
e3e99ac8a0 Add a convenience method to create a ValueCodeGenerator
This commit makes BeanDefinitionPropertyValueCodeGeneratorDelegates
public and offer a convenience method to create a ValueCodeGenerator
that works will all core delegates.

Closes gh-34761
2025-04-15 17:17:45 +02:00
Sam Brannen
d5baab2aed Merge branch '6.2.x' 2025-04-14 14:16:31 +02:00
Sam Brannen
d0966dfb58 Revise contribution
See gh-34747
2025-04-14 14:15:50 +02:00
lituizi
bb45a3ae69 Update AbstractAutowireCapableBeanFactory.ignoreDependencyInterface() Javadoc
Specifically, the documentation update reflects that:

- Initially, it was mentioned that only the `BeanFactoryAware`
  interface is ignored by default.

- The updated documentation now correctly states that `BeanNameAware`,
  `BeanFactoryAware`, and `BeanClassLoaderAware` interfaces are all
  ignored by default.

This change ensures a more accurate representation of the default
behavior regarding which dependency interfaces are automatically
ignored during autowiring in the context of Spring's bean factory
mechanism.

Closes gh-34747

Signed-off-by: lituizi <2811328244@qq.com>
2025-04-14 14:07:35 +02:00