Commit Graph

1091 Commits

Author SHA1 Message Date
Juergen Hoeller f26866e4d4 Introduce getType variant with allowFactoryBeanInit flag
Closes gh-23374
2019-09-04 00:06:23 +02:00
Brian Clozel d4089747b8 Use dependency management in Framework build
Prior to this commit, the Spring Framework build would partially use the
dependency management plugin to import and enforce BOMs.

This commit applies the dependency management plugin to all Java
projects and regroups all version management declaration in the root
`build.gradle` file (versions and exclusions).

Some versions are overridden in specific modules for
backwards-compatibility reasons or extended support.

This commit also adds the Gradle versions plugin that checks for
dependency upgrades in artifact repositories and produces a report; you
can use the following:

    ./gradlew dependencyUpdates
2019-09-02 18:01:09 +02:00
Sebastien Deleuze ca02cc1194 Migrate to AssertJ in Kotlin tests
Closes gh-23475
2019-09-02 15:59:26 +02:00
康智冬 a6f4862f13 Fix typos related to indefinite articles
Closes gh-23555
2019-09-01 15:45:49 +02:00
stsypanov 78d56dc61b Use Arrays.copyOf and Arrays.copyOfRange where possible
Closes gh-23393
2019-08-27 19:18:39 +02:00
Sam Brannen 4cd635e9c8 Avoid repeated instantiation of AutowiredArgumentMarker
Prior to this commit, the AutowiredArgumentMarker type was repeatedly
instantiated in ConstructorResolver.

This commit replaces the AutowiredArgumentMarker type with a simple
Object instance.

