Commit Graph

3043 Commits

Author SHA1 Message Date
Stephane Nicoll
f2e9d112b1 Fix TypeReference#getName for CGLIB proxies
This commit makes sure that the double '$' sign typically used by
generated cglib proxies are not used as an inner class separator.

Closes gh-29252
2022-10-04 16:49:13 +02:00
Sam Brannen
5bff2c7341 Clean up warnings in tests 2022-10-04 16:19:37 +02:00
Sam Brannen
31d98bfd95 Ensure PathMatchingResourcePatternResolverTests run in native image
See inline comments in commit for details.

See gh-29243
2022-10-04 16:13:46 +02:00
Sam Brannen
dd814b6d30 Test sub-paths in PathMatchingResourcePatternResolverTests
This commit introduces assertions that verify that the sub-path is
properly URL-decoded when a path contains `#`. The additional assertions
are necessary since the existing assertions use Resource#getFilename
which already implicitly decodes the path.

See gh-29243
2022-10-04 15:50:33 +02:00
Sam Brannen
ddc7aef51b Merge branch '5.3.x'
# Conflicts:
#	spring-core/src/test/java/org/springframework/core/io/support/PathMatchingResourcePatternResolverTests.java
2022-10-04 14:31:43 +02:00
Sam Brannen
fee38175b3 Revert "Test encoding and Unicode normalization for scanned resources"
This reverts commit eb2c1cbcd4.
2022-10-04 14:29:22 +02:00
Sam Brannen
2ce314d4dd Modify PathMatchingResourcePatternResolverTests so that it passes on main
See gh-29243
2022-10-04 13:22:44 +02:00
Sam Brannen
5b08bc29b1 Merge branch '5.3.x' 2022-10-04 13:21:30 +02:00
Sam Brannen
eb2c1cbcd4 Test encoding and Unicode normalization for scanned resources
This commit introduces tests which serve as "regression tests" for the
behavior of PathMatchingResourcePatternResolver in Spring Framework
5.3.x with regard to URL-encoding and Unicode normalization of resource
paths.

Specifically, the new tests demonstrate that resource paths do NOT need
to be decoded or normalized in 5.3.x.

See gh-29243
2022-10-04 13:19:59 +02:00
Juergen Hoeller
4a2b058b0a Enforce static initialization of CGLIB method proxies on attemptLoad
This propagates current Enhancer settings (naming strategy etc) to the method proxies.

See gh-29107
2022-10-04 12:24:09 +02:00
Sam Brannen
01025c8551 Merge branch '5.3.x'
# Conflicts:
#	spring-core/src/test/java/org/springframework/core/io/support/PathMatchingResourcePatternResolverTests.java
2022-10-04 12:08:16 +02:00
Sam Brannen
7241c30141 Backport changes to PathMatchingResourcePatternResolverTests 2022-10-04 11:48:29 +02:00
Brian Clozel
3b91eea0b7 Support parsing locales without country, with variant
Prior to this commit, the parsing algorithm in
`StringUtils#parseLocaleString` would skip empty tokens, turning
`en__VARIANT` into `en_VARIANT` when parsed.

This commit ensures that such cases are now supported and that more
invalid formats are rejected by the parser.

Fixes gh-29248
2022-10-03 22:44:09 +02:00
Violeta Georgieva
b5adae2086 Switch to Reactor Netty 2 snapshots
Update to Reactor BOM 2022.0.0-SNAPSHOT.
Process package changes.
Adapt to new `HttpHeaders` API.
Adapt to new cookies API.

See gh-29247
2022-10-03 18:20:52 +01:00
Juergen Hoeller
1b1682eacd Narrow early initialization of CGLIB method proxies (for AOT processing)
Do not trigger early initialization on Factory classes (e.g. AOP proxies)

See gh-29107
2022-10-03 18:00:57 +02:00
Stephane Nicoll
3b2b36d0b8 Allow AccessControl to determine visibility from a given type
This commit adapts AccessVisibility so that it can determine if the
member or type signature is accessible from a given package. This lets
implementers figure out if reflection is necessary without assuming that
package private visibility is OK.

Closes gh-29245
2022-10-03 17:56:19 +02:00
Sam Brannen
df58c00bf5 Restore GraalVM native image resource scanning support
This commit restores support for the GraalVM native image file system
in PathMatchingResourcePatternResolver.

Closes gh-29226
2022-10-03 17:38:30 +02:00
Juergen Hoeller
51875cdf5f Defensive early initialization of CGLIB method proxies (for AOT processing)
Method proxies might not actually be used later on, so failure is not fatal.

