Commit Graph

32657 Commits

Author SHA1 Message Date
Sam Brannen
d44701f828 Extract WrapEarlyBeanPostProcessor to top-level class 2024-10-03 16:39:43 +02:00
Sam Brannen
4c3bc3ba69 Emulate AbstractAotProcessor.process() in AotIntegrationTests 2024-10-03 16:39:43 +02:00
Simon Baslé
6c5e63e446 Merge branch '6.1.x' 2024-10-03 16:33:40 +02:00
Simon Baslé
b54420f8aa Include argument name in MethodArgumentTypeMismatchException message
Closes gh-33573
2024-10-03 16:32:29 +02:00
Sam Brannen
32309e86ce Fix context caching for Bean Overrides w/ different annotation order
Prior to this commit, ApplicationContext caching support was broken if
two Bean Override fields declared the same annotations but in a
different order.

This commit fixes that by switching to Set semantics for the
annotations declared on a Bean Override field.

Closes gh-33633
2024-10-02 11:23:48 +02:00
Brian Clozel
8cd2c40860 Improve random source in SockJS server support
Prior to this commit, the SockJs server support would use
`java.util.Random` to send a random value to clients when they request
the `/info` endpoint. Per protocol, clients can use this value as a
source of entropy for generating a random session id.

In practice, this is not used by clients. For example, the SockJS
javascript client is using a cryptographically safe API to generate
session ids.

While this has no concrete effect on known clients, this commit improves
the random source in the server support by switching to
`java.security.SecureRandom`.

Closes gh-33632
2024-10-01 21:29:19 +02:00
Sam Brannen
309897497a Update copyright header 2024-10-01 12:35:01 +02:00
Hyunwoo Kim
893f5dcb9b Replace "null" with NULL_STRING constant in ObjectUtils.nullSafeConciseToString()
Closes gh-33625
2024-10-01 12:33:40 +02:00
Sam Brannen
a21c557101 Do not replace existing Bean Override definition with pseudo-definition
Prior to this commit, BeanOverrideBeanFactoryPostProcessor replaced
existing bean definitions with "pseudo" bean definitions; however, that
is unnecessary. An existing BeanDefinition is suitable as-is and does
not need to be replaced with a pseudo/fake definition.

To address that, this commit reregisters an existing bean definition
and only registers a new bean definition when creating a bean
definition for a nonexistent bean.

As a side effect, we no longer need to copy primary and fallback flags.

Closes gh-33627
2024-10-01 12:20:27 +02:00
Sébastien Deleuze
56a0a33e5d Add a missing test case for ObjectUtils#unwrapOptional
Closes gh-33618
2024-10-01 09:42:58 +02:00
Tran Ngoc Nhan
4d87c77649 Add test cases for ObjectUtils#unwrapOptional
See gh-33618
2024-10-01 09:41:39 +02:00
SungbinYang
fc8bd64f34 Simplify ObjectUtils#unwrapOptional
This commit replaces optional.isEmpty() and optional.get() with
optional.orElse(null) for better efficiency and readability.

Closes gh-33612
2024-09-30 18:32:43 +02:00
Sam Brannen
1c87e4795d Introduce enforceOverride flag in @⁠TestBean and @⁠MockitoBean
Prior to this commit, @⁠MockitoBean could be used to either create or
replace a bean definition, but @⁠TestBean could only be used to replace
a bean definition.

However, Bean Override implementations should require the presence of
an existing bean definition by default (i.e. literally "override" by
default), while giving the user the option to have a new bean
definition created if desired.

To address that, this commit introduces a new `enforceOverride`
attribute in @⁠TestBean and @⁠MockitoBean that defaults to true but
allows the user to decide if it's OK to create a bean for a nonexistent
bean definition.

