Commit Graph

3853 Commits

Author SHA1 Message Date
Sam Brannen 6ea9fdbf77 Polishing 2023-11-30 19:04:59 +01:00
Juergen Hoeller f3b1f37000 Process URL path for filename extraction if URI does not expose path
Closes gh-31718
2023-11-29 17:08:59 +01:00
Sébastien Deleuze df00aafdff Add a nested generics test for GenericTypeResolver
Closes gh-31690
2023-11-29 15:12:07 +01:00
Sébastien Deleuze 7cf124b696 Revert "Support WildcardType resolution in GenericTypeResolver"
This reverts commit f075120675.

See gh-22313
See gh-31690
2023-11-29 15:09:57 +01:00
Stéphane Nicoll 9eb2f29d4a Move sample to unit test
See gh-28904
2023-11-27 07:58:19 +01:00
Sam Brannen dbad9fd208 Update copyright headers 2023-11-25 14:59:40 +01:00
Juergen Hoeller 710373d286 Consider generics in equals method (for ConversionService caching)
Closes gh-31672
2023-11-24 23:25:59 +01:00
Stéphane Nicoll fb4455b396 Polish 2023-11-24 08:38:47 +01:00
Stéphane Nicoll 85aa4b65dc Polish "Polish GenericTypeResolver Javadoc"
See gh-31663
2023-11-24 08:30:40 +01:00
Yanming Zhou 0b61755ea3 Polish GenericTypeResolver Javadoc
See gh-31663
2023-11-24 08:28:27 +01:00
Sébastien Deleuze 441e210533 Treat kotlin.Unit as void in web controllers
This commit fixes a regression introduced by gh-21139
via the usage of Kotlin reflection to invoke HTTP
handler methods. It ensures that kotlin.Unit is treated
as void by returning null.

It also polishes CoroutinesUtils to have a consistent
handling compared to the regular case, and adds related
tests to prevent future regressions.

Closes gh-31648
2023-11-22 13:45:03 +01:00
Sébastien Deleuze bec385d310 Use JarURLConnection caching defaults
In order to prevent leaks of large amounts of non-heap
memory (and potential other efficiency and performance side
effects), this commit updates ResourceUtils#useCachesIfNecessary
to leave the caching flag to its JVM default value for instances
of JarURLConnection.

The previous behavior was originally introduced via gh-9316 and
gh-13755 to avoid I/O failure during webapp hot reloading in
Servlet containers. This is not a popular deployment mode anymore
and we have not been able to reproduce the original issue with
a Java 17 JVM and Tomcat 10.

Closes gh-30955
2023-11-21 12:00:45 +01:00
“7fantasy7” 54f87f1ff7 Skip buffer in StreamUtils#copy(String) 2023-11-20 20:41:21 +01:00
Stéphane Nicoll f146d09607 Handle default package with AOT processing
Adding generated code in the default package is not supported as we
intend to import it, most probably from another package, and that is
not supported. While this situation is hard to replicate with Java,
Kotlin is unfortunately more lenient and users can end up in that
situation if they forget to add a package statement.

This commit checks for the presence of a valid package, and throws
a dedicated exception if necessary.

Closes gh-31628
2023-11-20 11:54:47 +01:00
Sam Brannen 8c9481d4c4 Polishing 2023-11-20 11:31:36 +01:00
Sam Brannen 7006d0a80e Polishing 2023-11-19 14:28:19 +01:00
Sam Brannen 69049a4b0f Overhaul Javadoc for PathMatchingResourcePatternResolver 2023-11-19 14:27:41 +01:00
Sam Brannen 194747a80c Polish PathMatchingResourcePatternResolver 2023-11-19 14:26:12 +01:00
Juergen Hoeller d1867f1b73 Merge branch '6.0.x' 2023-11-16 11:35:12 +01:00
Juergen Hoeller e5f04e5ddf Polishing 2023-11-16 11:34:31 +01:00
Juergen Hoeller 99378fe947 Polishing 2023-11-16 11:22:09 +01:00
Stéphane Nicoll c485e9b74f Merge branch '6.0.x' 2023-11-15 20:50:02 +01:00
Stéphane Nicoll d93114df9a Polish "Provide invalid class name in exception message"
See gh-31612
2023-11-15 20:45:24 +01:00
PiotrFLEURY 5ac4c3bd76 Provide invalid class name in exception message
See gh-31612
2023-11-15 20:40:45 +01:00
rstoyanchev 3a70c71c5e Merge branch '6.0.x' 2023-11-15 18:57:35 +00:00
rstoyanchev 05c3ffb2fb Use InvalidMimeTypeException in MimeTypeUtils#sortBySpecificity
Closes gh-31254
2023-11-15 18:57:23 +00:00
Arjen Poutsma 0ef3cb9b9e Merge branch '6.0.x' 2023-11-15 14:33:55 +01:00
Arjen Poutsma 8868fe2ea5 Fix position bug in NettyDataBuffer::toByteBuffer
Closes gh-31605
2023-11-15 14:23:43 +01:00
Sam Brannen 978e81e72e Merge branch '6.0.x' 2023-11-14 15:15:53 +01:00
Sam Brannen e71117dcdf Polish contribution
See gh-31598
2023-11-14 14:46:34 +01:00
Jason d5874ab99e Avoid duplicate resources in PathMatchingResourcePatternResolver on Windows
This commit updates PathMatchingResourcePatternResolver to avoid
returning duplicate resources on MS Windows when searching using the
`classpath*:` prefix and a wildcard pattern that matches resources
which are directly present in a JAR as well as present via classpath
manifest entries.