Closes gh-23469
2019-08-25 22:42:41 +02:00
Sam Brannen ad6231ad29 Add missing @Override annotations 2019-08-23 13:50:58 +02:00
Sam Brannen 0b63db26b7 Reinstate AbstractBeanFactoryTests.typeMismatch() test 2019-08-23 13:50:57 +02:00
Brian Clozel e9523161f0 Revert "Revert "Refactor Gradle tasks in Spring Framework build""
This reverts commit fb0d618751.
2019-08-20 20:26:43 +02:00
Stephane Nicoll fb0d618751 Revert "Refactor Gradle tasks in Spring Framework build"
This reverts commit 1539ba8991.
2019-08-20 20:07:11 +02:00
Brian Clozel 1539ba8991 Refactor Gradle tasks in Spring Framework build
This commit reorganizes tasks and scripts in the build to only apply
them where they're needed. We're considering here 3 "types" of projects
in our build:
* the root project, handling documentation, publishing, etc
* framework modules (a project that's published as a spring artifact)
* internal modules, such as the BOM, our coroutines support and our
integration-tests

With this change, we're strealining the project configuration for all
spring modules and only applying plugins when needed (typically our
kotlin support).

See gh-23282
2019-08-20 18:17:02 +02:00
Sam Brannen 288461a541 Introduce @EnabledForTestGroups in Spring's test suite
Closes gh-23476
2019-08-17 14:47:24 +02:00
Sam Brannen 979508a7f3 Remove JUnit 4 dependency from all modules except spring-test
This commit removes the JUnit 4 dependency from all modules except
spring-test which provides explicit JUnit 4 support.

This commit also includes the following.

- migration from JUnit 4 assertions to JUnit Jupiter assertions in all
  Kotlin tests
- migration from JUnit 4 assumptions in Spring's TestGroup support to
  JUnit Jupiter assumptions, based on org.opentest4j.TestAbortedException
- introduction of a new TestGroups utility class than can be used from
  existing JUnit 4 tests in the spring-test module in order to perform
  assumptions using JUnit 4's Assume class

See gh-23451
2019-08-17 11:37:21 +02:00
Sam Brannen 3f3e41923f Migrate rest of test suite from JUnit 4 to JUnit Jupiter
This commit migrates the rest of Spring's test suite to JUnit Jupiter,
except spring-test which will be migrated in a separate commit.

See gh-23451
2019-08-17 11:36:58 +02:00
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
Sebastien Deleuze 095fd5bcb3 Use Kotlin BOM
Close gh-23316
2019-07-19 10:43:54 +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
Phillip Webb 9d74da006c Migrate JUnit 4 assertions to AssertJ
Migrate all existing JUnit 4 `assert...` based assertions to AssertJ
and add a checkstyle rule to ensure they don't return.

See gh-23022
2019-05-23 15:52:49 -07:00
Phillip Webb 95a9d46a87 Migrate Hamcrest assertions to AssertJ
Migrate all existing `assertThat(..., Matcher)` assertions to AssertJ
and add checkstyle rules to ensure they don't return.

See gh-23022
2019-05-23 15:49:59 -07:00
Juergen Hoeller 75d751d968 Polishing 2019-05-20 22:19:11 +02:00
stsypanov 6f07a504b8 A couple of trivial simplifications 2019-05-20 21:41:15 +02:00
Phillip Webb 02850f357f Migrate exception checking tests to use AssertJ
Migrate tests that use `@Test(expectedException=...)` or
`try...fail...catch` to use AssertJ's `assertThatException`
instead.
2019-05-20 10:47:53 -07:00
Juergen Hoeller a363fed209 Merge branch '5.1.x' 2019-05-20 17:21:07 +02:00
Juergen Hoeller 7edf8aca8e Drop DefaultNamespaceHandlerResolverTests.testResolveInvalidHandler
Closes gh-22994
2019-05-20 17:19:18 +02:00
Juergen Hoeller 9755b59197 Merge branch '5.1.x' 2019-05-13 18:05:07 +02:00
Juergen Hoeller 4af94dfc5d Clarify AbstractBeanDefinition.getBeanClass() return semantics
Closes gh-22960
2019-05-13 18:03:12 +02:00
Sam Brannen deecab6311 Use assertThat from Hamcrest instead of JUnit 4
org.junit.Assert.assertThat() is deprecated as of JUnit 4.13.

See gh-22894
2019-05-12 14:46:55 +02:00
Sam Brannen 9e1ed6c771 Fix build on JDK 9+ 2019-05-12 13:46:14 +02:00
Sam Brannen 6ef7d7124e Clean up warnings 2019-05-11 15:51:06 +02:00
Phillip Webb 798b51f4a3 Migrate to BDD Mockito
Migrate all tests to consistently use BDD Mockito. Also add
checksyle rule to enforce going forwards.
2019-05-08 13:46:13 -07:00
Phillip Webb 816bbee8de Remove '.*' imports from tests
Organize test imports to expand all '.*' static imports into
fully qualified imports.

This update will allow us to use additional checkstyle rules in
the future, and will also help if we migrate fully to AssertJ.
2019-05-08 09:55:09 -07:00
Phil Webb d7320de871 Migrate away from ExpectedException (#22922)
* Add limited checkstyles to test code

Add a limited set of checkstyle rules to the test codebase to improve
code consistency.

* Fix checksyle violations in test code

* Organize imports to fix checkstyle for test code

* Migrate to assertThatExceptionOfType

Migrate aware from ExpectedException rules to AssertJ exception
assertions. Also include a checkstyle rules to ensure that the
the ExpectedException is not accidentally used in the future.

See gh-22894
2019-05-08 16:25:52 +02:00
Phillip Webb 7031964e49 Deprecate StandardMetadata constructors
Deprecate the public `StandardMetadata` constructors to make it clearer
that these classes should not be instantiated directly. A new
`AnnotationMetadata.introspect` factory method has been added which
can now be used to obtain instances.

This change will allow use to make the constructors package private
and drop the `nestedAnnotationsAsMap` parameter in a future release.

Closes gh-22906
2019-05-07 23:12:42 +02:00
Sam Brannen ccb01e663a Merge branch '5.1.x' 2019-05-07 13:03:45 +02:00
Sam Brannen 4aaec942c4 Introduce HTTPS mappings in spring.schemas files
Closes gh-22903
2019-05-07 12:56:42 +02:00
Juergen Hoeller 4b06d8e511 Merge branch '5.1.x' 2019-05-07 00:59:56 +02:00
Juergen Hoeller 379d81da74 Consistent thread-safe handling of manualSingletonNames Set
Closes gh-22896
2019-05-07 00:47:59 +02:00
Sam Brannen d616e10dca Use assertThat from Hamcrest instead of JUnit 4
org.junit.Assert.assertThat() is deprecated as of JUnit 4.13.

See gh-22894
2019-05-05 19:26:04 +02:00
Sam Brannen c79fdfb668 Use assertThat from Hamcrest instead of JUnit 4
org.junit.Assert.assertThat() is deprecated as of JUnit 4.13.

See gh-22894
2019-05-05 18:09:11 +02:00
Juergen Hoeller ce9162065c Merge branch '5.1.x' 2019-05-02 17:52:12 +02:00
Juergen Hoeller 8158b6fd86 Update postProcessBeforeInstantiation comment on factory methods
Closes gh-22867
2019-05-02 17:28:11 +02:00
Yanming Zhou 900abfce47 Temporal should be simple value type like Date 2019-04-23 12:55:18 +02:00
水木今山 574dffb60b Some trivial optimization in method populateBean() (#22792)
Optimize the number of getResolvedAutowireMode() method calls
2019-04-23 12:48:21 +02:00
stsypanov 604361ee1f Use concatenation instead of torn StringBuilder::append chain 2019-04-09 13:23:22 +02:00
Sam Brannen 80ad60e91b Fix Javadoc for @Value 2019-04-09 11:30:59 +02:00
Sam Brannen df15b64e86 Document @Autowired support on parameters
Closes gh-21118
2019-04-04 18:31:04 +02:00
Sam Brannen e1080f8b5f Polish Javadoc for @Autowired 2019-04-04 18:18:35 +02:00
Juergen Hoeller d39e3cc0ba Merge branch '5.1.x' 2019-04-03 14:43:22 +02:00
Juergen Hoeller 9ea02c6dfa Revised javadoc 2019-04-03 14:34:11 +02:00
Juergen Hoeller abbe61b9f8 Consistent internal use of getMergedLocalBeanDefinition 2019-04-03 14:33:57 +02:00
Juergen Hoeller e0fe32af05 Detect factory method annotations in getBeanNamesForAnnotation and co
As of 5.2, ListableBeanFactory.findAnnotationOnBean and its retrieval companions getBeanNamesForAnnotation and getBeansWithAnnotation detect annotations on @Bean methods as well.

Closes gh-22541
2019-04-03 13:07:47 +02:00
Juergen Hoeller dee88d931a Common constant for DefaultBeanNameGenerator as well
Closes gh-22591
2019-04-03 12:58:13 +02:00