Commit Graph

1014 Commits

Author SHA1 Message Date
Juergen Hoeller 9bd3a535cd Avoid UndeclaredThrowableStrategy with 1.8 bytecode level (CGLIB 3.3)
ClassLoaderAwareUndeclaredThrowableStrategy fails with a VerifyError on recent JDKs after the CGLIB 3.3 upgrade. The alternative is to replace it with a plain ClassLoaderAwareGeneratorStrategy (extracted from CglibSubclassingInstantiationStrategy) and custom UndeclaredThrowableException handling in CglibMethodInvocation.

See gh-23453
2019-08-14 00:14:14 +02:00
Juergen Hoeller 7ac665b18e Polishing 2019-08-01 22:42:33 +02:00
Juergen Hoeller fd86f34057 Merge branch '5.1.x' 2019-08-01 15:27:06 +02:00
Juergen Hoeller 762ea3ea90 Document all remaining public methods on BeanDefinitionParserDelegate
Closes gh-23349
2019-08-01 15:26:11 +02:00
Juergen Hoeller 49593f5399 Revise DependencyDescriptor etc to avoid MethodParameter deprecations
See gh-23385
2019-08-01 14:25:33 +02:00
liym@com fde651a606 Polish getTypeForFactoryBean comment
See gh-23394
2019-08-01 10:17:11 +02:00
Phillip Webb 89d150d398 Resolve factoryBeanClass if necessary
Update `AbstractAutowireCapableBeanFactory.getTypeForFactoryBean` to
use fallback to `determineTargetType` if the factory bean definition
does not have a resolved class.

This is required for the case where a `@Configuration` class is picked
up via component scanning and has a bean type that has not yet been
resolved.

Closes gh-23338
2019-08-01 07:48:12 +01:00
Phillip Webb a6021cc968 Rename SearchStrategy.EXHAUSTIVE to TYPE_HIERARCHY
Rename `SearchStrategy.EXHAUSTIVE` from `MergedAnnotations` to
`SearchStrategy.TYPE_HIERARCHY`

See gh-23378
2019-07-31 13:52:53 +01:00
Juergen Hoeller e6f86c5c75 Nullability refinements and related polishing 2019-07-31 13:45:48 +02:00
Phillip Webb 71a5308c78 Support FactoryBean bean definition attributes
Update `getTypeForFactoryBean` detection so that a bean definition
attribute can be used to supply the result. This commit allows projects
such as Spring Data to provide the result that would be supplied by
`getObjectType` early so that we don't need to initialize the
`FactoryBean` unnecessarily.

Closes gh-23338
2019-07-31 12:22:03 +02:00
Phillip Webb a0e462581f Consider generics for predicting FactoryBean types
Update the `FactoryBean` type prediction logic (primarily in the
`DefaultListableBeanFactory`) so that generic type information is
considered when calling `getBeanNamesForType` on a non-frozen
configuration.

Calling `getBeanNamesForType` with `allowEagerInit` disabled will now
detect `FactoryBean` variants as long as generic type information is
available in either the class or the factory method return type.

Closes gh-23338
2019-07-31 12:22:03 +02:00
Phillip Webb 527876d9a0 Cache AbstractBeanFactory.isFactoryBean results
Add an additional cache to the `RootBeanDefinition` to save
recalculating the result of `isFactoryBean`.

Closes gh-23337
2019-07-31 12:22:03 +02:00
Phillip Webb 95edcb81b5 Retain merged bean definition caches when possible
Update the logic in `AbstractBeanFactory` so that caches from merged
bean definitions remain whenever possible.

Prior to this commit, all merged bean definitions would be completely
removed after bean post processing in case a processor changed the bean
type. It's fairly unlikely these days that the bean type will actually
change, so instead we now compare a subset of the old cached properties
against the newly created definition. Only if key properties have
changed do we now discard the older cached values.

Closes gh-23336
2019-07-31 12:22:03 +02:00
Phillip Webb 2ee1ce61c0 Add missing variants of getBeanNamesForType
Update `ListableBeanFactory` and `BeanFactoryUtils` to add the missing
`getBeanNamesForType` methods that accept a `ResolvableType` rather
than a `Class`.

This completes the work started in 778a01943b.

Closes gh-23335
2019-07-31 12:22:03 +02:00
Juergen Hoeller 8ef557df2f Merge branch '5.1.x' 2019-07-30 17:34:29 +02:00
Juergen Hoeller c4622dbebc Polishing 2019-07-30 16:59:01 +02:00
Juergen Hoeller 8ea3aa512f Merge branch '5.1.x' 2019-07-20 16:35:05 +02:00
Juergen Hoeller 4a09b323b6 Apply getInterfaceMethodIfPossible without SecurityManager as well
Closes gh-23323
2019-07-20 16:11:17 +02:00
Juergen Hoeller daf29118a6 Resolve ApplicationListener against BeanDefinition.getResolvableType()
This covers ApplicationListener generics in factory method return types in particular but also allows for programmatic setTargetType hints.