Closes gh-31598
2023-11-14 14:39:48 +01:00
Sébastien Deleuze d8ed7c7906 Merge branch '6.0.x' 2023-11-09 13:11:58 +01:00
Sébastien Deleuze 620f558547 Register hints for superclass in BindingReflectionHintsRegistrar
Closes gh-31552
2023-11-09 13:11:36 +01:00
Sam Brannen b7c579954c Merge branch '6.0.x'
# Conflicts:
#	spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java
2023-11-08 13:48:22 +01:00
lorenzsimon 6a7a0bddb7 Restore support for recursive annotations in Kotlin
This commit reinstates support for recursive annotations in Kotlin.

See gh-28012
See gh-28618
See gh-31400
Closes gh-31518
2023-11-08 13:28:28 +01:00
Sam Brannen 9759bf5964 Merge branch '6.0.x' 2023-11-07 17:13:46 +01:00
Sam Brannen 5752e03d97 Polishing 2023-11-07 16:58:21 +01:00
wakingrufus 8c77e398b6 Add extension for PropertyResolver#getProperty(String, Class<T>, T)
Allows Kotlin caller to get a non-nullable property,
using a default value when the property is not set.
A method already exists on PropertyResolver which does this,
but takes a Class parameter.
The extension method can eliminate the parameter via reified type,
similar to the other extension methods which exist already.

Closes gh-31523
2023-11-06 15:14:16 +01:00
Sébastien Deleuze 34e5512ff6 Enable PropertyResolverExtensionsKotlinTests
Closes gh-31553
2023-11-06 15:14:16 +01:00
Sam Brannen b3a6dbaab3 Polishing 2023-11-04 14:45:09 +01:00
Sam Brannen ed49f86dfb Remove obsolete code in ConcurrentReferenceHashMapTests 2023-11-04 14:38:30 +01:00
Stéphane Nicoll 24aa6163f0 Polish 2023-11-03 12:10:01 +01:00
Stéphane Nicoll 9c5dcad0e5 Polish 2023-11-02 11:45:07 +01:00
Stéphane Nicoll 199d5e5f37 Polish 2023-10-31 13:02:01 +01:00
Johnny Lim 2b750926c3 Polishing
Closes gh-31522
2023-10-30 15:05:20 +01:00
Sam Brannen 44b98c6a8b Polish PatternMatchUtils[Tests] 2023-10-27 17:44:44 +02:00
Sam Brannen 555404e679 Polishing 2023-10-25 16:36:53 +02:00
Stéphane Nicoll 6585f1a208 Merge branch '6.0.x' 2023-10-25 11:23:45 +02:00
Stéphane Nicoll 84c28995fb Improve documentation for the default profile
Closes gh-29071
2023-10-25 11:20:21 +02:00
Juergen Hoeller 83870e35d1 TypeDescriptor/ResolvableType cache in GenericTypeAwarePropertyDescriptor
Closes gh-31490
2023-10-24 23:13:19 +02:00
Juergen Hoeller 93b0b66735 Merge branch '6.0.x'
# Conflicts:
#	spring-beans/src/main/java/org/springframework/beans/BeanUtils.java
#	spring-core/src/main/java/org/springframework/core/ResolvableType.java
#	spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java
2023-10-24 22:58:31 +02:00
Juergen Hoeller 925fa0272b Polishing 2023-10-24 22:53:44 +02:00
Juergen Hoeller 795ce1658c Consistent Class and array matching with Class comparison shortcut
Closes gh-31487
2023-10-24 16:42:52 +02:00
Juergen Hoeller cf3a25bfac Merge branch '6.0.x' 2023-10-23 17:34:45 +02:00
Juergen Hoeller 6bdf7ad36a Polishing 2023-10-23 17:32:45 +02:00
Sam Brannen 2d792f000a Polish "Apply SingleSpaceSeparator Checkstyle module"
See gh-31469
2023-10-22 14:18:18 +02:00
Johnny Lim 64e9fcad53 Apply SingleSpaceSeparator Checkstyle module
This commit also fixes its violations.

Closes gh-31469
2023-10-22 14:09:57 +02:00
Sam Brannen 37e6fe5b64 Update copyright headers 2023-10-22 11:28:40 +02:00
Brian Clozel daaccce918 Merge branch '6.0.x' 2023-10-19 16:07:41 +02:00
Brian Clozel 6ec264252b Ensure consistent value count in ConcurrentReferenceHashMap#Segment
Prior to this commit, the `ConcurrentReferenceHashMap#Segment` would
recalculate its element count during the restructure phase by
subtracting the number of polled elements from the queue to the current
count.
Later, the newly restructured `references` array would only contain
references that 1) are not in the set of elements to purge and
2) that hold a non-null value.

The issues with this approach are multiple. The newly calculated count
is only an estimate, as some situations can make it invalid, even
temporarily.

* since we initially collected all elements to be purged from the queue,
  the GC might have collected new values. This means that we might
  filter out more references that we initially intended to

