Commit Graph

25271 Commits

Author SHA1 Message Date
Vedran Pavic
7ea49fa9f4 Refactor CookieLocaleResolver
At present, CookieLocaleResolver extends CookieGenerator instead of
AbstractLocale(Context)Resolver like other LocaleResolver
implementations. This means it duplicates some common aspects of
LocaleResolver hierarchy while also exposing some CookieGenerator
operations, such as #addCookie and #removeCookie.

Additionally, CookieGenerator's support for writing cookies is based
on Servlet support which at current baseline doesn't support SameSite
directive.

This commit refactors CookieLocaleResolver to make it extend
AbstractLocaleContextResolver and also replaces CookieGenerator's
cookie writing support with newer and more capable ResponseCookie.
Simplify creation of CookieLocaleResolver with custom cookie name

This commit introduces CookieLocaleResolver constructor that accepts
cookie name thus allowing for a simpler creation of an instance with
the desired cookie name.

See gh-28779
2022-09-28 16:00:33 +01:00
Sam Brannen
f6d1806e30 Ensure DefaultListableBeanFactoryTests compiles in Eclipse IDE 2022-09-28 15:44:45 +02:00
Sam Brannen
6cb131ac76 Polishing 2022-09-28 14:27:36 +02:00
Sam Brannen
0eb66789ed Introduce generic FileSystem support in PathMatchingResourcePatternResolver
This commit introduces support in PathMatchingResourcePatternResolver
for resolving files in a generic fashion using the
java.nio.file.FileSystem API, including preliminary support for class
path scanning within a GraalVM native image.

See included commits for details.

Closes gh-29163
2022-09-28 13:53:31 +02:00
Sam Brannen
ccff526454 Reintroduce logging and exception handling for file system resource scanning
See gh-29163
2022-09-28 13:47:55 +02:00
Sam Brannen
7cb54de985 Apply root dir cleanup only for GraalVM native image resource scheme
See gh-29163
2022-09-28 13:47:44 +02:00
Sam Brannen
7a15805f6c Polish contribution
See gh-29163
2022-09-28 13:47:44 +02:00
Sam Brannen
0e22c3d89d Convert file: URL to FileSystemResource for backward compatibility
See gh-29163
2022-09-28 13:47:44 +02:00
Sam Brannen
508be4e0fa Update Javadoc to reflect changes
See gh-29163
2022-09-28 13:47:44 +02:00
Sam Brannen
385292dc41 Fix Checkstyle violations
See gh-29163
2022-09-28 13:47:44 +02:00
Dave Syer
f751b38795 Use java.nio and FileSystems to resolve files in PathMatchingResourcePatternResolver
The JDK has decent support for walking a file system (via the
FileSystem API in java.nio.file), but prior to this commit Spring still
used hand-rolled pre-Java 7 code. Also, in principle, FileSystem can be
an abstraction used to express any hierarchy of resources through their
URIs. This is a good fit with the Spring Resource abstraction, and for
instance would mean that GraalVM native images could potentially do
classpath scanning through a custom URI and FileSystem already provided
by GraalVM.

In light of the above, this commit overhauls the implementation of
PathMatchingResourcePatternResolver to use a java.nio.file.FileSystem
to find matching resources within a file system.

As a side effect, several obsolete `protected` methods have been
removed from PathMatchingResourcePatternResolver.

See gh-29163
2022-09-28 13:39:48 +02:00
Stephane Nicoll
c5fc0a5ef3 Add shortcut in TestGenerationContext 2022-09-28 11:20:35 +02:00
Stephane Nicoll
737967f924 Polish 2022-09-28 11:16:07 +02:00
Stephane Nicoll
38d91bafce Generate matching structure for configuration classes
This commit improves GeneratedClass to support inner classes, allowing
them to be registered by name with a type customizer, as
GeneratedClasses does for top level classes.

BeanDefinitionMethodGenerator leverages this feature to create a
matching structure for configuration classes that contain inner classes.

