Commit Graph

3916 Commits

Author SHA1 Message Date
Juergen Hoeller 2f2c4188e5 Nullability refinements
See gh-32475
2024-03-18 15:49:20 +01:00
Sam Brannen ccebaa6b0c Merge branch '6.1.x' 2024-03-18 15:18:06 +01:00
Sam Brannen 42a4f28962 Avoid unnecessary Annotation array cloning in TypeDescriptor
Closes gh-32476
2024-03-18 15:17:04 +01:00
Juergen Hoeller 2b56ca08d4 Restore canonical name representation for 6.2
See gh-32405
2024-03-17 21:03:02 +01:00
Juergen Hoeller b89cf2b16a Merge branch '6.1.x' 2024-03-17 21:00:00 +01:00
Juergen Hoeller b1c3b6e34b Restore original toString representation (revert accidental backport)
See gh-32405
2024-03-17 20:42:29 +01:00
Johnny Lim 99e1b0d117 Make SimpleAliasRegistry.aliasNames final 2024-03-17 13:33:31 +01:00
Juergen Hoeller 89d563097f Merge branch '6.1.x'
# Conflicts:
#	spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java
2024-03-16 23:24:51 +01:00
Juergen Hoeller eb8b7c4331 Remove superfluous @NonNull declarations 2024-03-16 14:22:17 +01:00
Juergen Hoeller 58bd057a24 Avoid cloning empty Annotation array in TypeDescriptor (backport)
Closes gh-32405
2024-03-16 14:21:34 +01:00
Sam Brannen e1b1435a00 Stop referring to JDK 1.5 plus polishing 2024-03-14 16:00:51 +01:00
Sam Brannen 986c4fd926 Revise use of Objects.requireNonNull()
Historically, we have rarely intentionally thrown a
NullPointerException in the Spring Framework. Instead, we prefer to
throw either an IllegalArgumentException or IllegalStateException
instead of a NullPointerException.

However, changes to the code in recent times have introduced the use of
Objects.requireNonNull(Object) which throws a NullPointerException
without an explicit error message.

The latter ends up providing less context than a NullPointerException
thrown by the JVM (since Java 14) due to actually de-referencing a
null-pointer. See https://openjdk.org/jeps/358.

In light of that, this commit revises our current use of
Objects.requireNonNull(Object) by removing it or replacing it with
Assert.notNull().

However, we still use Objects.requireNonNull(T, String) in a few places
where we are required to throw a NullPointerException in order to
comply with a third-party contract such as Reactive Streams.

Closes gh-32430
2024-03-13 16:00:22 +01:00
Juergen Hoeller 3b87c87a33 Merge branch '6.1.x' 2024-03-12 20:11:21 +01:00
Juergen Hoeller 723c94e5ac Polishing 2024-03-12 20:10:01 +01:00
Sébastien Deleuze 0435e9c49e Merge branch '6.1.x' 2024-03-11 13:40:23 +01:00
Sébastien Deleuze 80f3be6577 Replace getJvmErasure by getClassifier
Should be slightly faster.

See gh-32334
2024-03-11 13:37:41 +01:00
Sébastien Deleuze 946082f806 Refine publisher type check in CoroutinesUtils
See gh-32390
2024-03-11 13:15:54 +01:00
Yanming Zhou 246e4977a2 Polishing Optional usage 2024-03-11 09:13:49 +01:00
Sam Brannen 4c246b7c96 Consistently use canonical annotation names in string representations 2024-03-10 15:54:53 +01:00
Sam Brannen 5345a13918 Polish contribution
See gh-32405
2024-03-10 12:36:08 +01:00
Patrick Strawderman 7fa2a28970 Avoid cloning empty Annotation array in TypeDescriptor
Rework AnnotatedElementAdapter to avoid cloning the underlying
Annotation array if it is empty when getAnnotations() is called.

Additionally, make the class static and add a factory method that
returns a singleton instance for null or empty Annotation arrays.