* because the restructure operation re-creates new references for all
  elements in the original array, we might later get references from the
  queue that are not in the array anymore. This could lead to
  "duplicate" removals for the same value

Because several methods in the Segment class have special no-op behavior
when `count == 0`, an invalid count can lead to keys appearing missing
when they are actually still present. In some scenarios, this can
decrease the performance of the cache since values need to be
recalculated.

This commit fixes this inconsistency count issue by first using an
estimate in order to decide whether the array needs a resize and then by
counting the actual numbers of elements inserted in the restructured
array as the new count.

Fixes gh-31373
2023-10-19 15:54:31 +02:00
Johnny Lim 919faa2ce2 Order modifiers to align with JLS
This commit also applies Checkstyle ModifierOrder to enforce it.

See gh-31368
2023-10-17 16:13:56 +02:00
Brian Clozel 33deaff108 Move performance test to JMH benchmark
This commit removes an ignored performance test in the
`ConcurrentReferenceHashMap` test suite and converts it to a JMH
benchmark.
2023-10-17 10:42:02 +02:00
Sam Brannen 32b4f55d92 Update copyright headers 2023-10-16 16:19:55 +02:00
Sam Brannen 8e5f39b439 Align with StackWalker use in MergedAnnotationsTests.getFromMethodWithBridgeMethod() 2023-10-15 17:53:19 +02:00
Juergen Hoeller 0eb92c1267 Merge branch '6.0.x' 2023-10-15 16:10:12 +02:00
Juergen Hoeller 7a60e2024b BeanCopier sets name prefix for public classes as well
Includes consistent formatting of Spring-patched files.

Closes gh-28699
2023-10-15 16:09:17 +02:00
Juergen Hoeller 4458799e06 Upgrade to ASM 9.6
Closes gh-31431
2023-10-15 16:04:44 +02:00
Johnny Lim 15f7e8ef2f Fix typo in ClassUtils.forName()
See gh-31258
Closes gh-31428
2023-10-14 17:43:06 +02:00
OnlyWick eafbcfd385
Remove redundant static declaration on Search class
Closes gh-31381
2023-10-11 13:01:21 +02:00
Juergen Hoeller de6692e7d8 Merge branch '6.0.x'
# Conflicts:
#	spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java
2023-10-10 21:58:31 +02:00
Juergen Hoeller 5459304a4b Re-introduce support for annotation declarations with self references
Closes gh-31400
2023-10-10 21:54:58 +02:00
Johnny Lim 8ed302bfa4 Add @⁠since tags for DataBufferUtils.outputStreamPublisher() methods
See gh-31184
Closes gh-31376
2023-10-08 18:09:21 +02:00
Stéphane Nicoll ae731fbb78 Merge branch '6.0.x' 2023-10-05 16:57:04 +02:00
Stéphane Nicoll 19fd8159b2 Improve Javadoc of MethodParameter#getAnnotatedElement
This commit adds a reference to the method that can be used to get
the AnnotatedElement at the parameter level.

Closes gh-30397
2023-10-05 16:56:37 +02:00
Arjen Poutsma 59d123a18e Introduce OutputStream BodyInserter
This commit introduces a BodyInserter that inssert any bytes written to
an output stream to the body of an output message.

Closes gh-31184
2023-10-05 15:31:08 +02:00
Sam Brannen 74fc8bd12d Polish SimpleAliasRegistryTests
See gh-31348
2023-10-03 15:29:22 +02:00
Enrico Freni d507590abf Add missing unit tests for SimpleAliasRegistry
Closes gh-31348
2023-10-03 15:13:42 +02:00
Johnny Lim 4a802c4e1f Add Javadoc since for ExponentialBackOff.DEFAULT_MAX_ATTEMPTS
See gh-31351
2023-10-02 17:04:05 +02:00
Juergen Hoeller a3e13c8ba8 Merge branch '6.0.x'
# Conflicts:
#	spring-core/src/main/java/org/springframework/util/backoff/ExponentialBackOff.java
2023-09-29 15:01:43 +02:00
Juergen Hoeller 407113945d Polishing 2023-09-29 14:58:02 +02:00
Sam Brannen 47ed4e6c78 Merge branch '6.0.x' 2023-09-27 13:19:39 +02:00
Sam Brannen 06658c3c71 Restore zero capacity support in ConcurrentLruCache
Since the rewrite of ConcurrentLruCache in Spring Framework 6.0, an
attempt to create a ConcurrentLruCache with zero capacity results in an
IllegalArgumentException even though the documentation states that zero
capacity indicates "no caching, always generating a new value".

This commit restores the ability to configure a ConcurrentLruCache with
zero capacity and introduces corresponding tests (which were first
verified against the 5.3.x branch to ensure backward compatibility).

See gh-26320
Closes gh-31317
2023-09-27 13:18:30 +02:00
Sam Brannen 225c9062a1 Merge branch '6.0.x' 2023-09-25 20:19:11 +02:00
Sam Brannen 18456dec52 Reintroduce FastClass in CGLIB class names for @⁠Configuration classes
Given a @⁠Configuration class named org.example.AppConfig which
contains @⁠Bean methods, in Spring Framework 5.3.x and previous
versions, the following classes were created when generating the CGLIB
proxy.

