Commit Graph

2115 Commits

Author SHA1 Message Date
Sam Brannen 3299793c8a Polish [Simple]AliasRegistry[Tests] 2020-01-06 11:30:05 +01:00
Qimiao Chen d0c2812dad Optimize SimpleAliasRegistry hasAlias implementation
This commit reduces the number of loops and recursions in
the implementation of SimpleAliasRegistry#hasAlias().

Closes gh-24295
2020-01-06 11:28:24 +01:00
Sam Brannen 081b3d304d Move JavaUtilLoggingConfigurer to spring-core test fixtures
See gh-23550
2020-01-03 14:34:29 +01:00
Sam Brannen 94f8ef08e2 Move common TestPrincipal to spring-core test fixtures
See gh-23550
2020-01-02 16:01:35 +01:00
Sam Brannen 4260c34b47 Rename test fixture package in spring-core
See gh-23550
2020-01-02 16:01:34 +01:00
Sam Brannen 5718bf424b Use Gradle test fixture support for spring-core
See gh-23550
2020-01-02 16:01:34 +01:00
Rossen Stoyanchev 0eacb443b0 Reuse InputStream in ResourceRegionHttpMessageConverter
The converter now tries to keep reading from the same InputStream which
should be possible with ordered and non-overlapping regions. When
necessary the InputStream is re-opened.

Closes gh-24214
2019-12-18 16:22:53 +00:00
Juergen Hoeller 0711e58a5f Un-deprecate PathResource (for NIO Path resolution in createRelative)
Includes aligned createRelative signature and dedicated java.io.File test.

Closes gh-24211
2019-12-16 16:50:04 +01:00
Juergen Hoeller f353bc0c25 ConcurrentReferenceHashMap cache for getInterfaceMethodIfPossible results
Closes gh-24206
2019-12-16 16:49:39 +01:00
Sam Brannen 17edbec035 Polishing 2019-12-13 16:30:03 +01:00
Sam Brannen 49ddf798e0 Polish ClassUtils.resolvePrimitiveClassName()
See gh-24192
2019-12-13 15:47:05 +01:00
Juergen Hoeller fa8f08391f Consistent use of annotation-api dependency instead of tomcat-embed-core 2019-12-12 17:21:41 +01:00
Sam Brannen d757f73902 Handle exceptions in annotation searches again
Prior to Spring Framework 5.2, most annotation search algorithms made
use of AnnotationUtils.handleIntrospectionFailure() to handle exceptions
thrown while attempting to introspect annotation metadata. With the
introduction of the new MergedAnnotation API in Spring Framework 5.2,
this exception handling was accidentally removed.

This commit introduces the use of handleIntrospectionFailure() within
the new MergedAnnotation internals in order to (hopefully) align with
the previous behavior.

Closes gh-24188
2019-12-12 11:29:06 +01:00
Sam Brannen 6e21b19999 Make TYPE_HIERARCHY_AND_ENCLOSING_CLASSES annotation search strategy defensive
Prior to this commit, when searching for annotations using the
TYPE_HIERARCHY_AND_ENCLOSING_CLASSES strategy an exception could be
thrown while attempting to load the enclosing class (e.g., a
NoClassDefFoundError), thereby halting the entire annotation scanning
process.

This commit makes this search strategy defensive by logging exceptions
encountered while processing the enclosing class hierarchy instead of
allowing the exception to halt the entire annotation scanning process.

The exception handling is performed by
AnnotationUtils.handleIntrospectionFailure() which only allows an
AnnotationConfigurationException to propagate.

See gh-24136
2019-12-10 22:38:55 +01:00
Sam Brannen 16ed7e2a19 Only load enclosing class for TYPE_HIERARCHY_AND_ENCLOSING_CLASSES strategy
Prior to this commit, the enclosing class was always eagerly loaded
even if the annotation search strategy was not explicitly
TYPE_HIERARCHY_AND_ENCLOSING_CLASSES.

See gh-24136
2019-12-10 22:08:26 +01:00
Sam Brannen 76bc581528 Polishing 2019-12-10 22:06:22 +01:00
Sam Brannen 2bd821c909 Improve exception for mixed explicit/implicit aliases with @AliasFor
Given the following improperly configured composed @RequestMapping
annotation:

@Retention(RetentionPolicy.RUNTIME)
@RequestMapping
@interface PostApi {

	@AliasFor("value")
	String[] path() default {};

	@AliasFor(annotation = RequestMapping.class, attribute = "path")
	String[] value() default {};
}

Prior to this commit, an attempt to process the above annotation
resulted in an exception similar to the following, which is not
especially helpful to discern the problem.

> Attribute 'value' in annotation [PostApi] must be declared as an
> @AliasFor 'path', not 'path'.

This commit improves the exception message for such scenarios,
resulting in an exception message similar to the following.

> Attribute 'value' in annotation [PostApi] must be declared as an
> @AliasFor attribute 'path' in annotation [PostApi], not attribute
> 'path' in annotation [RequestMapping].

Closes gh-24168
2019-12-10 14:36:11 +01:00
Sam Brannen 4466114cfa Polishing 2019-12-10 14:26:48 +01:00
Juergen Hoeller 2c03246f00 Polishing 2019-12-09 15:58:21 +01:00
Juergen Hoeller 2d2993dffb Cleanup of "varaible" typos in ResolvableTypeTests 2019-12-09 14:03:56 +01:00
Juergen Hoeller a4f75e9c6a Polishing 2019-12-09 13:29:00 +01:00
stsypanov ebbb562cb9 Hoist constant result of SerializableTypeWrapper.unwrap() out of loop 2019-12-09 13:14:10 +01:00
PyvesB e15ccdb35d Polish DataBufferUtils javadoc
See gh-24160
2019-12-08 14:01:55 +01:00
stsypanov 484006ce90 Hoist Class.getName() from String concatenation to dodge an issue related to profile pollution 2019-12-06 17:36:07 +01:00
Phillip Webb 7c84695333 Support variable resolution of wildcard types
Update `ResolvableType` so that variable referenced can be resolved
against wildcard types. Prior to this commit, given a type:

	Map<String, ? extends List<? extends CharSequence>>