Closes gh-32405
2024-03-10 12:26:49 +01:00
Stéphane Nicoll e53ed3e3c6 Merge branch '6.1.x' 2024-03-09 16:03:04 +01:00
Stéphane Nicoll 4983a802a7 Polish "Fix Javadoc"
See gh-32403
2024-03-09 16:02:01 +01:00
Maksim Sasnouski abdccffa39 Fix Javadoc
This commit fixes various Javadoc issues across the code base.

See gh-32403
2024-03-09 16:02:00 +01:00
Juergen Hoeller c1287d48e2 Polishing 2024-03-08 19:31:01 +01:00
Juergen Hoeller 19fec0633f Local root directory and jar caching in PathMatchingResourcePatternResolver
Closes gh-21190
2024-03-08 19:12:14 +01:00
Sam Brannen ae6c64abc5 Fix Javadoc errors 2024-03-08 11:59:53 +01:00
Sébastien Deleuze f0039833c8 Merge branch '6.1.x' 2024-03-07 14:31:26 +01:00
Sébastien Deleuze 579dbc48d7 Optimize Coroutine invocations
KClass instantiation in CoroutinesUtils is suboptimal, and should be
replaced by KTypes#isSubtypeOf checks using pre-instantiated types for
Flow, Mono and Publisher.

This commit impact on performances is significant since a throughput
increase between 2x and 3x has been measured on basic endpoints.

Closes gh-32390
2024-03-07 14:27:47 +01:00
Sébastien Deleuze 92f4e883b3 Merge branch '6.1.x' 2024-03-07 11:11:46 +01:00
Sébastien Deleuze c1d4b610ca Refine Kotlin inline class optimizations
Closes gh-32334
2024-03-07 11:11:20 +01:00
Sam Brannen b32a2cadfb Update class-level Javadoc for ParameterNameDiscoverer 2024-03-06 14:49:46 +01:00
Juergen Hoeller a0ae849856 Polishing 2024-03-05 18:23:13 +01:00
ali dandach eb01cc0d9d Use String#isEmpty where feasible
This commit replaces checks for empty strings ("".equals(...)) with the
String#isEmpty method.

Closes gh-32377
2024-03-05 17:38:29 +01:00
Sam Brannen c29c67839b Cache parameterTypes in ClassUtils.getInterfaceMethodIfPossible 2024-03-05 11:48:01 +01:00
Arjen Poutsma 6d9aba88d0 Fix typo
See gh-32360
2024-03-05 10:48:06 +01:00
Arjen Poutsma 646bd7f893 Document StringUtils::uriDecode limitations
Closes gh-32360
2024-03-05 10:03:15 +01:00
Juergen Hoeller 79c54098ab Merge branch '6.1.x' 2024-03-04 23:49:55 +01:00
Juergen Hoeller 4300fec023 Restore ability to return original method at ClassUtils level as well
Closes gh-32365
2024-03-04 23:48:26 +01:00
Juergen Hoeller dc6c96de0a Merge branch '6.1.x'
# Conflicts:
#	spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractFallbackJCacheOperationSource.java
#	spring-context/src/main/java/org/springframework/cache/interceptor/AbstractFallbackCacheOperationSource.java
#	spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java
2024-03-04 22:50:22 +01:00
Juergen Hoeller e9110c0729 Polishing 2024-03-04 22:48:52 +01:00
Juergen Hoeller 24759a75f4 Restore ability to return original method for proxy-derived method
Closes gh-32365
2024-03-04 22:48:46 +01:00
Sébastien Deleuze 219004ef13 Merge branch '6.1.x' 2024-03-03 22:26:37 +01:00
Sébastien Deleuze 516a203703 Support nullable Kotlin value class arguments
This commit skips the value class parameter instantiation for nullable
types when a null argument is passed.

Closes gh-32353
2024-03-03 22:26:21 +01:00
Juergen Hoeller 390fe0fe78 Add support for resolving multiple bounds in type variables
Closes gh-22902
See gh-32327
2024-03-02 11:30:17 +01:00
Stéphane Nicoll ac1a030c35 Make PlaceholderResolutionException extend from IllegalArgumentException
To smooth upgrade from 6.1.x, this commit makes sure that code that used
to catch an IAE to ignore a faulty placeholder resolution still works.

