Commit Graph

30168 Commits

Author SHA1 Message Date
Juergen Hoeller
e4f35ebcc5 Merge branch '6.1.x' 2024-05-22 10:01:30 +02:00
Juergen Hoeller
ea596aa211 Select most specific advice method in case of override
Closes gh-32865
2024-05-22 10:00:31 +02:00
Brian Clozel
1bd6b30ddd Allow ServerHttpObservationFilter to be extended
This commit allows to extend  the `ServerHttpObservationFilter` when the
observation scope is opened. This typically allows to add the current
traceId as a response header.

Closes gh-30632
2024-05-21 20:01:17 +02:00
Juergen Hoeller
559fec052f Merge branch '6.1.x' 2024-05-21 19:22:55 +02:00
Juergen Hoeller
58da30cd30 Upgrade to Jetty Reactive HttpClient 4.0.4 2024-05-21 19:22:20 +02:00
Juergen Hoeller
cd33b4e35a Polishing 2024-05-21 18:25:57 +02:00
Juergen Hoeller
0e5e81e7ef Merge branch '6.1.x' 2024-05-21 17:39:59 +02:00
Juergen Hoeller
20dea0dae2 Polishing 2024-05-21 17:39:11 +02:00
Juergen Hoeller
fee17e11ba Default fallback parsing for UTC without milliseconds
Closes gh-32856
2024-05-21 17:39:06 +02:00
rstoyanchev
8c9b6e2205 Use default phase 0 for WebSocket messaging
Closes gh-27519
2024-05-21 15:49:38 +01:00
Simon Baslé
d5c7a5e2db Bean overriding by type uses isAutowireCandidate for matching
This commit uses the bean factory `isAutowiredCandidate` method directly
in `BeanOverrideBeanFactoryPostProcessor` to select a single match among
multiple candidates when matching by type.

The expected consequence, in most cases, is that this will delegate to
a `@Qualifier`-aware `QualifierAnnotationAutowireCandidateResolver`.
In that sense, bean overriding by-type matching is now potentially
taking Qualifier annotations or meta-annotations into account.

It also changes the way existing bean definitions are checked in case
a bean name has been specified: factory beans are now taken into account
when checking the type of an existing definition matches the expected
bean override type.

Closes gh-32822
2024-05-21 14:06:52 +02:00
Simon Baslé
b17d1c5124 Polishing BeanOverrideBeanFactoryPostProcessor to also copy isFallback 2024-05-21 14:06:52 +02:00
Juergen Hoeller
6f6e25bd5b Merge branch '6.1.x' 2024-05-21 11:17:16 +02:00
Juergen Hoeller
65e1337d35 Polishing 2024-05-21 11:16:25 +02:00
Juergen Hoeller
a4c2f291d9 Avoid creation of SAXParserFactory for every read operation
Includes JAXBContext locking revision (avoiding synchronization) and consistent treatment of DocumentBuilderFactory (in terms of caching as well as locking).

Closes gh-32851
2024-05-21 11:16:19 +02:00
Stéphane Nicoll
ddf5521bc9 Merge branch '6.1.x' 2024-05-21 08:56:41 +02:00
Stéphane Nicoll
f26483d272 Detect deprecated element in generic types
This commit updates Spring AOT to suppress a deprecation warning for
a generic type that has a deprecated element. Previously we only were
checking for the raw class.

Closes gh-32850
2024-05-21 08:53:18 +02:00
Brian Clozel
4d4b343815 Support Content Negotiation with @ExceptionHandler
Prior to this commit, `@ExceptionHandler` annotated controller methods
could be mapped using the exception type declaration as an annotation
attribute, or as a method parameter.
While such methods support a wide variety of method arguments and return
types, it was not possible to declare the same exception type on
different methods (in the same controller/controller advice).

This commit adds a new `produces` attribute on `@ExceptionHandler`; with
that, applications can vary the HTTP response depending on the exception
type and the requested content-type by the client:

```
@ExceptionHandler(produces = "application/json")
public ResponseEntity<ErrorMessage> handleJson(IllegalArgumentException exc) {
	return ResponseEntity.badRequest().body(new ErrorMessage(exc.getMessage(), 42));
}

@ExceptionHandler(produces = "text/html")
public String handle(IllegalArgumentException exc, Model model) {
	model.addAttribute("error", new ErrorMessage(exc.getMessage(), 42));
	return "errorView";
}
```

This commit implements support in both Spring MVC and Spring WebFlux.

Closes gh-31936
2024-05-20 17:22:30 +02:00
Stéphane Nicoll
991be14847 Merge branch '6.1.x' 2024-05-20 13:58:44 +02:00
Stéphane Nicoll
481d036f7a Avoid reader on empty content to be shared by multiple requests
This commit avoids several instances of MockHttpServletRequest to
have a common reader for empty content as closing it will have an
unwanted side effect on the others.

Closes gh-32820
2024-05-20 13:58:36 +02:00
Stéphane Nicoll
99adc58ee3 Merge branch '6.1.x' 2024-05-20 13:58:09 +02:00
Stéphane Nicoll
f2605fd9e5 Avoid reader on empty content to be shared by multiple requests
This commit avoids several instances of MockHttpServletRequest to
have a common reader for empty content as closing it will have an
unwanted side effect on the others.

Closes gh-32820
2024-05-20 13:32:04 +02:00
Stéphane Nicoll
4bbfd4c5e7 Add convenient request/response accessors on MvcTestResult
Closes gh-32846
2024-05-20 11:19:12 +02:00
Sébastien Deleuze
268043a28c Merge branch '6.1.x' 2024-05-20 10:24:42 +02:00
Sébastien Deleuze
2a2ef443a5 Refine CDS documentation
Closes gh-32843
2024-05-20 10:24:29 +02:00
Juergen Hoeller
f0c6fab39e Merge branch '6.1.x'
# Conflicts:
#	gradle.properties
#	spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java
2024-05-17 12:30:39 +02:00
Juergen Hoeller
617833bec9 Defensively catch and log pointcut parsing exceptions
Closes gh-32838
See gh-32793
2024-05-17 12:27:59 +02:00
Sam Brannen
93387e69b5 Polishing 2024-05-16 16:47:02 +02:00
Spring Builds
4d633c2ea8 Next development version (v6.1.8-SNAPSHOT) 2024-05-16 09:04:43 +00:00
Juergen Hoeller
28398624bf Avoid cyclic package import for javadoc reference 2024-05-15 22:19:20 +02:00
rstoyanchev
da3b59e7a9 Merge branch '6.1.x' 2024-05-15 20:07:13 +01:00
rstoyanchev
010e8a303b Polishing contribution
Closes gh-32799
2024-05-15 20:06:48 +01:00
Matteo Cristoforo
78549d4963 Fix cookie management in reactive JdkClientHttpRequest
Prevent cookies to be set to empty in the HTTP request if no cookie
is present

See gh-32799
2024-05-15 20:02:04 +01:00
rstoyanchev
edb6bb717d Add UrlHandlerFilter
Closes gh-31366
2024-05-15 18:45:07 +01:00
rstoyanchev
48ad7b1bcd Remove unused code in WebHttpHandlerBuilder
The code was necessary while ForwardedHeaderFilter was deprecated
but still possible to use. When the filter was removed, this code
could have been removed as well.
2024-05-15 18:45:07 +01:00
SharadK10
a3b62a80bc Improve wording in Spring Framework Overview documentation
Closes gh-32829
2024-05-15 19:00:27 +02:00
Sam Brannen
6cdb34410b Register DynamicPropertyRegistry as singleton bean in test ApplicationContext
Prior to this commit, DynamicPropertyRegistry could only be used with a
static @⁠DynamicPropertySource method in an integration test class;
however, it can also be useful to be able to register a "dynamic
property" from within a test's ApplicationContext -- for example, in a
@⁠Bean method in a @⁠Configuration class that is specific to testing
scenarios.

To support such use cases, this commit updates the dynamic property
source infrastructure so that a DynamicPropertyRegistry is always
registered as a singleton bean in a test's ApplicationContext. This
allows DynamicPropertyRegistry to be autowired into a @⁠Configuration
class or supplied to a @⁠Bean method as an argument as shown in the
following example.

