Commit Graph

4106 Commits

Author SHA1 Message Date
Sam Brannen 5532574f56 Remove unused casts and variables 2024-10-25 15:16:05 +02:00
Sam Brannen 1b3e96b9bf Merge branch '6.1.x' 2024-10-25 14:49:46 +02:00
Sam Brannen e340e45f5a Rename aopAvailable constants in TransactionSynchronizationUtils
Closes gh-33796
2024-10-25 14:41:41 +02:00
Juergen Hoeller 081d0b33d4 Consistently sort jar entries in doFindPathMatchingJarResources
Includes consistent clearCache() behavior for manifest entries.

Closes gh-33771
See gh-33705
2024-10-22 21:29:22 +02:00
Phillip Webb 1c69a3c521 Fix `PathMatchingResourcePatternResolver` manifest classpath discovery
Update `PathMatchingResourcePatternResolver` so that in addition to
searching the `java.class.path` system property for classpath enties,
it also searches the `MANIFEST.MF` files from within those jars.

Prior to this commit, the `addClassPathManifestEntries()` method
expected that the JVM had added `Class-Path` manifest entries to the
`java.class.path` system property, however, this did not always happen.

The updated code now performs a deep search by loading `MANIFEST.MF`
files from jars discovered from the system property. To deal with
potential performance issue, loaded results are also now cached.

The updated code has been tested with Spring Boot 3.3 jars extracted
using `java -Djarmode=tools`.

See gh-33705
2024-10-22 21:10:29 +02:00
Juergen Hoeller 267d3a36ae Merge branch '6.1.x'
# Conflicts:
#	spring-context/src/main/java/org/springframework/instrument/classloading/jboss/JBossLoadTimeWeaver.java
2024-10-21 18:14:50 +02:00
Juergen Hoeller e235e661d8 Polishing 2024-10-21 18:13:42 +02:00
Stéphane Nicoll bdf76b2f8d Restore nested property resolution for non CharSequence types
Closes gh-33727

Co-authored-by: Andy Wilkinson <andy.wilkinson@broadcom.com>
2024-10-17 10:25:50 +02:00
Juergen Hoeller fa955934e7 Merge branch '6.1.x'
# Conflicts:
#	spring-beans/src/main/java/org/springframework/beans/factory/annotation/QualifierAnnotationAutowireCandidateResolver.java
2024-10-16 17:19:30 +02:00
Juergen Hoeller fde7116ae4 Consistently skip processing of plain Java annotations
Closes gh-33580
2024-10-16 17:17:22 +02:00
Juergen Hoeller e89218b39a Merge branch '6.1.x' 2024-10-16 13:46:22 +02:00
Juergen Hoeller 11d4272ff4 Use Locale.ROOT consistently for toLower/toUpperCase
Closes gh-33708
2024-10-16 13:36:23 +02:00
rstoyanchev bdcfbee7df Merge branch '6.1.x' 2024-10-16 12:11:23 +01:00
rstoyanchev 23656aebc6 Use Locale.ROOT consistently for toLower/toUpperCase
See gh-33708
2024-10-16 12:05:54 +01:00
Juergen Hoeller fb6a6892ef Merge branch '6.1.x' 2024-10-16 11:36:30 +02:00
Juergen Hoeller feb6a5f52d Polishing 2024-10-16 11:35:23 +02:00
Tran Ngoc Nhan e191c34078 Polishing
Closes gh-33681
2024-10-14 16:44:42 +02:00
KimJuHyun 5bcce17fd9 Add tests for CollectionUtils
- findValueOfType
- findCommonElementType
- firstElement
- lastElement
- toArray
- compositeMap

Closes gh-33694
2024-10-14 16:10:05 +02:00
Sam Brannen 59ef5e140f Update warning for use of convention-based annotation attribute overrides
See gh-28761
2024-10-09 10:03:22 +02:00
Sam Brannen ad4f0c99bf Polish StringUtilsTests 2024-10-06 15:36:16 +02:00
zinzo 2cd1ee8a24 Add unit tests for StringUtils.hasLength()
Closes gh-33658
2024-10-06 15:28:41 +02:00
Sam Brannen b0c7d15d9f Polishing 2024-10-05 13:57:24 +02:00
Park Sung Jun 32df079b05 Polish use of constants in StringUtils
The hardcoded '.' and '\\' literals have been replaced by the use of
EXTENSION_SEPARATOR and WINDOWS_FOLDER_SEPARATOR_CHAR.