org.example.AppConfig$$EnhancerBySpringCGLIB$$fd7e9baa
org.example.AppConfig$$FastClassBySpringCGLIB$$3fec86e
org.example.AppConfig$$EnhancerBySpringCGLIB$$fd7e9baa$$FastClassBySpringCGLIB$$82534900

Those class names indicate that 1 class was generated for the proxy for
the @⁠Configuration class itself and that 2 additional FastClass
classes were generated to support proxying of @⁠Bean methods in
superclasses.

However, since Spring Framework 6.0, the following classes are created
when generating the CGLIB proxy.

org.example.AppConfig$$SpringCGLIB$$0
org.example.AppConfig$$SpringCGLIB$$1
org.example.AppConfig$$SpringCGLIB$$2

The above class names make it appear that 3 proxy classes are generated
for each @⁠Configuration class, which is misleading.

To address that and to align more closely with how such generated
classes were named in previous versions of the framework, this commit
modifies SpringNamingPolicy so that generated class names once again
include "FastClass" when the generated class is for a CGLIB FastClass
as opposed to the actual proxy for the @⁠Configuration class.

Consequently, with this commit the following classes are created when
generating the CGLIB proxy.

org.example.AppConfig$$SpringCGLIB$$0
org.example.AppConfig$$SpringCGLIB$$FastClass$$0
org.example.AppConfig$$SpringCGLIB$$FastClass$$1

Closes gh-31272
2023-09-25 20:17:10 +02:00
Sam Brannen d17c75a7ef Test status quo for SpringNamingPolicy
See gh-31272
2023-09-25 20:14:29 +02:00
Sam Brannen f547b6ad2a Polishing 2023-09-25 20:14:29 +02:00
Arjen Poutsma ecd3f191b6 Refactoring external contribution
Created abstract CharSequence decoder, which is extended by
StringDecoder and CharBufferDecoder.

See gh-29741
2023-09-19 16:24:07 +02:00
Markus Heiden 59771318ce Introduce CharBufferDecoder
This commit introduces the CharBufferDecoder.

Closes gh-29741
2023-09-19 16:24:07 +02:00
Brian Clozel 103c6b8bda Add missing reflection hint on Eclipse FileLocator
`PathMatchingResourcePatternResolver` is reflecting on
`org.eclipse.core.runtime.FileLocator` and invoking methods on it for
OSGi support. While this use case is highly unlikely in native images,
registering the reflection entry by itself should be enough.

Fixes gh-31271
2023-09-19 16:06:43 +02:00
Brian Clozel 7af9ce4f03 Add resource hint for spring.properties
Fixes gh-31270
2023-09-19 15:57:59 +02:00
Brian Clozel 4c343ef796 Add missing reflection hints on Kotlin classes
This commit adds the relevant reflection hints required by
`KotlinDetector`; this class is trying to detect both `kotlin.Metadata`
and `kotlin.reflect.full.KClasses`.

Fixes gh- 31269
2023-09-19 15:49:46 +02:00
Brian Clozel e53c2c6331 Reduce nested class lookups in ClassUtils
Prior to this commit, `ClassUtils#forName` would always attempt to
resolve the given class name as a nested type. For example, searching
for `org.example.Spring` would try to resolve:

* `org.example.Spring`
* if not available, try `org.example$Spring` as well

Java classes usually start with uppercase letters, so this additional
lookup can be costly and not very useful.

This commit only attempts nested class lookups when the previous segment
starts with an uppercase. So `org.example.Spring.Issue` will look for
`org.example.Spring$Issue`, but `org.example.Spring` will not.

Closes gh-31258
2023-09-19 15:12:53 +02:00
Brian Clozel 7ecbdc19a5 Merge branch '6.0.x' 2023-09-15 17:54:06 +02:00
Brian Clozel 227049824c Fix RuntimeHintsPredicates matching rules
Prior to this commit, the `RuntimeHintsPredicates` would assume that
registering introspection or invocation hints for "all declared methods"
on a type would also include "all public methods". This is not true, as
the Java reflection API itself behaves differently.
`getDeclaredMethods()` does not return a superset of `getMethods()`, as
the latter can return inherited methods, but not the former.
Same reasoning applies to fields.

This commit fixes the hints predicates to only match if the correct hint
has been registered.

Fixes gh-31224
2023-09-15 17:50:53 +02:00
Yanming Zhou 46397381ba Eliminate synchronized block to avoid thread pinning in SingletonSupplier 2023-09-14 16:37:32 +02:00
Juergen Hoeller 550f05c9dc Merge branch '6.0.x'
# Conflicts:
#	spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessor.java
2023-09-13 17:28:54 +02:00
Juergen Hoeller 966b0a92c6 Defensively call Resource.getFile() for fallback resolution
Closes gh-31216
2023-09-13 17:14:04 +02:00
Sam Brannen 5bcbcb3049 Simplify SynthesizedMergedAnnotationInvocationHandler.invoke() 2023-09-13 17:14:03 +02:00
Sam Brannen fe7355d5b0 Polishing 2023-09-13 17:04:39 +02:00
Sam Brannen a271d5ec15 Use nullSafeHashCode() in SynthesizedMergedAnnotationInvocationHandler
In light of the refinements to ObjectUtils, this commit updates
SynthesizedMergedAnnotationInvocationHandler to use
ObjectUtils.nullSafeHashCode() and removes the now obsolete code in
SynthesizedMergedAnnotationInvocationHandler.