See gh-9628
2024-03-02 08:28:38 +01:00
Sébastien Deleuze 4149d5cb2b Merge branch '6.1.x' 2024-03-01 11:55:08 +01:00
Sébastien Deleuze 85a781d517 Instantiate value class parameters with Kotlin reflection
In order to invoke the init block and to improve the maintainability.

Closes gh-32324
2024-03-01 11:50:19 +01:00
Sébastien Deleuze 7c5bcbcba4 Merge branch '6.1.x' 2024-02-28 17:24:08 +01:00
Sébastien Deleuze 45c21042f6 Optimize Kotlin inline class checks
This commit fixes a performance regression caused by gh-31698,
and more specifically by KClass#isValue invocations which are slow since
they load the whole module to find the class to get the descriptor.

After discussing with the Kotlin team, it has been decided that only
checking for the presence of `@JvmInline` annotation is enough for
Spring use case.

As a consequence, this commit introduces a new
KotlinDetector#isInlineClass method that performs such check, and
BeanUtils, CoroutinesUtils and WebMVC/WebFlux InvocableHandlerMethod
have been refined to leverage it.

Closes gh-32334
2024-02-28 17:18:57 +01:00
Juergen Hoeller 479879c53a Polishing 2024-02-26 13:40:21 +01:00
Juergen Hoeller 9198774f13 Detect wildcard without bounds returned from VariableResolver as well
See gh-32327
See gh-20727
2024-02-25 16:32:11 +01:00
Juergen Hoeller 260404b7f2 Consistently detect wildcard without bounds as unresolvable
Closes gh-32327
See gh-20727
2024-02-24 20:25:56 +01:00
Sam Brannen f59c4023e9 Polishing 2024-02-23 14:46:12 +01:00
Sam Brannen eab1a3dc6b Fix BridgeMethodResolverTests.isBridgeMethodFor() in Eclipse IDE 2024-02-23 12:57:14 +01:00
Sam Brannen 4b5e96578d Extract runningInEclipse() into IdeUtils test fixture 2024-02-23 12:57:06 +01:00
Sam Brannen 122372c580 Spring cleaning: update copyright headers 2024-02-23 12:21:22 +01:00
Sam Brannen c98bebd6d3 Spring cleaning: add missing @⁠Override annotations 2024-02-23 12:20:11 +01:00
Sam Brannen d0ffc16efc Spring cleaning: avoid unnecessary static imports 2024-02-23 12:20:11 +01:00
Sam Brannen 4bd1485ce4 Spring cleaning: use method references 2024-02-23 12:20:11 +01:00
Sam Brannen 4339c8eac2 Spring cleaning: use diamond operator 2024-02-23 12:20:11 +01:00
Arjen Poutsma aee03c5201 Use composite collections in attribute merging
This commit introduces composite collections (i.e. Collection, Set, Map)
and uses these composites in request predicates, where before new
collections were instantiated.

Closes gh-32245
2024-02-22 13:11:20 +01:00
Sam Brannen 644887e094 Polish (Linked)HashSet usage
See gh-32291
2024-02-21 16:22:31 +01:00
Sam Brannen b9c304b890 Polish contribution
See gh-32291
2024-02-21 16:19:53 +01:00
Patrick Strawderman e1a32d4ba9 Avoid resizing of fixed-size HashSet/LinkedHashSet variants
Add helpers to CollectionUtils for building HashSets and LinkedHashSets
that can hold an expected number of elements without needing to
resize/rehash.

Closes gh-32291
2024-02-21 16:19:53 +01:00
Sam Brannen 3fb170058f Polish contribution
See gh-32294
2024-02-21 14:09:09 +01:00
Patrick Strawderman f9fe8efb2e Use ConcurrentHashMap.newKeySet
In places where a ConcurrentHashMap was used as a set by wrapping it
with Collections.newSetFromMap, switch to just using the set returned
by ConcurrentHashMap.newKeySet directly.