Closes gh-33654
2024-10-05 13:57:24 +02:00
SungbinYang 65ac17ee78 Refactor: Replace hardcoded path separator with PATH_SEPARATOR constant
Replaced the hardcoded '/' path separator with the `PATH_SEPARATOR` constant
to improve code readability and maintainability. This change ensures
consistency across the codebase when handling path separators.

Closes gh-33646
2024-10-04 09:19:16 +02:00
Sam Brannen 309897497a Update copyright header 2024-10-01 12:35:01 +02:00
Hyunwoo Kim 893f5dcb9b
Replace "null" with NULL_STRING constant in ObjectUtils.nullSafeConciseToString()
Closes gh-33625
2024-10-01 12:33:40 +02:00
Sébastien Deleuze 56a0a33e5d Add a missing test case for ObjectUtils#unwrapOptional
Closes gh-33618
2024-10-01 09:42:58 +02:00
Tran Ngoc Nhan 4d87c77649 Add test cases for ObjectUtils#unwrapOptional
See gh-33618
2024-10-01 09:41:39 +02:00
SungbinYang fc8bd64f34 Simplify ObjectUtils#unwrapOptional
This commit replaces optional.isEmpty() and optional.get() with
optional.orElse(null) for better efficiency and readability.

Closes gh-33612
2024-09-30 18:32:43 +02:00
Yanming Zhou 8941e2876e Replace 'e.g.' with 'for example' in documentation and comments
Closes gh-33515
2024-09-26 14:11:17 +02:00
Juergen Hoeller 073cfd405b Merge branch '6.1.x' 2024-09-25 14:24:35 +02:00
Juergen Hoeller 49da92b6a3 Avoid http URL String (making checkstyleNohttp happy)
See gh-33561
2024-09-25 13:53:34 +02:00
Juergen Hoeller 885f650911 Merge branch '6.1.x' 2024-09-25 12:46:37 +02:00
Juergen Hoeller daa109e2ec Preserve URLStreamHandler in toRelativeURL and convertClassLoaderURL
Closes gh-33561
See gh-33199
2024-09-25 12:45:34 +02:00
rstoyanchev 7051cddcf7 Align OutputStreamPublisher's
Align internal handling and contracts. The core copy could do without
those contracts, but it helps with alignment, and it's internal to
the implementation.

Closes gh-33592
2024-09-25 11:42:26 +01:00
rstoyanchev f6c31bb6c3 Align OutputStreamPublisher's
Update constructors to match and drop unnecessary factory methods.

See gh-33592
2024-09-25 11:42:26 +01:00
rstoyanchev 113b430fab Align OutputStreamPublisher's
Apply recent nullability changes, and formatting differences.

See gh-33592
2024-09-25 11:42:26 +01:00
Juergen Hoeller 5f6b8d5582 Polishing 2024-09-24 18:59:17 +02:00
Simon Baslé f7aa4409bb Merge branch '6.1.x' 2024-09-24 11:01:57 +02:00
Simon Baslé 7df9db3bb7 Polishing test
Assert that BlockHound doesn't trigger, rather than assertions on a
condition that makes the test flakky because concurrency is involved.
2024-09-24 11:01:37 +02:00
Tran Ngoc Nhan c85050eb43 Consistently use CharSequence.isEmpty() for emptiness checks
Closes gh-33577
2024-09-23 17:10:21 +02:00
Simon Baslé 06d240b558 Merge branch '6.1.x' 2024-09-17 16:42:09 +02:00
Simon Baslé de4ff4b44b Polishing tests
This commit adds more test coverage of SpringCoreBlockHoundIntegration.

See gh-33450
2024-09-17 16:40:40 +02:00
Simon Baslé f6e96a24d4 Add BlockHound exception for ConcurrentReferenceHashMap$ReferenceManager
This commit adds a SpringCoreBlockHoundIntegration configuration to
allows `pollForPurge` method to block.

Closes gh-33450
2024-09-17 16:40:40 +02:00
Juergen Hoeller 20bc5ef68b Accept nested array type for upUntilUnresolvable check as well
Closes gh-33535
2024-09-17 16:20:54 +02:00
Sébastien Deleuze 52f0e8fb6d Refine null-safety for additional Assert methods
Closes gh-33530
2024-09-13 14:47:00 +02:00
Juergen Hoeller e9f9a7ae8e Merge branch '6.1.x'
# Conflicts:
#	framework-platform/framework-platform.gradle
2024-09-11 17:17:38 +02:00
Juergen Hoeller 54dbb9f52a Upgrade to Objenesis 3.4
Closes gh-33526
2024-09-11 17:15:37 +02:00
Patrick Strawderman 7827188e8e Avoid empty array allocations in AnnotationTypeMapping
Closes gh-33507
2024-09-11 09:49:39 +02:00
Patrick Strawderman 2b6639e587 Avoid storing duplicate empty array in MethodParameter field
Avoid storing duplicate empty arrays in the parameterAnnotations field of MethodParameter.