See gh-29051
2023-09-13 16:50:58 +02:00
Sam Brannen af13967e2a Polishing 2023-09-13 16:50:58 +02:00
Sam Brannen e63e3a6d28 Delete obsolete constants 2023-09-13 16:13:09 +02:00
Sam Brannen 4ca70256d6 Backport polishing 2023-09-13 16:09:59 +02:00
Sam Brannen e5f18798ca Revert deprecation of [Simple]CommandLinePropertySource
This commit reverts the deprecation of CommandLinePropertySource and
SimpleCommandLinePropertySource, since we have discovered that Spring
Boot actively uses SimpleCommandLinePropertySource in
org.springframework.boot.SpringApplication.

Closes gh-31207
2023-09-13 15:58:00 +02:00
Stephane Nicoll 01f717375b Introduce ObjectUtils#nullSafeHash(Object... element)
This commit deprecates the various nullSafeHashCode methods taking array
types as they are superseded by Arrays.hashCode now. This means that
the now only remaining nullSafeHashCode method does not trigger a
warning only if the target type is not an array. At the same time, there
are multiple use of this method on several elements, handling the
accumulation of hash codes.

For that reason, this commit also introduces a nullSafeHash that takes
an array of elements. The only difference between Objects.hash is that
this method handles arrays.

The codebase has been reviewed to use any of those two methods when it
is possible.

Closes gh-29051
2023-09-13 15:14:34 +02:00
Stephane Nicoll f2e898d35d Polish 2023-09-13 14:30:01 +02:00
Sam Brannen c598f0565a Deprecate CommandLinePropertySource and associated implementations
Closes gh-31207
2023-09-13 13:56:24 +02:00
Juergen Hoeller 3099710087 Merge branch '6.0.x'
# Conflicts:
#	spring-r2dbc/src/main/java/org/springframework/r2dbc/connection/R2dbcTransactionManager.java
#	spring-r2dbc/src/test/java/org/springframework/r2dbc/connection/R2dbcTransactionManagerUnitTests.java
2023-09-11 17:40:11 +02:00
Juergen Hoeller 78fce80c43 AnnotationUtils.clearCache() includes all annotation caches
Closes gh-31170
2023-09-11 17:36:32 +02:00
Sam Brannen b082f546ec Polishing 2023-09-10 14:59:21 +02:00
liaozan 9728b8cefd Use Method#isDefault to find default methods in interfaces
Closes gh-31197
2023-09-10 14:53:05 +02:00
Sam Brannen a11b8039c5 Merge branch '6.0.x' 2023-09-08 16:31:11 +02:00
Sam Brannen 1227fe5774 Polishing 2023-09-08 16:30:53 +02:00
Sam Brannen f0b1133b12 Merge branch '6.0.x' 2023-09-08 16:12:29 +02:00
Sam Brannen ea41051651 Do not invoke [Map|Collection].isEmpty() in nullSafeConciseToString()
gh-30810 introduced explicit support for collections and maps in
ObjectUtils.nullSafeConciseToString() by invoking isEmpty() on a Map or
Collection to determine which concise string representation should be
used. However, this caused a regression in which an exception was
thrown if the Map or Collection was a proxy generated by
AbstractFactoryBean to support <util:set />, <util:list />, and
<util:map /> in XML configuration.

This commit addresses this set of regressions by always returning
"[...]" or "{...}" for a Collection or Map, respectively, disregarding
whether the map is empty or not.

Closes gh-31138
2023-09-08 16:03:00 +02:00
Sam Brannen ac3a466607 Merge branch '6.0.x' 2023-09-07 16:50:50 +02:00
Sam Brannen 1cdbd68aec Revise FilePatternResourceHintsRegistrar API and improve documentation
This commit revises the FilePatternResourceHintsRegistrar API and
introduces List<String> overrides of various var-args methods used with
the new builder API.

Closes gh-29161
2023-09-07 16:45:50 +02:00
Sam Brannen 453c0e5191 Backport changes from `main` 2023-09-07 16:45:50 +02:00
Sébastien Deleuze adb73389a8 Merge branch '6.0.x' 2023-09-05 16:32:15 +02:00
Johnny Lim 73766c01e6 Add Javadoc since tags in FilePatternResourceHintsRegistrar
See gh-29161
Closes gh-31174
2023-09-05 16:31:46 +02:00
Sam Brannen 23a0903b5c Add missing comma and polishing 2023-09-02 19:34:20 +02:00
Sébastien Deleuze 03650e7d58 Merge branch '6.0.x' 2023-09-01 12:52:59 +02:00
Sébastien Deleuze 1641cb75e2 Refine Reactor field precomputing on native
This commit refines Reactor field precomputing on native
to only compute at build-time fields in the reactor.core
package, since doing so in reactor.netty has unwanted side
effects like Epoll always disabled.