Calling `type.getGeneric(1).asCollection().resolveGeneric()` would
return `null`. This was because the `List` variable `E` referenced a
wildcard type which `resolveVariable` did not support.

Closes gh-24145
2019-12-06 13:38:46 +01:00
Sam Brannen a4fa6a7a31 Test status quo for @Inherited annotation support in AnnotationMetadata 2019-12-05 23:30:14 +01:00
Sam Brannen 3b9d1a00b0 Polishing 2019-12-05 22:37:00 +01:00
Juergen Hoeller c2141e2e93 Add @since tags to firstElement methods 2019-12-05 16:36:55 +01:00
Vitalii Rastvorov d503bc2804 Add firstElement to CollectionUtils 2019-12-05 16:26:25 +01:00
Sam Brannen fb13f6f0bc Add integration test for gh-24110 2019-12-03 16:48:30 +01:00
wanxiangming1994 6f15f32be3 Honor default values for implicit aliases in composed annotations
Spring Framework 5.2 introduced a regression for implicit aliases
declared via @AliasFor. Specifically, Spring's merged annotation
algorithms stopped honoring default values for implicit alias pairs if
the composed annotation was used without specifying the aliased
attributes.

This commit fixes this regression.

Closes gh-24110
2019-12-03 16:14:49 +01:00
Sam Brannen 279777b2f3 Polishing 2019-12-02 16:22:40 +01:00
Sam Brannen d9ebc3bbc4 Polish StringArrayPropertyEditor[Tests] 2019-11-29 14:55:18 +01:00
Sam Brannen 7cedffc707 Support @Inherited again in reflection-based AnnotationMetadata
Spring Framework 5.2 introduced a regression in reflection-based
AnnotationMetadata. Specifically, as of 5.2, StandardAnnotationMetadata
no longer found @Inherited annotations from superclasses.

This commit fixes this regression by switching to the INHERITED_ANNOTATIONS
SearchStrategy when creating the MergedAnnotations used within
StandardAnnotationMetadata,

Note, however, that the discrepancy between StandardAnnotationMetadata
and SimpleAnnotationMetadata (i.e., reflection-based vs. ASM-based)
regarding @Inherited support still remains as it was prior to Spring
Framework 5.2.

Closes gh-24077
2019-11-29 00:07:44 +01:00
Sam Brannen 85016aef30 Test status quo for @Inherited annotations in AnnotationMetadata
This commit introduces failing assertions that are currently disabled
via a boolean reproduceGh24077 flag.

Setting that flag to true demonstrates the regression for
StandardAnnotationMetadata and inconsistencies for SimpleAnnotationMetadata.

See gh-24077
2019-11-28 18:45:58 +01:00
Sam Brannen d1f544209e Test status quo for AnnotatedTypeMetadata.getAnnotationAttributes()
See gh-24077
2019-11-28 13:50:35 +01:00
Sébastien Deleuze 712eac2915 Refine Coroutines annotated controller support
This commit refines Coroutines annotated controller support
by considering Kotlin Unit as Java void and using the right
ReactiveAdapter to support all use cases, including suspending
functions that return Flow (usual when using APIs like WebClient).

It also fixes RSocket fire and forget handling and adds related tests
for that use case.

Closes gh-24057
Closes gh-23866
2019-11-22 14:13:17 +01:00
Juergen Hoeller 06b1f31cdd SynthesizedMergedAnnotationInvocationHandler does not pre-load values
Closes gh-24029
2019-11-19 14:54:12 +01:00
Juergen Hoeller 4af6039359 Avoid substring allocation in StringUtils.replace
Closes gh-24023
2019-11-19 14:53:30 +01:00
Juergen Hoeller 830f81210f Revise getElementTypeDescriptor javadoc (no IllegalStateException)
Closes gh-23996
2019-11-14 18:31:32 +01:00
Sébastien Deleuze 029e61f54a Refine MethodParameter#isOptional Kotlin implementation
This commit adds support for Continuation parameter that is now
considered as an optional parameter since it is never provided by
the user.

It also simplifies and optimizes the implementation.

Closes gh-23991
2019-11-14 15:28:06 +01:00
Juergen Hoeller 22211a01ce Polishing 2019-11-13 17:23:23 +01:00
Rossen Stoyanchev f2b9264674 Remove Jetbrains annotations 2019-11-13 14:42:32 +00:00
Sébastien Deleuze 7646895fd4 Support Kotlin synthetic classes in MethodParameter and SpEL
Closes gh-23812
2019-11-13 14:22:53 +01:00
stsypanov f2b3953d76 Use array.clone() instead of manual array creation 2019-11-13 13:53:42 +01:00
Juergen Hoeller 9cc06454aa Restore findAnnotation superclass traversal for java.lang annotations
Closes gh-23929
2019-11-12 11:51:44 +01:00
Arjen Poutsma 789f6fc188 Add @Nullable annotation to decode method taking DataBuffer
Javadoc indicates the returned value can be null.
2019-11-11 16:48:30 +01:00
Andy Wilkinson b5fb28284e Upgrade to Shadow Plugin 5.2.0
Closes gh-23971
2019-11-11 14:56:40 +01:00
Juergen Hoeller 6a48bb7b4d Polishing 2019-11-07 22:08:29 +01:00
stsypanov f5ae3c77c6 Use Method::getParameterCount where possible 2019-11-07 18:00:15 +01:00