Closes gh-33613
2024-09-30 14:32:53 +02:00
Juergen Hoeller
30dc86810e Upgrade to Jackson 2.18
Closes gh-33615
2024-09-30 13:53:22 +02:00
Sam Brannen
38c9af2385 Merge branch '6.1.x' 2024-09-30 12:42:17 +02:00
Sam Brannen
0b3b1391c1 Avoid usage of deprecated AssertJ feature 2024-09-30 12:41:35 +02:00
Johnny Lim
64daba34de Upgrade to Awaitility 4.2.2
See gh-33143
Closes gh-33604
2024-09-30 12:36:54 +02:00
Juergen Hoeller
b59d0a396e Add equals/hashCode methods to ServerSentEvent
Closes gh-33606
2024-09-30 11:22:43 +02:00
Juergen Hoeller
8ab965c981 Merge branch '6.1.x'
# Conflicts:
#	spring-web/src/main/java/org/springframework/web/method/annotation/AbstractNamedValueMethodArgumentResolver.java
#	spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractNamedValueArgumentResolver.java
2024-09-30 11:17:55 +02:00
Juergen Hoeller
87157d3200 Polishing 2024-09-30 11:13:50 +02:00
Juergen Hoeller
95f181352f Defensively check MethodParameter.getMethod() in KotlinDelegate
Closes gh-33609
2024-09-30 11:13:26 +02:00
Simon Baslé
854f6ffd39 Merge branch '6.1.x' 2024-09-30 10:19:36 +02:00
Simon Baslé
e32a2f339d Propagate method error in some cases of reactive findInCaches errors
In a Cacheable reactive method, if an exception is propagated from
both the method and the caching infrastructure, an NPE could previously
surface due to the `CacheAspectSupport` attempting to perform an
`onErrorResume` with a `null`. This change ensures that in such a case
the user-level exception from the method is propagated instead.

Closes gh-33492
2024-09-30 10:18:59 +02:00
Sam Brannen
d79258ac73 Reject non-singletons in Test Bean Override support
Prior to this commit, a non-singleton FactoryBean was silently replaced
by a singleton bean. In addition, bean definitions for prototype-scoped
and custom-scoped beans were replaced by singleton bean definitions
that were incapable of creating the desired bean instance. For example,
if the bean type of the original bean definition was a concrete class,
an attempt was made to invoke the default constructor which either
succeeded with undesirable results or failed with an exception if the
bean type did not have a default constructor. If the bean type of the
original bean definition was an interface or a FactoryBean that claimed
to create a bean of a certain interface type, an attempt was made to
instantiate the interface which always failed with a
BeanCreationException.

To address the aforementioned issues, this commit reworks the logic in
BeanOverrideBeanFactoryPostProcessor so that an exception is thrown
whenever an attempt is made to override a non-singleton bean.

Closes gh-33602
2024-09-29 18:12:00 +02:00
Sam Brannen
4e9b503055 Polish OverrideMetadata 2024-09-29 18:02:09 +02:00
Sam Brannen
ba1d01d9b7 Add missing final declaration to OverrideMetadata.getBeanName() 2024-09-29 16:31:20 +02:00
Sam Brannen
5c08f81d80 Polishing 2024-09-29 16:28:06 +02:00
Sam Brannen
625614a4d2 Stop "collecting" annotations in MockitoAnnotationDetector
There is no need to collect/track the actual annotations. Rather, we
only need to know if there is at least once such annotation present.
2024-09-29 15:34:40 +02:00
Sam Brannen
40ca83dfd4 Revise Bean Override internals and Javadoc 2024-09-28 17:13:24 +02:00
Juergen Hoeller
56f3a48879 Merge branch '6.1.x'
# Conflicts:
#	spring-context/src/main/java/org/springframework/context/aot/AbstractAotProcessor.java
2024-09-27 19:17:32 +02:00
Juergen Hoeller
9f4968ed05 Polishing 2024-09-27 19:16:12 +02:00
Juergen Hoeller
b6cfa2db0b Refine warn log message with advisor and ROLE_INFRASTRUCTURE hints
Closes gh-33184
2024-09-27 19:16:05 +02:00
Sébastien Deleuze
8e3846991d Reuse NoTransactionInContextException instances
New NoTransactionInContextException instances are created frequently in
TransactionContextManager#currentContext() when there is no transaction,
we could reuse the same instance instead to reduce the GC pressure.