Closes gh-31141
2023-09-01 12:52:27 +02:00
Sam Brannen 093d6a1bec Merge branch '6.0.x' 2023-08-31 13:40:31 +02:00
Sam Brannen 2e4e43b5bd Polish org.springframework.core.env.PropertySource
See gh-30195
2023-08-31 13:38:13 +02:00
Brian Clozel f5a356c9c6 Add ContextPropagatingTaskDecorator
Prior to this commit, `@Async` and `@EventListener` annotated methods
would lose the the logging and observation contexts whenever their
execution was scheduled on a different Thread.

The Context Propagation library supports this use case and can propagate
context values in ThreadLocals, Reactor Context and more.

This commit introduces a new `TaskDecorator` implementation that
leverages the Context Propagation library. When configured on a
`TaskExecutor`, this allows to properly propagate context value through
the execution of the task.

This implementation is completely optional and requires the
"io.micrometer:context-propagation" library on the classpath. Enabling
this feature must be done consciously and sometimes selectively, as
context propagation introduces some overhead.

Closes gh-31130
2023-08-29 11:21:47 +02:00
Sam Brannen f054c2e804 Polishing 2023-08-27 19:29:21 +02:00
Sam Brannen 95453a4427 Merge branch '6.0.x' 2023-08-27 19:03:16 +02:00
Sam Brannen bbf73848b5 Update warning for use of convention-based annotation attribute overrides
See gh-28761
2023-08-27 19:02:57 +02:00
Sam Brannen d189e169cc Polish CompositePropertySource[Tests] 2023-08-27 14:08:39 +02:00
Stephane Nicoll 5c691960a2 Polish "Improve performance of CompositePropertySource#getPropertyNames"
See gh-27236
2023-08-26 17:46:19 +02:00
shawyeok b67a381fbe Improve performance of CompositePropertySource#getPropertyNames
Create LinkedHashSet with a initialCapacity, prevent under the hood
table resize cost in continuous add operations. Reduce bootstrap time
in the case of large properties.

See gh-27236
2023-08-26 17:46:19 +02:00
Sam Brannen dac481da43 Test CollectionUtils.unmodifiableMultiValueMap only once
No need to test that feature as a parameterized test.
2023-08-26 14:56:17 +02:00
Sam Brannen 31a07e6fbf User AssertJ assertions 2023-08-26 14:56:16 +02:00
Sam Brannen ef01a078d3 Polishing 2023-08-26 14:55:15 +02:00
Sam Brannen 44167ecea4 Polish BackOff support 2023-08-26 14:44:46 +02:00
Stephane Nicoll 609580bfb9 Polish "Add maxAttempts to ExponentialBackOff"
See gh-27071
2023-08-26 12:54:24 +02:00
Gary Russell f6a09f3fad Add maxAttempts to ExponentialBackOff
If you wish to stop after a certain number of attempts with an
`ExponentialBackOff` you have to calculate the `maxElapsedTime`
corresponding to the number of attempts.

Add a new property to make it more convenient to stop after a
certain number of attempts.

See gh-27071
2023-08-26 12:45:32 +02:00
Sam Brannen 78d8fac05b Polishing 2023-08-25 17:06:57 +02:00
Sam Brannen 3efbbc5994 Merge branch '6.0.x' 2023-08-25 16:56:52 +02:00
Sam Brannen 89b7a6bf47 Skip searching of nonexistent directory in PathMatchingResourcePatternResolver
Prior to this commit, when PathMatchingResourcePatternResolver
processed a `file:` pattern (for example, `file:/app-config/**`) for a
`rootPath` that did not exist in the filesystem, the resolver attempted
to search the directory and logged a WARNING message similar to the
following when it failed to do so.

Failed to search in directory [/app-config/] for files matching pattern
[**]: java.nio.file.NoSuchFileException: /app-config/

To avoid unnecessary attempts to search a nonexistent directory,
PathMatchingResourcePatternResolver now skips searching of a nonexistent
directory and preemptively logs an INFO message similar to the
following.

Skipping search for files matching pattern [**]: directory [/app-config]
does not exist

Closes gh-31111
2023-08-25 16:54:10 +02:00
Sam Brannen 19570338c9 Ensure doFindPathMatchingFileResources() returns a mutable Set
This commit ensures that PathMatchingResourcePatternResolver's
doFindPathMatchingFileResources() method returns a mutable Set in order
to comply with the documented contract.
2023-08-25 16:53:00 +02:00
Stephane Nicoll 49cafe07ed Polish "Use Comparable instead of dedicated implementations"
See gh-25478
2023-08-25 14:44:57 +02:00
Eugene 33454a4007 Use Comparable instead of dedicated implementations
This commit deprecates ComparableComparator and NullSafeComparator in
favor of the available convenient implementation in the JDK.