See gh-29107
2022-10-03 16:43:43 +02:00
Juergen Hoeller
740d3d931a Restore Windows compatibility through streamlined Path API interaction
In addition to consistent use of cleaned file paths, this revision avoids FileSystem SPI interaction, resolving NIO Path instances from URI (and FileSystemResource from Path).

See gh-29226
2022-10-03 16:08:46 +02:00
Sam Brannen
d79d2fc573 Ensure ClassPathResourceTests can pass on MS Windows 2022-10-03 15:34:45 +02:00
Juergen Hoeller
d873f60fef Enforce early initialization of CGLIB method proxies (for AOT processing)
For non-required method proxies, prefer regular reflective invocation instead.

See gh-29107
2022-10-03 13:22:49 +02:00
Brian Clozel
43d39d4e8a Enforce need for type reflection in RuntimeHintsAgent
Prior to this commit, the AOT infrastructure would rely on the fact that
native runtime reflection on a type would only consider
methods/fields/constructors that had specific hints contributed. When
listing them through the reflection API on the type, the native image
would only return those for which we had hints contributed.
This behavior will soon change in GraalVM and will better align with the
JVM behavior: when asking for all declared methods on a type in a native
image, we should get all existing methods, not just the ones registered
previously in the native image.

This commit aligns the behavior of the `RuntimeHintsAgent` and removes
the now misleading predicates as a consequence.

Closes gh-29205
2022-10-03 11:31:24 +02:00
Brian Clozel
94da3609af Ignore Blockhound tests on Java 19 2022-10-02 16:23:42 +02:00
Johnny Lim
89db4efb67 Polish ReflectionHintsPredicates
See gh-29230
2022-09-30 15:23:35 +02:00
Sam Brannen
2606557483 Polishing 2022-09-30 13:32:33 +02:00
Sam Brannen
d21eea7de4 Fix recent regression in PathMatchingResourcePatternResolver
Commit 0eb66789ed which introduced generic FileSystem support in
PathMatchingResourcePatternResolver also introduced a regression in that
a matching folder is now returned in the results.

This commit address this by additionally using Files#isRegularFile() in
the predicate used to filter candidates.

Closes gh-29163
2022-09-30 13:05:31 +02:00
Sam Brannen
6cb131ac76 Polishing 2022-09-28 14:27:36 +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
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
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
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
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
0ccb64fe10 Replace Collectors.toList with Stream.toList
Closes gh-29203
2022-09-26 18:32:01 +02:00
Сергей Цыпанов
8a87e118e1 Remove redundant assignment of default values to volatile/atomic fields
Closes gh-27477
2022-09-26 13:43:04 +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
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
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
Sam Brannen
f31eb2dcf9 Skip scanning the module path when running in a native image
Prior to this commit, the following exception was thrown when using the
PathMatchingResourcePatternResolver to scan for class path resources
using the `classpath*:` prefix within a native image.

com.oracle.svm.core.jdk.UnsupportedFeatureError: JRT file system is disabled
com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:89)
jdk.internal.module.SystemModuleFinders$SystemImage.reader(SystemModuleFinders.java:139)
jdk.internal.module.SystemModuleFinders$ModuleContentSpliterator.<init>(SystemModuleFinders.java:527)
jdk.internal.module.SystemModuleFinders$SystemModuleReader.list(SystemModuleFinders.java:502)
org.springframework.core.io.support.PathMatchingResourcePatternResolver.lambda$findAllModulePathResources$6(PathMatchingResourcePatternResolver.java:819)

This commit addresses this by not attempting to scan the module path
when running in a GraalVM native image.

Closes gh-29183
2022-09-25 19:31:06 +02:00
Sam Brannen
29442d4b7a Revamp PathMatchingResourcePatternResolverTests
In preparation for gh-29163, this commit revamps
PathMatchingResourcePatternResolverTests as follows.

- organizes tests into @Nested test classes

- reintroduces the @Disabled classpathStarWithPatternOnFileSystem() test

- stops asserting the protocol of Resource URLs, since the protocol is
  dependent on the environment -- for example, file: and jar: URLs are
  actually resource: URLs within a GraalVM native image

- simplifies implementation of test methods and assertFilenames()
2022-09-25 16:12:46 +02:00
rstoyanchev
c2f1ddcee9 Consistent Nullable input in Hints 2022-09-23 16:54:15 +01:00