Closes gh-33496
2024-09-06 10:02:02 +02:00
Patrick Strawderman f88c314e83 Avoid empty array allocations in ResolvableType
Avoid allocating empty arrays in a few places in ResolvableType.

Closes gh-33473
2024-09-04 10:40:20 +02:00
Sam Brannen 717b972f88 Polish contribution
See gh-33452
2024-09-03 18:08:23 +02:00
Yanming Zhou 019c0b1d4e
Expand acronyms FQN and FQCN
Closes gh-33452
2024-09-03 17:30:27 +02:00
Johnny Lim 6e640f0800 Add Javadoc since for ReflectionHints.registerForInterfaces()
See gh-32824
Closed gh-33458
2024-09-02 16:21:35 +02:00
Juergen Hoeller 69d5587f53 Merge branch '6.1.x'
# Conflicts:
#	spring-context/src/main/java/org/springframework/scheduling/annotation/Scheduled.java
2024-08-31 12:04:29 +02:00
Juergen Hoeller 5d80d75051 Follow symlinks during root path traversal
Closes gh-33424
2024-08-31 12:00:14 +02:00
Sam Brannen 167cb5d494 Polishing 2024-08-29 17:02:08 +02:00
Sam Brannen ba774c6290 Restore behavior for ClassUtils.getInterfaceMethodIfPossible()
Commit 47f88e123f introduced support for invoking init/destroy/SpEL
methods via public types whenever possible. To achieve that,
getInterfaceMethodIfPossible() was modified so that it only returned
interface methods from public interfaces; however, we have learned that
third parties relied on the previous behavior which found any interface
method (even in non-public interfaces).

In light of the above, this commit partially reverts commit 47f88e123f
in order to reinstate getInterfaceMethodIfPossible() in non-deprecated
form with its previous behavior.

See gh-33216
2024-08-27 11:42:07 +02:00
Sam Brannen d2ea5b4448 Polish internal Javadoc 2024-08-23 11:24:22 +02:00
Sam Brannen 47f88e123f Invoke init/destroy/SpEL methods via public types whenever possible
Prior to this commit, when invoking init methods and destroy methods
for beans as well as methods within Spring Expression Language (SpEL)
expressions via reflection, we invoked them based on the "interface
method" returned from ClassUtils.getInterfaceMethodIfPossible(). That
works well for finding methods defined in an interface, but it does not
find public methods defined in a public superclass.

For example, in a SpEL expression it was previously impossible to
invoke toString() on a non-public type from a different module. This
could be seen when attempting to invoke toString() on an unmodifiable
list created by Collections.unmodifiableList(...). Doing so resulted in
an InaccessibleObjectException.

Although users can address that by adding an appropriate --add-opens
declaration, such as --add-opens java.base/java.util=ALL-UNNAMED, it is
better if applications do not have to add an --add-opens declaration
for such use cases in SpEL. The same applies to init methods and
destroy methods for beans.

This commit therefore introduces a new
getPubliclyAccessibleMethodIfPossible() method in ClassUtils which
serves as a replacement for getInterfaceMethodIfPossible().

This new method finds the first publicly accessible method in the
supplied method's type hierarchy that has a method signature equivalent
to the supplied method. If the supplied method is public and declared
in a public type, the supplied method will be returned. Otherwise, this
method recursively searches the class hierarchy and implemented
interfaces for an equivalent method that is public and declared in a
public type. If a publicly accessible equivalent method cannot be
found, the supplied method will be returned, indicating that no such
equivalent method exists.

All usage of getInterfaceMethodIfPossible() has been replaced with
getPubliclyAccessibleMethodIfPossible() in spring-beans and
spring-expression. In addition, getInterfaceMethodIfPossible() has been
marked as deprecated in favor of the new method.

As a bonus, the introduction of getPubliclyAccessibleMethodIfPossible()
allows us to delete a fair amount of obsolete code within the SpEL
infrastructure.