@⁠Bean
@⁠DynamicPropertySource
ApiServer apiServer(DynamicPropertyRegistry registry) {
	ApiServer apiServer = new ApiServer();
	registry.add("api.url", apiServer::getUrl);
	return apiServer;
}

Note that the use of @⁠DynamicPropertySource on the @⁠Bean method is
optional and results in the corresponding bean being eagerly
initialized so that other singleton beans in the context can be given
access to the dynamic properties sourced from that bean when those
other beans are initialized.

Side note: DynamicPropertySourceBeanInitializer temporarily implements
LoadTimeWeaverAware since doing so is currently the only way to have a
component eagerly initialized before the
ConfigurableListableBeanFactory.preInstantiateSingletons() phase.
However, we plan to introduce a first-class callback to support such
use cases in the future.

Closes gh-32271
2024-05-15 17:09:03 +02:00
Juergen Hoeller
7d8279afec Merge branch '6.1.x' 2024-05-15 14:16:51 +02:00
Juergen Hoeller
e4e6910122 Polishing 2024-05-15 14:15:52 +02:00
Juergen Hoeller
2270df515b Enforce cleaned URL for root resource from ClassLoader
Closes gh-32828
2024-05-15 14:15:47 +02:00
Sam Brannen
d625b3de27 Document SpEL IndexAccessor support in the reference manual
Closes gh-32735
2024-05-15 11:47:42 +02:00
Simon Baslé
531da015e1 Improve MediaTypeAssert to-string-equality assertions
This commit introduces a `isNotEqualTo(String)` assertion in order to
avoid false negatives when using the default Object-based assertion.

This is a risk since MediaTypeAssert has a `isEqualTo(String)` method
that overrides the base object method and parses the provided String
into a MediaType. Users may thus be tempted to use the reverse assertion
and expect the same parsing behaviour.

This commit also adds tests around the String parsing and the isNotEqual
cases.

Closes gh-32756
2024-05-15 11:14:13 +02:00
Juergen Hoeller
60c5f44e1d Upgrade reactor.util.annotation content
See gh-32785
2024-05-14 22:59:43 +02:00
Juergen Hoeller
c69ab069b7 Upgrade to Reactor 2024.0.0-M2
Closes gh-32785
2024-05-14 22:03:38 +02:00
Juergen Hoeller
7c534eeeeb Merge branch '6.1.x'
# Conflicts:
#	framework-platform/framework-platform.gradle
2024-05-14 22:02:32 +02:00
Juergen Hoeller
70886e32c0 Upgrade to Reactor 2023.0.6
Includes AspectJ 1.9.22.1, Tomcat 10.1.24, Jetty 12.0.9, Mockito 5.12

Closes gh-32786
2024-05-14 22:01:07 +02:00
Juergen Hoeller
e509385eae Add InputStreamResource(InputStreamSource) constructor for lambda expressions
Includes notes for reliable InputStream closing, in particular with Spring MVC.

Closes gh-32802
2024-05-14 21:59:42 +02:00
Sam Brannen
716e7de841 Simplify implementation of SpelNodeImpl.loadClassForExitDescriptor(...) 2024-05-14 17:58:05 +02:00
Brian Clozel
f7a6a7b814 Allow ReflectionHints to register hints on interface hierarchies
This commit promotes a previously private method in
`BeanRegistrationsAotContribution` to a top-level method in
`ReflectionHints`.

This helps to register hints on all interfaces implemented in the class
hierarchy of the given type.

Closes gh-32824
2024-05-14 17:54:12 +02:00
Simon Baslé
a86612a254 Use by-type semantics in bean overriding if no explicit name is provided
This change switches default behavior of `@TestBean`, `@MockitoBean` and
`@MockitoSpyBean` to match the bean definition / bean to override by
type in the case there is no explicit bean name provided via the
annotation. The previous behavior of using the annotated field's name
is still an option for implementors, but no longer the default.

Closes gh-32761
2024-05-14 16:42:11 +02:00