Closes gh-32294
2024-02-21 14:08:38 +01:00
Arjen Poutsma c077805761 Set correct capacity in DefaultDataBuffer::setNativeBuffer
Closes gh-30984
2024-02-20 12:36:55 +01:00
Arjen Poutsma 70004e9ad0 Polishing external contribution
Change position and limit on duplicate, rather than source.

See gh-30967
Closes gh-32009
2024-02-20 12:12:35 +01:00
injae-kim 969d0bd08b Set correct limit in DefaultDataBuffer::getNativeBuffer
Closes gh-30967
2024-02-20 12:12:35 +01:00
Juergen Hoeller 0ddfe3977a Merge branch '6.1.x' 2024-02-16 22:50:04 +01:00
Juergen Hoeller 3aae7a66e6 Polishing 2024-02-16 22:27:09 +01:00
Sam Brannen a85bf3185e Remove APIs deprecated for removal in 6.2
This commit removes the following obsolete and deprecated APIs.

- org.springframework.util.Base64Utils

- org.springframework.cache.jcache.interceptor.JCacheOperationSourcePointcut

- org.springframework.http.client.AbstractClientHttpResponse

- org.springframework.http.client.ClientHttpResponse.getRawStatusCode()

- org.springframework.http.client.observation.ClientHttpObservationDocumentation.HighCardinalityKeyNames.CLIENT_NAME

- org.springframework.web.reactive.function.client.ClientHttpObservationDocumentation.HighCardinalityKeyNames.CLIENT_NAME

- org.springframework.web.filter.reactive.ServerWebExchangeContextFilter.get(Context)

- org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler.handleBindException(...)

- org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver.handleBindException(...)

Closes gh-30608
2024-02-16 16:45:18 +01:00
Sam Brannen 6d5bf6d9b3 Ensure alias resolution in SimpleAliasRegistry depends on registration order
Closes gh-32024
2024-02-16 15:22:27 +01:00
Sam Brannen ea4e7df9ca Consistently declare ignoreUnresolvablePlaceholders as last argument 2024-02-16 15:00:32 +01:00
Sam Brannen 7c07c43201 Polishing 2024-02-16 15:00:06 +01:00
Sam Brannen fc9a118406 Polish SimpleCommandLinePropertySource support 2024-02-16 11:41:22 +01:00
Juergen Hoeller ea3573176a Avoid infinite recursion for self-referencing generic type
Closes gh-32282
See gh-30079
2024-02-16 11:15:02 +01:00
Stéphane Nicoll bcf235cc66 Merge branch '6.1.x' 2024-02-16 08:36:26 +01:00
Stéphane Nicoll 6b8105aef2 Update copyright year of changed files
See gh-32281
2024-02-16 08:33:17 +01:00
Patrick Strawderman 481283d2f1 Use Spliterator of underlying collection
Delegate to the spliterator method of the underlying collection in
MutablePropertyValues and MutablePropertySources. In both cases, those
collection types have specialized Spliterator implementations.
Delegating to these Spliterators also means the characteristics of the
Spliterator are properly set.

See gh-32281
2024-02-16 08:32:41 +01:00
Juergen Hoeller 7e67da8a26 Support for matching partial generics
Closes gh-20727
2024-02-15 16:51:09 +01:00
Juergen Hoeller d4e8daaede Add javadoc note on recursive resolution as of 6.2
See gh-30079
2024-02-15 16:50:53 +01:00
Yanming Zhou e788aeb25b Improve GenericTypeResolver to resolve type variable recursively
Fix GH-24963
2024-02-15 16:28:45 +01:00
Stéphane Nicoll e3aa5b6b11 Use new implementation in PropertyPlaceholderHelper
This commit removes the previous implementation in favor of the new
PlaceholderParser. The only noticeable side effect is that the exception
is no longer an IllegalArgumentException, but rather the dedicated
PlaceholderResolutionException.

See gh-9628
2024-02-15 15:27:13 +01:00
Stéphane Nicoll 00e05e603d Add new property placeholder implementation
This commit provides a rewrite of the parser for properties containing
potentially placeholders.