See gh-25478
2023-08-25 14:41:27 +02:00
Stephane Nicoll 352c7cd8b3 Polish "Add additional tests for MultiValueMap"
See gh-25160
2023-08-25 11:46:54 +02:00
Mihai Dumitrescu 325edbec7d Add additional tests for MultiValueMap
See gh-25140
See gh-25160
2023-08-25 11:27:52 +02:00
Stephane Nicoll 86e02a47fb Polish 2023-08-24 09:04:14 +02:00
陈其苗 e7071c329a Add a unit test for getMostSpecificMethod of ClassUtils
See gh-24633
2023-08-23 20:45:02 +02:00
Juergen Hoeller 3c5dc19da3 Polishing 2023-08-23 19:09:46 +02:00
Juergen Hoeller ecc0a6d2db Merge branch '6.0.x' 2023-08-23 19:02:44 +02:00
Stephane Nicoll 5878a0741e Polish "Add factory to create a NamedThreadLocal with an initial value"
See gh-24705
2023-08-23 18:58:12 +02:00
陈其苗 e1d0176faa Add factory to create a NamedThreadLocal with an initial value
See gh-24705
2023-08-23 18:58:12 +02:00
Sébastien Deleuze b2a86cc42d Polishing
See gh-24311
2023-08-23 18:56:14 +02:00
Sébastien Deleuze f161bc798e Implement StringToRegexConverter in Java
This commit implements StringToRegexConverter in Java
in order to avoid circular dependencies between Java
and Kotlin codes that can break IDE support, and for
consistency with the rest of the codebase.

See gh-24311
2023-08-23 18:53:32 +02:00
Juergen Hoeller 906a9f7982 Polishing 2023-08-23 18:52:55 +02:00
Stephane Nicoll a20a74817e Polish "Add support for converting String to Pattern"
See gh-24311
2023-08-23 18:13:41 +02:00
Valery Yatsynovich 06f6b45248 Add support for converting String to Pattern
See gh-24311
2023-08-23 18:13:41 +02:00
Sébastien Deleuze bb14dfa747 Merge branch '6.0.x' 2023-08-23 18:11:14 +02:00
Sébastien Deleuze 8934eb8464 Optimize ClassUtils#getMostSpecificMethod
This commit optimizes ClassUtils#getMostSpecificMethod which is
a method frequently invoked in typical Spring applications.

It refines ClassUtils#isOverridable by considering static and
final modifiers as non overridable and optimizes its implementation.

Closes gh-30272
2023-08-23 18:07:54 +02:00
Stephane Nicoll 6e141cc23a Polish "Add a composite for TaskDecorator"
See gh-23692
2023-08-23 16:02:54 +02:00
Tadaya Tsuyukubo 5f581a9a68 Add a composite for TaskDecorator
See gh-23692
2023-08-23 16:02:41 +02:00
Stephane Nicoll bf2cdcb1f2 Merge branch '6.0.x' 2023-08-23 10:47:32 +02:00
Stephane Nicoll 4b9f89101d Clarify handling of several representations for JOpt options
See gh-22168
2023-08-23 10:46:21 +02:00
Stephane Nicoll f95a1f49df Polish "Add Basic Authorization for UrlResource"
See gh-1822
2023-08-22 16:38:00 +02:00
Denis Kostin ac9ca412c8 Add Basic Authorization for UrlResource
See gh-1822
2023-08-22 16:12:31 +02:00
Stephane Nicoll 2b76c4d847 Polish "Wrap ternary operator within parentheses"
See gh-31076
2023-08-22 15:40:16 +02:00
70825 6712c044b1 Wrap ternary operator within parentheses
See gh-31076
2023-08-22 15:15:05 +02:00
Sam Brannen a55b50b512 Simplify implementation of AnnotationMetadata.getMetaAnnotationTypes()
Since an annotation cannot be extended in Java, there is no need to use
the INHERITED_ANNOTATIONS SearchStrategy to search for meta-annotations
on an annotation.
2023-08-22 14:58:19 +02:00
Sam Brannen 2935ff8f97 Fix Javadoc for AnnotationMetadata.getMetaAnnotationTypes() 2023-08-22 14:50:58 +02:00
Sam Brannen 94d9a71bb5 Polishing 2023-08-19 15:21:55 +02:00
Sam Brannen 74130d007b Ensure direct @PropertySource annotations override meta-annotations
Prior to this commit, there was an issue with the semantics of property
source overrides. Specifically, a @PropertySource annotation present as
a meta-annotation on a @Configuration class was registered with higher
precedence than a @PropertySource annotation declared closer to (or
directly on) the @Configuration class. Consequently, there was no way
for a "local" @PropertySource annotation to override properties
registered via @PropertySource as a meta-annotation.

This commit addresses this issue by introducing a new overloaded
getMergedRepeatableAnnotationAttributes() variant in
AnnotatedTypeMetadata that allows the caller to supply a
sortByReversedMetaDistance flag. When set to `true`, the annotation
search results will be sorted in reversed order based on each
annotation's meta distance, which effectively orders meta-annotations
before annotations that are declared directly on the underlying element.

ConfigurationClassParser and AnnotationConfigUtils have been updated to
use this new repeatable annotation search method for @PropertySource.

Closes gh-31074
2023-08-18 16:43:44 +02:00
Stephane Nicoll 9583d18896 Merge branch '6.0.x' 2023-08-18 15:39:49 +02:00
Stephane Nicoll 47b1a2bc55 Clarify usage of FilePatternResourceHintsRegistrar
This commit review the API using a builder to make it more clear what
the registrar does.

Closes gh-29161
2023-08-18 15:35:20 +02:00
Juergen Hoeller 1a137c2e61 Merge branch '6.0.x'
# Conflicts:
#	spring-core/src/main/java/org/springframework/util/StringUtils.java
2023-08-18 11:27:03 +02:00
Juergen Hoeller c5bdd9d79d Optimize whitespace checks in StringUtils
Closes gh-31067
2023-08-18 11:25:48 +02:00
Juergen Hoeller 86a101ac2b Merge branch '6.0.x' 2023-08-16 12:48:43 +02:00
Juergen Hoeller c7269feeaa Align validation metadata handling in PayloadMethodArgumentResolver
Reuses ValidationAnnotationUtils which is slightly optimized for the detection of Spring's Validated annotation now, also to the benefit of common web scenarios.

