Commit Graph

684 Commits

Author SHA1 Message Date
Juergen Hoeller
c1932dd307 Support for MultiValueMap elements in bean property paths
Closes gh-26297
2023-07-12 16:23:39 +02:00
Sam Brannen
16b9640af2 Merge branch '6.0.x' 2023-07-12 11:50:11 +02:00
Sam Brannen
68f2b0ca59 Rely on auto-boxing in tests 2023-07-12 11:49:02 +02:00
Juergen Hoeller
c20a2e4763 Support for indexing into any Collection/Iterable
Closes gh-907
2023-07-11 23:07:51 +02:00
Sam Brannen
b32b4f3a59 Polish DefaultSingletonBeanRegistryTests 2023-07-09 15:32:20 +02:00
Sébastien Deleuze
b3de1b8e95 Use consistently *KotlinTests naming for Kotlin tests
Closes gh-30837
2023-07-08 11:02:20 +02:00
Sébastien Deleuze
fb17e283d1 Replace @link by proper KDoc class reference in tests
Closes gh-30836
2023-07-08 10:44:40 +02:00
Sam Brannen
ae13823851 Polishing 2023-07-05 15:33:15 +02:00
Juergen Hoeller
0226580773 Refresh cached value after unexpected mismatch (e.g. null vs non-null)
In addition to the previously addressed removal of bean definitions, this is able to deal with prototype factory methods returning non-null after null or also null after non-null. Stale cached values are getting refreshed rather than bypassed.

Closes gh-30794
2023-07-04 15:58:30 +02:00
Juergen Hoeller
e902f9551a Improve condition assertions 2023-06-29 12:05:07 +02:00
Sébastien Deleuze
7137b22e6b Fix test compilation warnings
Closes gh-30753
2023-06-26 12:03:27 +02:00
Sam Brannen
3181dca5ef Support [package-]private init/destroy methods in AOT mode
Prior to this commit, private (and non-visible package-private)
init/destroy methods were not supported in AOT mode. The reason is that
such methods are tracked using their fully-qualified method names, and
the AOT support for init/destroy methods previously did not take
fully-qualified method names into account. In addition, the invocation
order of init/destroy methods differed vastly between standard JVM mode
and AOT mode.

This commit addresses these issues in the following ways.

- AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(),
  DisposableBeanAdapter.determineDestroyMethod(), and
  BeanDefinitionPropertiesCodeGenerator.addInitDestroyHint() now parse
  fully-qualified method names to locate the correct init/destroy
  methods.

- AbstractAutowireCapableBeanFactory and DisposableBeanAdapter delegate
  to a new MethodDescriptor record which encapsulates the parsing of
  fully-qualified method names; however,
  BeanDefinitionPropertiesCodeGenerator duplicates this logic since it
  resides in a different package, and we do not currently want to make
  MethodDescriptor public.

- Init/destroy methods detected via annotations (such as @PostConstruct
  and @PreDestroy) are now invoked prior to init/destroy methods that
  are explicitly configured by name or convention. This aligns with the
  invocation order in standard JVM mode; however,
  InitializingBean#afterPropertiesSet() and DisposableBean#destroy()
  are still invoked before annotated init/destroy methods in AOT mode
  which differs from standard JVM mode.

- Unit and integration tests have been updated to test the revised
  behavior.

Closes gh-30692
2023-06-24 14:22:17 +02:00
Sam Brannen
0521cdda88 Merge branch '6.0.x' 2023-07-09 15:38:55 +02:00
Sébastien Deleuze
8fb412ea74 Merge branch '6.0.x' 2023-07-08 11:11:37 +02:00
Sébastien Deleuze
a03a14797f Add AOT support for Kotlin constructors with optional parameters
This commit leverages Kotlin reflection to instantiate classes
with constructors using optional parameters in the code
generated AOT.

Closes gh-29820
2023-07-07 17:40:31 +02:00
Sam Brannen
f6218cadd7 Merge branch '6.0.x' 2023-07-05 15:33:26 +02:00
Juergen Hoeller
2a77665be7 Merge branch '6.0.x' 2023-07-04 15:59:38 +02:00
Juergen Hoeller
ef4d93507d Merge branch '6.0.x' 2023-06-29 12:05:57 +02:00
Sébastien Deleuze
66b27e6dc8 Merge branch '6.0.x' 2023-06-26 12:03:40 +02:00
Sam Brannen
209e02cf29 Merge branch '6.0.x' 2023-06-24 14:27:13 +02:00
Sam Brannen
5598dd2c34 Merge branch '6.0.x' 2023-06-22 13:54:04 +02:00
Sam Brannen
32f061a3e0 Polishing 2023-06-22 13:48:07 +02:00
Sam Brannen
abefc0aba0 Merge branch '6.0.x' 2023-06-21 17:54:16 +02:00
Sam Brannen
9a5290ea27 Apply project conventions to formatting 2023-06-21 17:50:42 +02:00
Stephane Nicoll
b581a79eed Merge branch '6.0.x' 2023-06-21 14:51:00 +02:00
Stephane Nicoll
6c42f374c8 Consistently set target type in generated code
Previously, a bean definition that is optimized AOT could have
different metadata based on whether its resolved type had a generic or
not. This is due to RootBeanDefinition taking either a Class or a
ResolvableType doing fundamentally different things. While the former
sets the bean class which is to little use with an instance supplier,
the latter specifies the target type of the bean.