Closes gh-29213
2022-09-28 11:13:52 +02:00
rstoyanchev
b1ee44f12e Polishing contribution
Closes gh-27280
2022-09-27 17:08:52 +01:00
Ashley Scopes
d14477eb84 Add methods to DefaultResponseCreator & MockRestResponseCreators
New methods in DefaultResponseCreator for adding headers and cookies,
for specifying the character encoding when setting a string body on
a response, which is useful when working in environments that do not
automatically assume UTF-8, such as integrating with legacy
applications from a new Spring one.

New methods in MockRestResponseCreators support extra commonly used
HTTP status codes, including some that occur when working in AWS,
CloudFlare, or when using gateways such as Kong, where resilient
applications should be able to respond to ratelimits, gateway errors,
and gateway timeouts that may occur if a remote service is down.

Added test cases for any changes made.

See gh-27280
2022-09-27 15:58:44 +01:00
rstoyanchev
badba7c3e9 Support coma-delimited format for origin values
Closes gh-27606
2022-09-27 14:49:18 +01:00
Arjen Poutsma
d516667f37 Polish "Allow for CoroutineContext in invokeSuspendingFunction"
See gh-27193
2022-09-27 13:26:49 +02:00
Lukáš Křečan
ff844ed99f Allow overriding invokeSuspendingFunction
This commit isolates the invocation of Kotlin coroutines into a separate
template method, so that it can be overridden in subclasses of
RequestMappingHandlerAdapter.

Closes gh-27195
2022-09-27 13:26:28 +02:00
rstoyanchev
ac3ebc37dc Remove requestCompleted from RequestMappingHandlerAdapter
Closes gh-29002
2022-09-27 11:48:31 +01:00
rstoyanchev
c135549a4e Conditional initialization of messageConverters
Closes gh-27854
2022-09-27 11:37:25 +01:00
Arjen Poutsma
f80fbe30cc Allow for CoroutineContext in invokeSuspendingFunction
This commit adds an overloaded version of invokeSuspendingFunction
that specifies a CoroutineContext, instead of using
Dispatchers.Unconfined.

Closes gh-27193
2022-09-27 11:54:44 +02:00
Stephane Nicoll
dd3e3b2989 Merge branch 'gh-29207'
Closes gh-29207
2022-09-27 10:33:27 +02:00
Stephane Nicoll
e6aef11b09 Allow target to be a ClassName rather than an existing Class
See gh-29207
2022-09-27 10:33:14 +02:00
Stephane Nicoll
8ef850ff91 Update ClassNameGenerator to work with a ClassName target
This commit updates ClassNameGenerator so that it uses a ClassName for
its default target. This makes sure that a target that has been
generated can be used.

See gh-29027
2022-09-27 10:33:13 +02:00
Brian Clozel
1707a22c18 Merge branch '5.3.x' 2022-09-26 22:27:53 +02:00
Brian Clozel
9465110917 Polish
See gh-26707
2022-09-26 22:25:44 +02:00
chenrl
b71e686cbd Fix ServletContextResource isFile check
Prior to this commit, `ServletContextResource` could rely on
`ServletContext#getRealPath` to check whether a resource exists.
This behavior is not enforced on some Servlet containers, as this method
is only meant to translate virtual paths to real paths, but not
necessarily check for the existence of the file.

See https://bz.apache.org/bugzilla/show_bug.cgi?id=55837#c3 for a
rationale of this behavior in Tomcat.

This commit enforces an additional check, resolving the path as a `File`
and checking that is exists and is a file.

Closes gh-26707
2022-09-26 22:20:15 +02:00
Brian Clozel
9c400ed384 Polish Stream#toList() consistent usage
In general, `Stream#toList()` is not a transparent replacement for
`.collect(Collectors.toList()))`, as the former returns an immutable
list.

This commit reverts some of those changes, where the returned `List`
instance was expected to be mutable.

See gh-29203
2022-09-26 20:25:13 +02:00
Adam Ostrožlík
641303baff Remove unnecessary sync block in ControllerMethodResolver
Closes gh-29208
2022-09-26 18:32:01 +02:00
Adam Ostrožlík
0ccb64fe10 Replace Collectors.toList with Stream.toList
Closes gh-29203
2022-09-26 18:32:01 +02:00
ijonathanc
9d263668d5 Pass current request to filter in RouterFunction extensions
This commit ensures that the proper request is passed in the
Kotlin RouterFunction extension DSL.