Closes gh-21852
2023-08-16 12:48:06 +02:00
Sam Brannen 02d3269dbb Polishing 2023-08-16 11:44:55 +02:00
Juergen Hoeller d89e305c87 Introduce SimplePropertyRowMapper with flexible constructor/property/field mapping
Includes query(Class) method with value and property mapping support on JdbcClient.
JdbcClient's singleColumn/singleValue are declared without a Class parameter now.

Closes gh-26594
See gh-30931
2023-08-15 13:14:52 +02:00
Juergen Hoeller 9c74c25961 Support for resource patterns in @PropertySource locations
Closes gh-21325
2023-08-14 19:16:52 +02:00
Juergen Hoeller 20d27e4fb6 Merge branch '6.0.x' 2023-08-14 15:14:58 +02:00
Juergen Hoeller 389238f622 Add registerReactiveTypeOverride method to ReactiveAdapterRegistry
Closes gh-31047
2023-08-14 15:14:22 +02:00
Juergen Hoeller fd5b0e144d Reuse Reactive Streams 1.0.3 FlowAdapters for Flow.Publisher bridge
See gh-31000
2023-08-14 14:25:03 +02:00
Sam Brannen bfeca4a0bf Polish contribution
See gh-30744
2023-08-13 17:03:12 +02:00
Adilson A 4979d8fded Increase code coverage in spring-core serializer package
Closes gh-30744
2023-08-13 16:26:02 +02:00
Sam Brannen f9b6aed6b6 Polishing
... for consistency with StandardAnnotationMetadata.
2023-08-13 16:21:18 +02:00
Sam Brannen 156546ad05 Make AnnotationAttributes.validated field immutable 2023-08-13 13:43:27 +02:00
Sam Brannen 0b902f32f6 Support finding repeatable annotations in AnnotatedTypeMetadata
AnnotatedTypeMetadata has various methods for finding annotations;
however, prior to this commit it did not provide explicit support for
repeatable annotations.

Although it is possible to craft a search "query" for repeatable
annotations using the MergedAnnotations API via getAnnotations(), that
requires intimate knowledge of the MergedAnnotations API as well as the
structure of repeatable annotations.

Furthermore, the bugs reported in gh-30941 result from the fact that
AnnotationConfigUtils attempts to use the existing functionality in
AnnotatedTypeMetadata to find repeatable annotations without success.

This commit introduces a getMergedRepeatableAnnotationAttributes()
method in AnnotatedTypeMetadata that provides dedicated support for
finding merged repeatable annotation attributes with full @AliasFor
semantics.

Closes gh-31041
2023-08-12 18:49:08 +02:00
Sam Brannen fb6c325cc0 Document @AliasFor support in AnnotatedTypeMetadata.getAnnotationAttributes()
The Javadoc for getAnnotationAttributes() states that it supports
"attribute overrides on composed annotations"; however, it actually
supports @AliasFor in general, including attribute aliases within a
given annotation.

This commit updates the Javadoc and corresponding tests to reflect that.

Closes gh-31042
2023-08-12 18:09:37 +02:00
Sam Brannen c52bfc0586 Update test names to reflect status quo
AnnotationMetadataReadingVisitor was replaced by
SimpleAnnotationMetadata in Spring Framework 5.2.
2023-08-12 18:09:37 +02:00
Sam Brannen a33b14338f Polishing annotation processing internals 2023-08-12 15:41:48 +02:00
Juergen Hoeller 8973d1ad8a Polishing 2023-08-08 20:10:23 +02:00
Johnny Lim 7f561fb53d Polish AbstractReflectionParameterNameDiscovererKotlinTests
See gh-30904
2023-08-08 10:23:07 +02:00
Juergen Hoeller c4896aca9b Defensively register Flow bridge in delegate class
See gh-31000
2023-08-08 09:52:42 +02:00
Juergen Hoeller 3b093754c8 Rename getLastTaskInfo to lastTaskInfo (aligned with currentTaskName)
See gh-25803
2023-08-08 09:41:00 +02:00
Juergen Hoeller 8e16e5ea35 Revise StopWatch for flexible time units in nanosecond precision
Closes gh-25803
2023-08-08 01:48:58 +02:00
Juergen Hoeller dedb58f7ed Defensively register default adapters behind Reactive Streams guard
See gh-31000
2023-08-07 20:48:10 +02:00
Sam Brannen f4b5738869 Polishing 2023-08-07 17:51:37 +03:00
Sam Brannen 526fc391ee Use Class#componentType() for consistency with arrayType()
Java 12 introduced java.lang.Class#componentType() as a shortcut for
getComponentType().

Since we started using arrayType() in fe5560400c, this commit switches
to componentType() for consistent API usage style.
2023-08-07 12:43:40 +03:00
Sam Brannen fe5560400c Use Class#arrayType() where feasible
Closes gh-31002
2023-08-07 12:07:46 +03:00