Commit Graph

3820 Commits

Author SHA1 Message Date
Juergen Hoeller 610626aec6 Ignore non-String keys in PropertiesPropertySource.getPropertyNames()
Closes gh-32742
2024-05-01 15:41:26 +02:00
Juergen Hoeller 0b9b9b4602 Avoid overreading of InputStream in copyRange
Closes gh-32695
2024-04-23 13:16:28 +02:00
Juergen Hoeller ec1f5ca600 Polishing 2024-04-22 13:43:07 +02:00
Juergen Hoeller 62efdfb89c Try early initialization for all user-declared methods (including interfaces)
Closes gh-32682
2024-04-22 13:43:02 +02:00
Sam Brannen e702733c7b Detect bridge methods across ApplicationContexts in MethodIntrospector
Prior to this commit, MethodIntrospector failed to properly detect
bridge methods for subsequent invocations of selectMethods() with the
same targetType and MetadataLookup, if such subsequent invocations
occurred after the ApplicationContext had been refreshed.

The reason this occurs is due to the following.

- Class#getDeclaredMethods() always returns "child copies" of the
  underlying Method instances -- which means that `equals()` should be
  used instead of `==` whenever the compared Method instances can come
  from different sources (such as the static caches mentioned below).

- BridgeMethodResolver caches resolved bridge methods in a static cache
  -- which is never cleared.

- ReflectionUtils caches declared methods in a static cache
  -- which gets cleared when an ApplicationContext is refreshed.

Consequently, if you attempt to load an ApplicationContext twice in the
same ClassLoader, the second attempt uses the existing, populated cache
for bridged methods but a cleared, empty cache for declared methods.
This results in new invocations of Class#getDeclaredMethods(), and
identity checks with `==` then fail to detect equivalent bridge methods.

This commit addresses this by additionally comparing bridge methods
using `equals()` in MethodIntrospector.selectMethods().

Note that the `==` checks remain in place as an optimization for when
`equals()` is unnecessary.

Closes gh-32586
2024-04-09 18:56:41 +02:00
Sam Brannen 187f641409 Polishing 2024-04-09 18:55:39 +02:00
Juergen Hoeller 84963ba4d8 Polishing 2024-04-05 18:04:08 +02:00
Sébastien Deleuze 048e4f0aa2 Invoke KCallablesJvm.setAccessible only when required
Closes-32536
2024-03-28 11:12:50 +01:00
T45K b28153e1d7 Fix handling of value class with private constructor
See gh-32536
2024-03-28 11:11:58 +01:00
Stéphane Nicoll c7c9da56da Consistent atMost period for Awaitility-based tests
Closes gh-32537
2024-03-26 17:45:14 +01:00
Sébastien Deleuze 290a41d398 Refine null-safety in more modules
This commit refines the null-safety in all remaining modules
except spring-test.

See gh-32475
2024-03-26 15:39:18 +01:00
Sébastien Deleuze 1b563f8ba4 Refine null-safety in more modules
This commit refines the null-safety in:
 - spring-jdbc
 - spring-r2dbc
 - spring-orm
 - spring-beans
 - spring-aop

See gh-32475
2024-03-26 09:46:34 +01:00
Sébastien Deleuze 1e80694daf Fix a regression with Kotlin generic controllers
This commit reintroduces a more defensive parameter type check that
skips KClass casting for generic parameters.

Closes gh-32510
2024-03-21 17:55:57 +01:00
Sébastien Deleuze 2e98a8a2a4 Refine null-safety in spring-expression
See gh-32475
2024-03-20 10:07:56 +01:00
Sébastien Deleuze aa0fb97ba5 Nullability refinements
See gh-32475
2024-03-19 13:32:13 +01:00
Juergen Hoeller bd27ddf83a Polishing (aligned with main) 2024-03-19 10:05:32 +01:00
Juergen Hoeller c531a8a705 Nullability refinements and related polishing
See gh-32475
2024-03-19 09:58:44 +01:00
Juergen Hoeller 5dc6a16c0b Nullability refinements
See gh-32475
2024-03-18 16:03:00 +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 b1c3b6e34b Restore original toString representation (revert accidental backport)
See gh-32405
2024-03-17 20:42:29 +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
Juergen Hoeller 723c94e5ac Polishing 2024-03-12 20:10:01 +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
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
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 c1d4b610ca Refine Kotlin inline class optimizations
Closes gh-32334
2024-03-07 11:11:20 +01:00
Juergen Hoeller a0ae849856 Polishing 2024-03-05 18:23:13 +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 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 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
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 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 3aae7a66e6 Polishing 2024-02-16 22:27:09 +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
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