See gh-29857
Closes gh-33216
2024-08-22 14:35:21 +02:00
Sam Brannen cac623b3f4 Refer to the "Java Module System" instead of "Jigsaw" 2024-08-22 13:00:39 +02:00
Sébastien Deleuze a9a1798012 Merge branch '6.1.x' 2024-08-16 14:37:56 +02:00
Sébastien Deleuze 46c29b9175 Support Boolean property in BindingReflectionHintsRegistrar
Closes gh-33380
2024-08-16 14:37:12 +02:00
Sam Brannen d749d2949d Use new features from JUnit Jupiter 5.11
This commit primarily migrates to the new argumentSet() feature but also
applies additional polishing to our use of parameterized tests.

See gh-33395
2024-08-16 13:48:19 +02:00
Juergen Hoeller e1cf203295 Merge branch '6.1.x'
# Conflicts:
#	framework-platform/framework-platform.gradle
2024-08-13 19:05:20 +02:00
Juergen Hoeller d0bff584d7 Polishing 2024-08-13 18:51:02 +02:00
Sam Brannen f6110dda06 Polishing 2024-08-08 17:48:57 +03:00
Sam Brannen f4604cfab3 Merge branch '6.1.x' 2024-08-04 17:14:10 +03:00
Sam Brannen cb6a5baac5 Support conversion from primitive array to Object[] in ConversionService
Prior to this commit, the ConversionService failed to convert a primitive
array (such as int[]) to an Object[] due to an error in the logic in
ArrayToArrayConverter.

This commit addresses this by augmenting the "can bypass conversion"
check in ArrayToArrayConverter to ensure that the supplied source object
is an instance of the target type (i.e., that the source array can be
cast to the target type array without conversion).

Closes gh-33212
2024-08-04 17:13:56 +03:00
Stéphane Nicoll ec9d29ea8f Polish "Improve test coverage of StringUtils"
See gh-33298
2024-08-01 07:32:41 +02:00
zinzo a2cae4c8f4 Improve test coverage of StringUtils
This commit adds tests for `trimArrayElements()` and
`delimitedListToStringArray()` in StringUtils.

See gh-33298
2024-08-01 07:23:28 +02:00
Stéphane Nicoll b6fbbeccdc Polish "Resolved nested placeholder for CharSequence"
See gh-32876
2024-07-22 14:59:58 +02:00
Sam Brannen aa2829455b Expand test coverage for gh-14200 2024-07-13 17:26:26 +02:00
Sam Brannen 59b9404956 Specify nullability @⁠Contract for TypeDescriptor.array() 2024-07-12 18:02:26 +02:00
Sam Brannen 09d8e4458c Merge branch '6.1.x' 2024-07-12 17:37:51 +02:00
Sam Brannen ae5dd54115 Add @⁠Disabled tests for primitive varargs array to Object[] conversion 2024-07-12 17:36:54 +02:00
Juergen Hoeller d1f9e35b35 Merge branch '6.1.x' 2024-07-11 16:16:31 +02:00
Juergen Hoeller 2bfff7fc37 Retain original URL instance in case of custom URLStreamHandler
Closes gh-33199
2024-07-11 16:15:42 +02:00
Sébastien Deleuze 7617a01f60 Unwrap Kotlin inline value classes return values
The result returned by Kotlin reflective invocation of a function
returning an inline value class is wrapped, which makes sense
from Kotlin POV but from a JVM perspective the associated value
and type should be unwrapped to be consistent with what
would happen with a reflective invocation done by Java.

This commit unwraps such result.

Closes gh-33026
2024-07-10 18:38:37 +02:00
gregw 0a60c622cc Implement Eclipse Jetty core HTTP handler adapter
This provides an implementation of an HTTP Handler Adapter that is coded
directly to the Eclipse Jetty core API, bypassing any servlet
implementation.

This includes a Jetty implementation of the spring `WebSocketClient`
interface, `JettyWebSocketClient`, using an explicit dependency to the
jetty-websocket-api.

Closes gh-32097

Co-authored-by: Lachlan Roberts <lachlan@webtide.com>
Co-authored-by: Arjen Poutsma <arjen.poutsma@broadcom.com>
2024-07-08 18:36:46 +02:00
Stéphane Nicoll 93587da394 Introduce ReflectiveScan
This commit allows `@Reflective` to be used on arbitrary types, not
only Spring beans. This makes the feature much more powerful as
components can be tagged directly.