Closes gh-33601
2024-09-27 17:45:02 +02:00
Sam Brannen
bed3025274 Restructure BeanOverrideBeanFactoryPostProcessor and improve documentation 2024-09-27 17:08:08 +02:00
Sam Brannen
ea8b8ae910 Polishing 2024-09-27 17:03:49 +02:00
Sam Brannen
9c746905bc Test status quo for Bean Override singleton semantics
The tests introduced in this commit reveal the following issues in our
Bean Override support.

- If a FactoryBean signals it does not manage a singleton, the Bean
  Override support silently replaces it with a singleton.

- An attempt to override a prototype-scoped bean or a bean configured
  with a custom scope results in one of the following.

  - If the bean type of the original bean definition is a concrete
    class, an attempt will be made to invoke the default constructor
    which will either succeed with undesirable results or fail with an
    exception if the bean type does not have a default constructor.

  - If the bean type of the original bean definition is an interface or
    a FactoryBean that claims to create a bean of a certain interface
    type, an attempt will be made to instantiate the interface which
    will always fail with a BeanCreationException.
2024-09-27 15:42:12 +02:00
Sam Brannen
c3ff6cf319 Reverse engineer documentation for Bean Override internals 2024-09-27 15:39:35 +02:00
Sam Brannen
ded5c13e19 Reinstate BeanOverrideTestSuite 2024-09-27 13:48:56 +02:00
Juergen Hoeller
594ed95f3c Replace transaction isolation synchronization with ReentrantLock
Closes gh-33546
2024-09-27 11:36:21 +02:00
Juergen Hoeller
8680c43368 Check for advisor-introduced interfaces specifically
See gh-31304
2024-09-27 11:07:11 +02:00
Juergen Hoeller
d3dd01e227 Adapt transactional test component declaration
See gh-33470
2024-09-27 11:06:30 +02:00
오영택
cc3948e14c feat: Implemented to throw a runtime error if a class has @Transactional 2024-09-27 10:59:52 +02:00
Tran Ngoc Nhan
e3cf23d15a remove unused keyword 2024-09-26 21:49:22 +02:00
Juergen Hoeller
07d281c6d8 Expose public constant for spring.aot.processing system property
Closes gh-33388
2024-09-26 18:31:36 +02:00
Juergen Hoeller
5326640f79 Initialize application context with initializer-given ServletContext
Closes gh-22319
2024-09-26 18:31:02 +02:00
Juergen Hoeller
13b49d41c3 Merge branch '6.1.x' 2024-09-26 15:30:39 +02:00
Juergen Hoeller
26054d1ab0 Fix TargetSource setup for valid proxy interface specification
See gh-31304
2024-09-26 15:26:31 +02:00
Juergen Hoeller
552a5cde36 Create CGLIB proxy in case of no target interfaces (just introductions)
Closes gh-31304
2024-09-26 14:48:42 +02:00
Yanming Zhou
8941e2876e Replace 'e.g.' with 'for example' in documentation and comments
Closes gh-33515
2024-09-26 14:11:17 +02:00
Sam Brannen
e55fe9077f Make DynamicPropertyRegistrarBeanInitializer public
In order to allow third parties (for example, Spring Boot) to ensure
that a DynamicPropertyRegistrarBeanInitializer has been registered in
an ApplicationContext which has not been customized by the
DynamicPropertiesContextCustomizer, this commit converts
DynamicPropertyRegistrarBeanInitializer to a public API for use in such
special use cases.

Closes gh-33593
2024-09-26 13:01:57 +02:00