Closes gh-23178
2019-07-20 15:05:38 +02:00
Sam Brannen 9110a56e11 Merge branch '5.1.x' 2019-07-20 13:33:43 +02:00
zheng.ren01@mljr.com f92b60c08f Only invoke getInterfaceMethodIfPossible() when security manager is used
Prior to this commit, AbstractAutowireCapableBeanFactory's
invokeCustomInitMethod() method invoked
ClassUtils.getInterfaceMethodIfPossible() even if the security manager
was not being used.

This commit ensures that getInterfaceMethodIfPossible() is only invoked
if the security manager is used.

Closes gh-23323
2019-07-20 13:30:57 +02:00
Sam Brannen b774147db4 Polish Javadoc for @Autowired
See gh-23263
2019-07-18 12:07:39 +02:00
Sam Brannen 817f689584 Improve Javadoc for AutowiredAnnotationBeanPostProcessor
See gh-23263
2019-07-18 11:55:18 +02:00
Sam Brannen 56eadff34f Merge branch '5.1.x' 2019-07-17 18:58:08 +02:00
Sam Brannen 74ddf1bee5 Improve documentation for @Autowired constructors
Prior to this commit, there was some ambiguity surrounding semantics
for @Autowired constructors and `required = true`, especially for
multiple @Autowired constructors.

This commit improves the documentation in the Javadoc for @Autowired as
well as in the reference manual.

Closes gh-23263
2019-07-17 18:55:58 +02:00
Rob Winch 8c605dd082 BeanDefinitionParserDelegate uses http://www.springframework.org/schema/
See gh-22839
2019-07-11 18:14:20 +02:00
Сергей Цыпанов 1728bf17fc Avoid unnecessary boxing where primitives can be used
Closes gh-23267
2019-07-10 16:51:18 +02:00
Sam Brannen b8f77e53b5 Polish contribution
See gh-23251
2019-07-10 15:52:41 +02:00
Eric Hettiaratchi 827ec5d5a2 Add unit tests for PropertyAccessorUtils
Closes gh-23251
2019-07-10 15:40:21 +02:00
Sam Brannen 140e1e6532 Polish PropertyAccessorUtilsTests 2019-07-09 17:39:32 +02:00
Sam Brannen fae75cb238 Polish contribution
See gh-23237
2019-07-07 16:29:03 +02:00
Сергей Цыпанов 9f81ffa5ae Use StringJoiner where possible to simplify String joining
Closes gh-23237
2019-07-07 16:19:01 +02:00
Juergen Hoeller a5cb8799fa Merge branch '5.1.x' 2019-07-05 18:22:02 +02:00
Juergen Hoeller 56cc0d02e9 Bean destruction exceptions consistently logged at warn level
Closes gh-23200
2019-07-05 17:07:22 +02:00
Johnny Lim 77aa17fe75 Polish YamlProcessorTests.flattenedMapIsSameAsPropertiesButOrdered()
See gh-23158
2019-06-20 08:34:44 +02:00
Juergen Hoeller 0a77477d32 Merge branch '5.1.x' 2019-06-12 18:16:30 +02:00
Juergen Hoeller fc46abf0b7 Polishing 2019-06-12 18:04:06 +02:00
stsypanov 49873a30c5 Simplify String concatenation 2019-06-12 17:32:35 +02:00
Juergen Hoeller 33b5bc2aae Polishing 2019-06-11 23:50:29 +02:00
Juergen Hoeller a89bfffd8c Merge branch '5.1.x' 2019-06-11 23:16:03 +02:00
Juergen Hoeller 7dc92aa05d Polishing 2019-06-11 20:57:27 +02:00
Juergen Hoeller fd159ad082 Custom init/destroy methods get invoked through interface is possible
Closes gh-22939
2019-06-11 20:56:30 +02:00
Juergen Hoeller 859923b732 Support for fine-grained by-type references and autowired properties
Closes gh-23032
2019-06-11 18:27:46 +02:00
Juergen Hoeller 662541a48e Fix formatting
See gh-23068
2019-06-08 14:26:39 +02:00
陈其苗 ab8e388412 Fix duplicate invoke method of transformedBeanName 2019-06-07 22:48:19 +02:00
Sebastien Deleuze 098ac0bbb8 Annotate Object#equals parameter with @Nullable
Closes gh-23093
2019-06-06 14:18:30 +02:00
Sam Brannen e92ace7301 Merge branch '5.1.x' 2019-06-04 16:22:08 +03:00
Sam Brannen 6eac141160 Restore non-null check for requiredType in BeanFactory methods
Beginning with Spring Framework 5.0, non-null checks for the
requiredType in the following methods were inadvertently removed with
the internal switch to ResolvableType.forRawClass(requiredType).

- BeanFactory.getBean(Class<T>, Object...)
- BeanFactory.getBeanProvider(Class<T>)
- AutowireCapableBeanFactory.resolveNamedBean(Class<T>)

This commit restores those non-null checks.

Closes gh-23045
2019-06-04 16:00:01 +03:00
Sam Brannen 410f204168 Support consistent ordering of string adapting properties
This commit introduces support for consistent ordering of Properties
created by CollectionFactory.createStringAdaptingProperties().

Specifically, the created Properties instance sorts properties
alphanumerically based on their keys.

Closes gh-23081
2019-06-04 14:47:43 +03:00
Sam Brannen 7c9c8220d8 Polish YAML tests 2019-05-28 15:27:11 +02:00