Closes gh-27086
2022-09-26 14:55:14 +02:00
Sam Brannen
a975b9d5da Suppress "unused" warnings in tests 2022-09-26 14:27:32 +02:00
Sam Brannen
2872282d75 Ensure Kotlin JMH folder is imported as test folder in Eclipse
Commit 9a180d1811 introduced Kotlin-based
JMH benchmarks which prevent spring-beans from being imported into the
Eclipse IDE.

This commit ensures that src/jmh/kotlin is imported in Eclipse with the
"test" attribute set.

See gh-24104
2022-09-26 14:21:49 +02:00
Сергей Цыпанов
8a87e118e1 Remove redundant assignment of default values to volatile/atomic fields
Closes gh-27477
2022-09-26 13:43:04 +02:00
Brian Clozel
e8d24ae693 Fix HTTP interface section title in ref docs 2022-09-26 13:39:51 +02:00
Stephane Nicoll
2c0a9e0e30 Merge pull request #23418 from Syquel
* pr/23418:
  Polish "Improve resolution of generic type variables"
  Improve resolution of generic type variables

Closes gh-23418
2022-09-26 13:13:24 +02:00
Stephane Nicoll
b11e885e00 Polish "Improve resolution of generic type variables"
See gh-23418
2022-09-26 13:07:43 +02:00
Frederik Boster
124a76b1ad Improve resolution of generic type variables
See gh-23418
2022-09-26 13:04:26 +02:00
Stephane Nicoll
267908a118 Polish 2022-09-26 11:15:43 +02:00
Sébastien Deleuze
9a180d1811 Add JMH benchmarks
Closes gh-24104
2022-09-26 10:23:06 +02:00
Sébastien Deleuze
8e73b57329 Refine Kotlin changes
This refinement ensures the constructor is properly
accessible, avoid duplicating current logic and
provide a slightly faster implementation of the
Kotlin codepath.

See gh-24104
2022-09-26 10:22:46 +02:00
stsypanov
edcc559b4a Add fast-path in BeanUtils#instantiateClass
For no-args constructor.

See gh-24104
2022-09-26 10:21:28 +02:00
Sébastien Deleuze
42ab1b75e7 Fix a regression in Kotlin serialization support
After gh-29068, some Type instances can throw an
IllegalArgumentException. This commit catches them
properly to just return a null serializer in that
case.

Closes gh-29192
2022-09-26 09:55:44 +02:00
Lars Grefer
94e5eb3eb6 Consider empty jar entries as readable
Prior to this commit, resource handling would not serve empty files and
return instead HTTP 404 responses. This would only happen for files
contained by JARs, but not on the filesystem.

This can be tracked to changes done in `AbstractFileResolvingResource`
where we avoid serving empty files for directories, see gh-21372.
This commit improves the `checkReadable` method to align this behavior
between file system and JAR files.

Closes gh-28850
2022-09-26 09:51:11 +02:00
Stephane Nicoll
dfd1a31435 Merge branch '5.3.x' 2022-09-26 09:07:27 +02:00
Stephane Nicoll
433a23a0bd Merge pull request #29190 from dreis2211
* pr/29190:
  Polish "Avoid resizing of Maps created by CollectionUtils"
  Avoid resizing of Maps created by CollectionUtils

Closes gh-29190
2022-09-26 09:06:52 +02:00
Stephane Nicoll
7309fe9f2e Polish "Avoid resizing of Maps created by CollectionUtils"
See gh-29190
2022-09-26 09:00:45 +02:00
Christoph Dreis
874a296a76 Avoid resizing of Maps created by CollectionUtils
See gh-29190
2022-09-26 08:54:52 +02:00
Stephane Nicoll
82ae2a0326 Merge branch '5.3.x' 2022-09-26 08:53:14 +02:00