Assuming a source where `firstName` = `John` and `lastName` = `Smith`,
the "${firstName}-${lastName}" property is evaluated as "John-Smith".

Compared with the existing implementation in PropertyPlaceholderHelper,
the new implementation offers the following extra features:

1. Placeholder can be escaped using a configurable escape character.
When a placeholder is escaped it is rendered as is. This does apply to
any nested placeholder that wouldn't be escaped. For instance,
"\${firstName}" is evaluated as "${firstName}".
2. The default separator can also be escaped the same way. When the
separator is escaped, the left and right parts are not considered as
the key and the default value respectively. Rather the two parts
combined, including the separator (but not the escape separator) are
used for resolution. For instance, ${java\:comp/env/test} is looking
for a "java:comp/env/test" property.
3. Placeholders are resolved lazily. Previously, all nested placeholders
were resolved before considering if a separator was present. This
implementation only attempts the resolution of the default value if the
key does not provide a value.
4. Failure to resolve a placeholder are more rich, with a dedicated
PlaceholderResolutionException that contains the resolution chain.

See gh-9628
See gh-26268
2024-02-15 15:27:13 +01:00
Brian Clozel b4131ce131 Support "--" end of options in SimpleCommandLineArgsParser
Prior to this commit, the `SimpleCommandLineArgsParser` would reject
"--" arguments as invalid. As reported by the community, the POSIX
utility conventions (Guideline 10) state that

> The first -- argument that is not an option-argument should be
> accepted as a delimiter indicating the end of options.
> Any following arguments should be treated as operands, even if they
> begin with the '-' character.

This commit updates `SimpleCommandLineArgsParser` to not reject "--"
arguments and instead to consider remaining arguments as non-optional.

See gh-31513
2024-02-15 15:06:17 +01:00
Sam Brannen 10bc93c058 Polishing 2024-02-13 17:22:35 +01:00
Simon Baslé 9b93c948a7 Infer reflection hints for Jackson annotations `builder` attributes
This notably enables Jackson to reflectively call a user-provided
builder class and invoke its declared methods (setters and build) in
a native app.

Closes gh-32238
2024-02-13 15:14:08 +01:00
Juergen Hoeller 0b09f1e12f Use ReentrantLock instead of synchronization for concurrency throttle
Closes gh-32251
2024-02-13 11:03:40 +01:00
Juergen Hoeller a2000dba33 Leniently accept tasks after context close in lifecycle stop phase
Schedulers remain strict, just plain executors are lenient on shutdown now.
An early shutdown for executors can be enforced via setStrictEarlyShutdown.

Closes gh-32226
2024-02-11 21:33:53 +01:00
Sam Brannen 052bbcc530 Cache parameter types array in ClassUtils.findInterfaceMethodIfPossible() 2024-02-08 18:14:22 +01:00
Juergen Hoeller 1a783f41aa Use target class for candidate retrieval but not for method matching
Closes gh-32181
See gh-21843
2024-02-01 18:59:45 +01:00
Juergen Hoeller 00577ed80a Polishing 2024-01-31 17:12:20 +01:00
Sam Brannen 067638ae6e Introduce ClassUtils.isVoidType() utility method 2024-01-30 16:27:34 +01:00
Sam Brannen db535863dd Consistently use class literals for primitive types
To improve consistency and avoid confusion regarding primitive types
and their wrapper types, this commit ensures that we always use class
literals for primitive types.

For example, instead of using the `Void.TYPE` constant, we now
consistently use `void.class`.
2024-01-30 15:26:12 +01:00
Sam Brannen f6d8443781 Fix logic in SupplierUtils 2024-01-29 16:07:44 +01:00
Juergen Hoeller 7e5efdd8dd Reuse MapPropertySource for DynamicValuesPropertySource implementation
Closes gh-32110
2024-01-29 13:04:02 +01:00
Juergen Hoeller c6121da151 Polishing 2024-01-24 22:30:33 +01:00
Juergen Hoeller 5656eaccb7 Avoid bridge resolution for method from unrelated class hierarchy
Closes gh-32087
2024-01-23 10:50:53 +01:00