Scanning happens during AOT processing (typically at build-time) when
`@ReflectiveScan` is used. Types do not need to have a particular
annotation, and types that can't be loaded are ignored.

This commit also exposes the infrastructure that does the scanning so
that custom code can do the scanning in an AOT contribution if they
don't want to rely on the annotation.

Closes gh-33132
2024-07-08 11:11:48 +02:00
Stéphane Nicoll f4607da45f Introduce RegisterReflection
This commit introduces a declarative way of registering reflection
information for arbitrary types. Types can be specified as a class,
a class name, or by annotating the type itself.

This existing RegisterReflectionForBinding becomes a specialized
version of the new annotation, registering the necessary hints for
data binding.

Closes gh-29194
2024-07-04 17:49:41 +02:00
Stéphane Nicoll 1ea4eb147a Polish 2024-07-03 10:04:51 +02:00
Stéphane Nicoll 99e8978a91 Restore binary backward compatibility for GeneratedFiles
See gh-31331
2024-07-03 09:57:22 +02:00
Sam Brannen 932ce04541 Stop referring to old Spring versions in Javadoc 2024-07-01 17:50:52 +02:00
Stephane Nicoll 0ea7af7465 Polish
See gh-31331
2024-06-24 18:07:59 +02:00
Sébastien Deleuze 8ef74dfdad Prevent compilation warnings with `@Nullable`
This commit replaces `@Nonnull(when = When.MAYBE)` meta-annotation in
org.springframework.lang.Nullable by `@CheckForNull` in order to
prevent "unknown enum constant When.MAYBE" compilation warnings.

IntelliJ IDEA 2024.1.2+ is required to interpret correctly the related
annotations.

Closes gh-27183
2024-06-24 14:56:07 +02:00
Juergen Hoeller 0a0f4c7460 Accept file separator difference in exception message (for Windows compatibility) 2024-06-24 12:28:43 +02:00
Juergen Hoeller d9a2e0b731 Merge branch '6.1.x' 2024-06-24 12:27:23 +02:00
Juergen Hoeller 4e2fb308f6 Document contentLength() behavior for InputStreamResource and custom subclasses
Closes gh-33089
2024-06-24 12:10:35 +02:00
Brian Clozel f9af5d400d Use custom path separator for pattern comparisons
As pointed out in gh-33085, the `AntPatternComparator` hardcodes the "/"
separator when checking for "catch all" patterns like "/**".
This commit ensures that the custom path separator is used for those
checks, in order to guarantee consistent comparator results.

See gh-33085
2024-06-24 11:37:24 +02:00
Brian Clozel 6d1f117103 Polishing contribution
Closes gh-33085
2024-06-24 11:37:16 +02:00
tafjwr 83fcdfba64 Fix AntPathMatcher URI template variable extractor
See gh-33085
2024-06-24 11:37:09 +02:00
Stephane Nicoll 2650da2b53 Provide more control over registration of GeneratedFiles
This commit provides an advanced handling of generated files that
provides more control over files registration. The callback provides
a FileHandler that can determine if the file already exists and its
content. The caller can then chose to override the content or leave it
as it is.

Closes gh-31331
2024-06-22 18:52:33 +02:00
Stéphane Nicoll 5cf8978d22 Restore proper code generation for types with nested generics
This commit aligns code generation to recent improvement in the core
container regarding type detection. Now that nested types are properly
resolved, our code generation that uses hasResolvableGenerics() is
taking the wrong decision if only a nested type has an unresolved
generics. Previously, this was hidden by the fact that the core
container would not resolve them recursively.

A new hasResolvableGenerics() method allows to verify that at least
one direct generic type is resolved. This restore our intent of checking
at the first level only and let recursive invocations figure out if they
have to write the raw type or the type with generics.

Closes gh-33069
2024-06-19 17:48:39 +02:00
Juergen Hoeller 6d5c312027 Merge branch '6.1.x' 2024-06-17 18:44:50 +02:00
Juergen Hoeller 2c3c3831c1 Consistently ignore bridge method on generated subclass for visibility purposes
Closes gh-33030
2024-06-17 18:42:20 +02:00
Stéphane Nicoll 720b7c1dac Merge branch '6.1.x' 2024-06-11 06:53:22 +02:00
Stéphane Nicoll 6b7f0bd4b6 Fix typo 2024-06-11 06:47:42 +02:00
Sébastien Deleuze 68e6b152ef Merge branch '6.1.x' 2024-06-10 22:46:03 +02:00