This commit sets the target type of the bean, using the existing
setter methods that take either a class or a ResolvableType and set the
same attribute consistently.

Closes gh-30689
2023-06-21 14:45:19 +02:00
Sam Brannen
6535614d78 Merge branch '6.0.x' 2023-06-21 14:22:11 +02:00
Sam Brannen
4879b56bb9 Test status quo for private init/destroy methods in AOT mode
This commit only tests which init/destroy methods are "registered" in
AOT mode.

This commit does NOT test that the registered methods can actually be
invoked in AOT mode: that will be addressed in a separate commit.

See gh-30692
2023-06-21 14:19:13 +02:00
Juergen Hoeller
1a201cd180 Merge branch '6.0.x'
# Conflicts:
#	spring-jcl/src/main/java/org/apache/commons/logging/LogFactory.java
2023-06-21 09:51:11 +02:00
Juergen Hoeller
049a024dea Deprecate RootBeanDefinition(ResolvableType) constructor
Closes gh-30704
2023-06-21 09:48:00 +02:00
Juergen Hoeller
ca4de8f191 Consistent simple value type check
Includes UUID treatment for data binding and bean dependency checks.

Closes gh-30664
2023-06-14 09:37:39 +02:00
Sam Brannen
e7c3e1c516 Merge branch '6.0.x' 2023-06-13 17:14:03 +02:00
Sam Brannen
ed74b04520 Move web-related test for BeanUtilsRuntimeHints to spring-web
The dependency on spring-web from spring-beans makes it impossible to
import the projects in Eclipse IDE due to cycles between projects.

This commit therefore moves the web-related test for
BeanUtilsRuntimeHints to spring-web.

See gh-30491
2023-06-13 17:12:38 +02:00
Sébastien Deleuze
ccb8db41f0 Merge branch '6.0.x' 2023-06-09 15:21:54 +02:00
Sébastien Deleuze
439bcd6715 Polishing 2023-06-09 15:19:42 +02:00
Sébastien Deleuze
4e33d0c293 Add missing hint for ResourceEditor
Closes gh-30628
2023-06-09 15:19:18 +02:00
Sébastien Deleuze
46fe7f5bea Merge branch '6.0.x' 2023-06-09 14:17:45 +02:00
Sébastien Deleuze
071d6a2a5a Introduce hints for finding hints by conventions
Closes gh-30491
2023-06-09 14:14:54 +02:00
Sam Brannen
75466fee8d Merge branch '6.0.x' 2023-06-04 16:40:23 +02:00
Sam Brannen
4f10f559f7 Suppress warnings 2023-06-04 16:36:20 +02:00
Juergen Hoeller
7150c23e93 Merge branch '6.0.x' 2023-05-26 11:03:48 +02:00
Juergen Hoeller
8b8d147480 Avoid Autowired shortcut resolution for NullBean values
Includes getBean documentation against NullBean values.

Closes gh-30485
2023-05-26 11:03:10 +02:00
Sam Brannen
b5902f4fbf Suppress unused warnings in tests 2023-05-23 15:09:10 +02:00
Andrey Somov
097758baf3 Upgrade to SnakeYAML 2.0
This commit raises the SnakeYAML baseline version to 2.0.
While most Spring applications are not affected by CVE-2022-1471,
upgrading this version should prevent automated tools from raising this
as a security issue. Such tools usually do not understand that YAML
parsing in Spring is about reading configuration, not parsing untrusted
content.

Closes gh-30048
2023-05-22 14:31:27 +02:00
Sam Brannen
5e1a4740d7 Suppress unused warning in test 2023-05-13 18:49:44 +02:00
Stephane Nicoll
c3c5eaf914 Align AOT contributions for injection with the runtime behavior
Bean post processors that use InjectionMetadata checks if a property
value for the element it is about to inject is set and skip it, so
that the property value is used. Previously, the AOT contribution for
the same behavior did not check if a matching property value is set
and therefore override the user-defined value.

This commit introduces an additional method that filters the injected
element list so that only the elements that should be processed are
defined.

Closes gh-30476
2023-05-12 08:49:22 +02:00
Sébastien Deleuze
2c15dcc56b Fix native support for generic array parameters
This commit adds a workaround for oracle/graal#6529
triggered by b374824319.

When the GraalVM fix will have reached a wide enough
audience, it should be removed via gh-30394.

Closes gh-30407
2023-05-05 18:20:08 +02:00
Stephane Nicoll
44b427c3e1 Add AOT support for Qualifiers
This commit handles AutowiredCandidateQualifier instances, rather than
relying on qualifiers being statically defined and meta-annotated with
`@Qualifier`.

Closes gh-30410
2023-05-04 12:17:07 +02:00
Sébastien Deleuze
cefb734763 Restore native support for record beans
After b374824319 related
to gh-29246, `"queryAllDeclaredMethods": true` is now added
on all registered beans.

This legit change triggers oracle/graal#6510. This
commit workarounds this GraalVM bug, and should be
removed once the GraalVM fix has reached a wide enough
audience.

Closes gh-30383
2023-04-28 09:57:22 +02:00
Stephane Nicoll
82e5464972 Avoid extra "__BeanDefinitions" suffix for inner classes
This commit makes AOT class names for bean definitions shorter.
Previously, the "__BeanDefinitions" suffix was applied for all
classes, but it was unnecessary for inner classes as the container
class already has the qualifier.

Closes gh-29846
2023-04-26 16:52:46 +02:00