Commit Graph

2115 Commits

Author SHA1 Message Date
Sam Brannen 30ebc3b8e2 Remove superfluous AnnotationAttributes#putIfAbsent implementation
Since Java 8, putIfAbsent() is a standard method in java.util.Map. We
therefore no longer need the custom implementation that overrides the
standard implementation in HashMap.
2019-08-06 18:10:13 +02:00
Sam Brannen a092dc055e Check for instanceof Throwable in AnnotationAttributes#assertNotException
Prior to this commit, AnnotationAttributes#assertNotException checked if
the attribute value was an instance of Exception. Although this was
typically sufficient, the scope was not always broad enough -- for
example, if AnnotationReadingVisitorUtils#convertClassValues stored a
Throwable in the map (such as a LinkageError).

This commit fixes this by checking for an instance of Throwable in
AnnotationAttributes#assertNotException.

Closes gh-23424
2019-08-06 18:06:00 +02:00
Sam Brannen 4d6e359e25 Add missing @deprecated tags for ASM-based annotation search classes 2019-08-05 15:30:06 +02:00
Sam Brannen 82f301f42f Polishing 2019-08-05 15:29:04 +02:00
Sam Brannen e6ab6c9fe9 Add missing @deprecated tag for AnnotationMetadataReadingVisitor 2019-08-05 14:39:20 +02:00
Sam Brannen c2f5dabeee Polishing 2019-08-03 00:13:30 +02:00
Sam Brannen 9be327985b Polishing 2019-08-01 23:15:40 +02:00
Sam Brannen ee2041388b Fix typo in Javadoc for MergedAnnotations 2019-08-01 23:15:39 +02:00
Juergen Hoeller aebc485eda MethodParameter.equals properly checks overridden containing class
Closes gh-23352
2019-08-01 14:34:39 +02:00
Juergen Hoeller b67dbe66ef Revise use of ResolvableType in MethodParameter
Includes consistent use of getContainingClass()
2019-08-01 14:25:26 +02:00
Juergen Hoeller 4612544505 Nullability refinements and related polishing 2019-08-01 13:04:46 +02:00
Phillip Webb 1e830f725c Polish firstRunOf javadoc 2019-08-01 08:29:02 +01:00
Phillip Webb 62a3e41473 Deprecate mutable methods of MethodParameter
Deprecate all mutation methods in `MethodParameter` in favor of factory
methods that return a new instance. Existing code that previously relied
on mutation has been updated to use the replacement methods.

Closes gh-23385
2019-08-01 08:05:14 +01:00
Sam Brannen de3c115614 Fix bug in TYPE_HIERARCHY_AND_ENCLOSING_CLASSES strategy
Prior to this commit, the new `TYPE_HIERARCHY_AND_ENCLOSING_CLASSES`
annotation search strategy failed to find annotations on enclosing
classes if the source class was a nested class that itself had no
annotations present.

This commit fixes this by adding special logic to AnnotationsScanner's
isWithoutHierarchy() method to properly support nested classes.

Closes gh-23378
2019-07-31 22:05:46 +02:00
Sam Brannen b03dd47598 Remove duplicate assertion 2019-07-31 22:01:18 +02:00
Phillip Webb 17518ecbbe Add TYPE_HIERARCHY_AND_ENCLOSING_CLASSES strategy
Add a `TYPE_HIERARCHY_AND_ENCLOSING_CLASSES` annotation search strategy
that can be used to search the full type hierarchy as well as any
enclosing classes.

Closes gh-23378
2019-07-31 14:40:40 +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 cca32a56a4 Use shared zero length array constants
Update code that's often called so that zero length array results use
a single shared static constant, rather than a new instance for each
call.

Closes gh-23340
2019-07-31 12:22:03 +02:00
Juergen Hoeller 4f3b89e907 Adapt MethodParameterTests to AssertJ usage on master
See gh-23352
2019-07-30 17:36:02 +02:00
Juergen Hoeller 8ef557df2f Merge branch '5.1.x' 2019-07-30 17:34:29 +02:00
Juergen Hoeller 9a36027ae1 MethodParameter.equals checks nesting level and containing class
Closes gh-23352
2019-07-30 16:58:45 +02:00
Johnny Lim bccc7a62f4 Remove duplicate assertion in matchWithNullPath()
See gh-23382
2019-07-30 09:37:50 +02:00
Sam Brannen a3c7ae2c58 Polish contribution
See gh-23300
2019-07-24 10:13:29 +02:00
stsypanov 1d6e44ab04 Use StringJoiner where possible to simplify String joining
Closes gh-23300
2019-07-24 10:05:38 +02:00
Sebastien Deleuze c006a83584 Upgrade to Coroutines 1.3.0-RC
This commit upgrades Coroutines support to kotlinx.coroutines
1.3.0-RC, leverages the new Coroutines BOM and refine Coroutines
detection to avoid false positives.

Only Coroutines to Mono context interoperability is supported
for now.

CLoses gh-23326
2019-07-21 11:27:43 +02:00
Juergen Hoeller 45136aabd4 Upgrade to Protobuf 3.9 (plus consistent XMLUnit declarations) 2019-07-20 19:06:54 +02:00
Juergen Hoeller 8ea3aa512f Merge branch '5.1.x' 2019-07-20 16:35:05 +02:00
Juergen Hoeller 209c8505e6 Align forRawClassAssignableFromTypeVariable with 5.1 assertion style
See gh-23321
2019-07-20 16:10:49 +02:00
Juergen Hoeller 69d3e89814 Polishing 2019-07-20 15:05:49 +02:00
Phillip Webb be65bef91b Merge branch '5.1.x' 2019-07-20 13:23:37 +01:00
Phillip Webb e5bef10d85 Fix ResolvableType raw class isAssignable checks
Fix `isAssignable` for `ResolvableType.forRawClass` so that it can be
used with types backed by a `TypeVarible`. Prior to this commit the
rawClass value was used, which wouldn't always work.

Closes gh-23321
2019-07-20 13:23:21 +01:00
Arjen Poutsma 090bfa63a1 Add DataBuffer::toString(Charset)
Closes gh-23317
2019-07-19 12:45:24 +02:00
Arjen Poutsma c8704ce473 Introduce DataBufferWrapper
This commit introduces the DataBufferWrapper, a wrapper for DataBuffers,
and uses it in applicable use cases.
2019-07-19 12:45:24 +02:00
Sebastien Deleuze 095fd5bcb3 Use Kotlin BOM
Close gh-23316
2019-07-19 10:43:54 +02:00
Juergen Hoeller 7f33344784 Tracking ASM master
See gh-23156
2019-07-17 22:34:39 +02:00
Juergen Hoeller 94e3210ae7 Fix nullability warnings and javadoc-triggered package cycles 2019-07-17 22:34:07 +02:00
Sam Brannen 7779aa3487 Polish contribution
See gh-23297
2019-07-17 16:53:47 +02:00
Scheidter,Ryan 84200f3141 Treat null path as non-matching pattern in AntPathMatcher
Prior to this commit, a null path supplied to the isPattern(), match(),
and matchStart() methods in AntPathMatcher resulted in a
NullPointerException.

This commit addresses this by treating a `null` path as a non-matching
pattern.

Closes gh-23297
2019-07-17 16:53:47 +02:00
Sam Brannen 699d3f15e8 Simplify LocalVariableTableParameterNameDiscoverer implementation
This commit refactors the internals of
LocalVariableTableParameterNameDiscoverer to use
java.lang.reflect.Executable in order to simplify the implementation.
2019-07-12 12:02:49 +02:00
mfeng-ya 309b328719 Use computeIfAbsent in LocalVariableTableParameterNameDiscoverer
Closes gh-23281
2019-07-12 11:44:10 +02:00
Arjen Poutsma 09572e7b60 Removed DataBufferUtils::split
DataBuffers::split (and underlying algorithm) should not be returning
a Flux<DataBuffer>, but rather a Flux<Flux<DataBuffer>>. In other words,
it should not join all data buffers that come before a delimiter.

Providing an implementation of a such a fully reactive split method
proved to be beyond the scope of this release, so this commit removes
the method altogether.
2019-07-10 16:00:11 +02:00
Arjen Poutsma fdcf09dc2f Copied buffering split from DataBufferUtils to StringDecoder
Due to the imminent removal of DataBufferUtils.split, this commit copies
over the buffering split algortihm from DataBufferUtils, as it is still
sutable for the StringDecoder
2019-07-10 16:00:11 +02:00
Arjen Poutsma ef19a6bf8e Various DataBufferUtils improvements
- Made sure that takeUntilByteCount is usable in multiple subscriptions.
- Added composite Matcher
2019-07-10 16:00:11 +02:00
Sebastien Deleuze ca75c2843a Upgrade to Coroutines 1.3.0-M2 2019-07-09 11:36:26 +02:00
Rossen Stoyanchev c199cb9054 @ConnectMapping for RSocket handling
The new annotation helps to differentiate the handling of connection
level frames (SETUP and METADATA_PUSH) from the 4 stream requests.

Closes gh-23177
2019-07-08 17:04:23 +01: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
Sam Brannen 8f5b2b2231 Merge branch '5.1.x' 2019-07-07 14:49:34 +02:00
Sam Brannen efab6eb55d Ignore empty entries when parsing MediaTypes and MimeTypes
Prior to Spring Framework 5.1.3, MimeTypeUtils.parseMimeTypes() and
MediaType.parseMediaTypes() ignored empty entries, but 5.1.3 introduced
a regression in that an empty entry -- for example, due to a trailing
comma in the list of media types in an HTTP Accept header -- would result
in a "406 Not Acceptable" response status.

This commit fixes this by filtering out empty entries before parsing
them into MimeType and MediaType instances. Empty entries are therefore
effectively ignored.

Fixes gh-23241
2019-07-07 12:39:46 +02:00
Juergen Hoeller d903b9acf5 Compatibility with RxJava 3.0
Closes gh-23208
2019-07-05 16:25:52 +02:00
Juergen Hoeller 6990504d17 Upgrade to ASM 7.2
Closes gh-23156
2019-07-05 16:24:45 +02:00
Rossen Stoyanchev 0d3e5db3ff Compare suffix patterns by length
Closes gh-23125
2019-07-05 07:36:35 +01:00
Phillip Webb b3d56ebf3b Restore StringUtils.hasLength check
Update `MimeTypeUtils` so that the  StringUtils.hasLength check is
performed immediately on the incoming argument, rather than in
`parseMimeTypeInternal`. This restores the `IllegalArgumentException`
rather than the `NullPointerException` which is thrown by the
`ConcurrentHashMap`.

Closes gh-23215
See gh-23211
2019-06-29 22:31:11 -07:00
Brian Clozel 5a308ad5bd Polish MimeTypeUtils LRU cache
This commit improves the cache implementation by skipping the ordering
of most recently used cached keys when the cache is at least half empty.

See gh-23211
2019-06-29 00:17:40 +02:00
Brian Clozel 1b93ea97ac Fix concurrent reads issue in MimeTypeUtils cache
As of gh-22340, `MimeTypeUtils` has a built-in LRU cache implementation
for caching parsed MIME types and avoiding excessive garbage creation at
runtime.
This implementation, when hit with highly concurrent reads on the same
media type (the cache key), can create multiple keys for the same MIME
type string. This duplication leads to the cache filling up and evicting
entries. When the cache fetches a duplicate key, it is then not
associated with a value and the cache can return a `null` value, which
is forbidden by the API contract.

This commit adds another cache check within the write lock: this avoids
creating duplicate entries in the cache and `null` return values.

Fixes gh-23211
2019-06-28 23:43:38 +02:00
Sam Brannen 33fa55e658 Update OrderComparatorTests based on clarified PriorityOrdered semantics
See gh-23187
2019-06-25 11:04:19 +03:00
Sam Brannen b2dc4debde Merge branch '5.1.x' 2019-06-25 10:42:14 +03:00
Sam Brannen dda4dfb44b Clarify semantics of the PriorityOrdered interface
This commit clarifies the semantics of the PriorityOrdered interface
with respect to sorting sets of objects containing both PriorityOrdered
and plain Ordered objects.

Closes gh-23187
2019-06-25 10:40:55 +03:00
Johnny Lim 1afc2be5aa Remove duplicate assertion in AnnotatedElementUtilsTests
Closes gh-23191
2019-06-25 10:00:12 +03:00
Sam Brannen 6cc6abd405 Test status quo for OrderComparator's PriorityOrdered support
See gh-23187
2019-06-24 14:13:46 +03:00
Sam Brannen 4357749a63 Document that OrderComparator honors PriorityOrdered
Prior to this commit, it was not clear that OrderComparator sorts
PriorityOrdered objects with higher priority than plain Ordered objects.
2019-06-24 13:32:54 +03:00
Sam Brannen e3b3481c19 Fix typo in Javadoc 2019-06-24 12:32:41 +03:00
Sam Brannen 4000b244ff Forbid null converters in RestTemplate & HttpMessageConverterExtractor
Prior to this commit, RestTemplate and HttpMessageConverterExtractor did
not validate that the supplied HttpMessageConverter list contained no
null elements, which can lead to a NullPointerException when the
converters are accessed.

This commit improves the user experience by failing immediately if the
supplied HttpMessageConverter list contains a null element. This applies
to constructors for RestTemplate and HttpMessageConverterExtractor as
well as to RestTemplate#setMessageConverters().

Note, however, that RestTemplate#getMessageConverters() returns a mutable
list. Thus, if a user modifies that list so that it contains null values,
that will still lead to a NullPointerException when the converters are
accessed.

This commit also introduces noNullElements() variants for collections in
org.springframework.util.Assert.

Closes gh-23151
2019-06-18 16:13:20 +03:00
Sam Brannen f6a4595cef Polishing 2019-06-17 17:06:37 +03:00
Arjen Poutsma f08656c6cb Add methods to read/write from Path to DataBufferUtils
This commit adds two methods to DataBufferUtils:
- one that reads a Flux<DataBuffer> from a Path
- one that writes a Flux<DataBuffer> to a Path
2019-06-14 14:13:18 +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
Juergen Hoeller 1ccd99ebe7 Polishing 2019-06-12 14:11:39 +02:00
Juergen Hoeller 918ffacdf8 Polishing 2019-06-12 13:29:35 +02:00
Sam Brannen bee4fb0615 Polishing 2019-06-12 14:07:04 +03:00
Sam Brannen 049437e111 Log exception when closing InputStream in AbstractResource
Prior to this commit, exceptions thrown while closing an InputStream in
AbstractResource were silently ignored.

This commit improves diagnostics for such failure scenarios by logging
the exception at DEBUG level.

Closes gh-23116
2019-06-12 14:07:04 +03: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
Phillip Webb 6ac68391c1 Polishing 2019-06-11 12:03:05 -07:00
Phillip Webb b21b27c5ac Add MultiValueMap.addIfAbsent method
Closes gh-23111
2019-06-11 12:03:05 -07:00
Juergen Hoeller 7dc92aa05d Polishing 2019-06-11 20:57:27 +02:00
Juergen Hoeller 4fc9747569 Defensive concurrent access to key set from java.util.Properties
Closes gh-23063
2019-06-11 20:56:57 +02:00
Juergen Hoeller b37390b8fe Restore javax meta-annotation lookup behavior
Closes gh-22957
2019-06-11 20:56:41 +02:00
Sebastien Deleuze 098ac0bbb8 Annotate Object#equals parameter with @Nullable
Closes gh-23093
2019-06-06 14:18:30 +02:00
Sebastien Deleuze 044ea17bf9 Polishing 2019-06-05 12:13:36 +02:00
Sebastien Deleuze 2a19b8f7a5 Refine Coroutines adapter registration activation
Closes gh-23087
2019-06-05 11:52:00 +02:00
Sam Brannen 3b37989774 Apply De Morgan's law for greater clarity of purpose 2019-06-05 10:29:24 +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
Stephane Nicoll 0ef4349c4d Polish "Replace with 'Integer.compare()'"
See gh-23071
2019-06-03 08:31:57 +02:00
Issam El-atif 7ce3792672 Replace with 'Integer.compare()'
See gh-23071
2019-06-03 08:31:19 +02:00
Sam Brannen f66eef1f88 Fix SortedPropertiesTests on JDK 9+ 2019-05-30 10:41:49 +02:00
Sam Brannen 53597f90e9 Remove dependency on StringUtils in SortedProperties
See gh-23018, gh-22383
2019-05-28 18:31:54 +02:00
Sam Brannen c6818fe15b Polishing
See gh-23018
2019-05-28 14:53:24 +02:00
Sam Brannen d495902a9c Polish Javadoc 2019-05-28 12:37:50 +02:00
Sam Brannen c39c4211df Introduce support for sorted Properties
This commit introduces an internal SortedProperties class that is a
specialization of java.util.Properties which sorts properties
alphanumerically based on their keys.

This can be useful when storing a java.util.Properties instance in a
properties file, since it allows such files to be generated in a
repeatable manner with consistent ordering of properties.

Comments in generated properties files can also be optionally omitted.

An instance of SortedProperties can be created via two new
createSortedProperties() factory methods in
org.springframework.core.CollectionFactory.

Closes gh-23018
2019-05-28 12:23:56 +02:00
Phillip Webb 6f2f5bb8c1 Fix annotation exceptions in tight memory
Update `AnnotationTypeMapping` so that instance comparisons are no
longer used when checking attribute methods. Prior to this commit,
in an environment with tightly constrained memory, the method cache
could be cleared and different method instances would be returned.

Closes gh-23010
2019-05-26 14:59:33 -07:00
Phillip Webb e386e53f92 Use less confusing MergedAnnotation method names
Rename some `MergedAnnotation` methods to prevent using parent/child
terminology, specifically:

	`getDepth()` has been renamed `getDistance()`
	`getParent()` has been renamed `getMetaSource()`
	`getTypeHierarchy()` has been renamed `getMetaTypes()`

The parent child naming was particularly confusing given that the
parent/child relationships were inverted from the way that a lot of
users think about meta-annotations. For example, a `@RequestMapping`
having a parent of `@GetMapping` feels odd given that `@GetMapping`
is the thing declaring the meta-annotation relationship.

The new method names are designed to align more closely with existing
terms. For example, `getMetaSource` hints at the relationship with
`isMetaAnnotated` and `getSource`.

Closes gh-22946
2019-05-26 13:15:59 -07:00
Sam Brannen 43119deb08 Polishing 2019-05-26 14:28:09 +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
Rossen Stoyanchev 71396121a7 Merge branch '5.1.x' 2019-05-23 09:57:29 -04:00
Rossen Stoyanchev 99302fd6bd AntPathMatcher#isPattern also checks URI vars
Closes gh-22959
2019-05-23 09:56:11 -04:00
Juergen Hoeller 8a33ef2d14 Merge branch '5.1.x' 2019-05-21 21:06:38 +02:00
Juergen Hoeller 701b7b8a18 Align ReactiveTypeDescriptor accessor methods 2019-05-21 20:46:27 +02:00
Juergen Hoeller ff838fd011 Consistently support CompletionStage in ReactiveAdapterRegistry
Aligns ReactiveAdapterRegistry with MVC/messaging handler methods in terms of recognizing CompletionStage as well as CompletableFuture. Includes consistent use of ReactiveAdapter for reactive transactions.

Closes gh-23011
2019-05-21 19:26:12 +02:00
Juergen Hoeller 171e8f56a3 Merge branch '5.1.x' 2019-05-20 22:27:37 +02:00
Juergen Hoeller 55e601c322 Revise system property replacement tests
See gh-22959
2019-05-20 22:19:03 +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
Arjen Poutsma a30a134c23 Make StringDecoder use DataBufferUtils.split
* Added DataBufferUtils.split variant that takes multiple delimiters
  as argument (instead of 1).
* Use this new split() variant from within StringDecoder, replacing
  its inefficient algorithm with the Knuth-Morris-Pratt algorithm.
2019-05-15 16:07:28 +02:00
Rossen Stoyanchev b1912f6acc Fix checkstyle error 2019-05-15 08:29:41 -04:00
Rossen Stoyanchev 97c2de915a Add RouteMatcher
Closes gh-22642
2019-05-14 21:44:39 -04:00
Sam Brannen 785e8d8116 Polish MergedAnnotation support 2019-05-13 14:11:29 +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 64819bbc1d Clean up warnings 2019-05-10 18:00:29 +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
Phillip Webb 66eb86f055 Delete unused Matchers class
Delete the `Matches` class since it's no longer being used.
2019-05-08 09:52:39 -07:00
Juergen Hoeller fb29088670 Revise LinkedCaseInsensitiveMap's lazy key/value/entry collections
Closes gh-22926
2019-05-08 17:52:28 +02: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
Juergen Hoeller c5b3848357 Nullability refinements and related polishing
Includes fix for typo in visitor class names.

See gh-22909
2019-05-08 00:27:47 +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
Phillip Webb 7fbf3f97cd Add SimpleAnnotationMeta classes and readers
Replace the existing ASM based readers with new implementations that
also support MergedAnnotations. The meta-data classes themselves are
now immutable, and constructed via separate reader classes.

The `SimpleMetadataReader` class has been updated to return the new
classes, however the old ones remain since some of them are public
and might be being used directly.

Closes gh-22884
2019-05-07 23:12:42 +02:00
Phillip Webb 8c2ccfe6a3 Add MergedAnnotations support to meta-data classes
Add `AnnotatedTypeMetaData.getAnnotations()` that can be used to access
annotation details using the `MergedAnnotations` interface.

Where possible, the existing annotation methods have been migrated to
call `getAnnotation()`, rather than needing their own implementation.

The existing ASM based meta-data implementations have not been updated
since they will be deprecated and replaced in a subsequent commit.

See gh-22884
2019-05-07 23:12:42 +02:00
Phillip Webb 30ba80a3c3 Reduce meta-data code duplicate with default methods
Extract and pull-up some common method implementations and make them
default methods of the interface.

See gh-22884
2019-05-07 23:12:42 +02:00
Phillip Webb f592c1f211 Add additional class/method meta-data tests
Add some additional tests to provide more coverage of class and method
meta-data support.

See gh-22884
2019-05-07 23:12:42 +02:00
Phillip Webb 9738e4886c Use ReflectionUtils to get declared methods
Update `StandardAnnotationMetadata` to use `ReflectionUtils` when
obtaining declared methods. This update is primarily so that the common
method cache can be used.

Closes gh-22907
2019-05-07 23:12:42 +02:00
Phillip Webb 1fa5937834 Skip java.lang.annotations when reading metadata
Update `StandardAnnotationMetadata` and `AnnotationMetadataReadingVisitor`
so that `java.lang.annotation` annotations are consistently skipped.

Closes gh-22885
2019-05-07 23:12:42 +02:00
Phillip Webb 8a293f51a4 Don't expose RetentionPolicy.CLASS annotations
Update ASM based metadata readers so that only RetentionPolicy.RUNTIME
annotations are exposed. This aligned behavior with the reflection based
implementation.

Closes gh-22886
2019-05-07 23:12:42 +02:00
Phillip Webb 9d6cf57cb7 Add MergedAnnotations.of method
Add a factory method to `MergedAnnotation` that allows an instance to
be created for an explicit collection of root annotations. This method
will allow ASM based readers to expose a `MergedAnnotation` instance
that has root annotations loaded from bytecode, and meta-annotations
loaded using reflection.

See gh-22884
2019-05-07 23:12:42 +02:00
Phillip Webb daec3531b3 Support String->Class adaptation in MergedAnnotation
Update TypeMappedAnnotation so that Strings can be used to represent
Class attribute values. This will allow ASM annotation readers to
present a `MergedAnnotation` instance without necessarily having the
actual class values on the classpath.

When the underlying value is a String, any calls to
`getValue(name, String.class)` or `asMap(Adapt.CLASS_TO_STRING)` will
simply return the original String. Calls that need the actual Class
result (such as `getClass`) will use `Class.forName` and may throw
a `ClassNotFoundException` at that point.

This commit also allows an empty Object[] to be used to represent
any empty primitive array.

See gh-22884
2019-05-07 23:12:42 +02:00
Phillip Webb e11990e63d Polishing MergedAnnotation code 2019-05-07 23:12:42 +02:00
Phillip Webb d4a761abea Rename some MergedAnnotation `from` methods to `of`
Rename `from` to `of` for the `MergedAnnotation` factory methods that
work with Maps. The previous name was a little confusing, especially
when an annotation source parameter was specified. The new method name
helps to make it clearer when the user is explicitly defining the
attributes of the annotation, as opposed to picking them up from the
source.
2019-05-07 23:12:42 +02:00
Phillip Webb 3b145a5a73 Add MergedAnnotation.getTypeHierarchy method
Add a `getTypeHierarchy()` method to `MergedAnnotation` that can be used
to return the full type hierarchy information. This method is
specifically designed to be used in combination with
`MergedAnnotationPredicates.unique`.

This update also allows us to delete the `parentAndType` method
from `AnnotatedElementUtils`.

Closes gh-22908
2019-05-07 23:12:42 +02:00
Juergen Hoeller ba1c7192c9 Merge branch '5.1.x' 2019-05-07 13:09:44 +02:00
Juergen Hoeller 46e5dd6420 Consistent handling of empty List entries in LinkedMultiValueMap
Closes gh-22912
2019-05-07 13:08:42 +02:00
Juergen Hoeller 7e5aacf8a2
Merge pull request #22421 from olszewskimichal/LinkedMultiValueMap-OutOfBoundException-When-EmptyList
LinkedMultiValueMap.getFirst - check that values is not empty
2019-05-07 12:44:05 +02:00
Juergen Hoeller 8eb9782ca2 Polishing 2019-05-07 12:43:36 +02:00
Arjen Poutsma f747ba282a Add DataBufferUtils.matcher and split
Added two methods to DataBufferUtils:

* matcher(byte[]), which returns a Matcher object that can be used to
  find a delimiter in a data buffer.
* split(Publisher<DataBuffer>, byte[] delimiter), which splits a given
  stream of data buffers around a given delimiter.
2019-05-07 12:14:45 +02:00
Arjen Poutsma b74c09d12e Add DataBuffer.retainedSlice
Add method retainedSlice to the DataBuffer, defaulting to using
DataBufferUtils for retain, but allowing for ByteBuf specific override.
2019-05-07 12:14:45 +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
Juergen Hoeller 9eb095d921 Merge branch '5.1.x' 2019-05-04 12:04:48 +02:00
Juergen Hoeller 293188c797 Consistent non-use of firstIndex 0 in PatternMatchUtils
Closes gh-22837
2019-05-04 12:01:54 +02:00
Juergen Hoeller 9674ce4906 Avoid HashSet/StringBuilder allocation for non-placeholder values
Closes gh-22870
2019-05-04 12:00:22 +02:00
Juergen Hoeller f0f6af2926 Merge branch '5.1.x' 2019-05-03 18:13:12 +02:00
Juergen Hoeller a7949ac84a Consistent use of StringUtils.hasLength(String) vs isEmpty(Object) 2019-05-03 17:29:14 +02:00
Juergen Hoeller eaa9a78d5d Merge branch '5.1.x' 2019-05-03 00:23:57 +02:00
Juergen Hoeller 5b1b1bae37 Consistent use of try-with-resources for local resource closing 2019-05-03 00:11:47 +02:00
Juergen Hoeller 31c3b8a291 Avoid unguarded String concatenation for debug/trace logging
Closes gh-22874
2019-05-03 00:10:56 +02:00
Juergen Hoeller cee7d09e40 Add is*Enabled methods for log level checks to LogAccessor
Closes gh-22862
2019-05-02 11:57:48 +02:00
Juergen Hoeller 52657b68ea Merge branch '5.1.x' 2019-04-30 18:55:34 +02:00
Juergen Hoeller a8f845c944 Upgrade to Checkstyle 8.20 and CGLIB 3.2.11
Includes dependency management plugin 1.0.7.
2019-04-30 18:44:08 +02:00
Juergen Hoeller 3d502d90e2 Add missing nullable declarations
See gh-22821
2019-04-26 23:10:18 +02:00
Juergen Hoeller f8dc8523da Merge branch '5.1.x' 2019-04-26 23:00:40 +02:00
Phillip Webb 87dba5a4df Fix MergedAnnotations javadoc 2019-04-26 13:59:16 -07:00
Juergen Hoeller 1f473261a8 Polishing 2019-04-26 22:56:23 +02:00
Phillip Webb 55ac110f7b Fix LinkedCaseInsensitiveMap collection methods
Ensure that results returned from keySet, entrySet & values are tracked
to remove case insensitive keys from the source map.

Closes gh-22821
2019-04-26 11:17:51 -07:00
Juergen Hoeller 55418b256d Merge branch '5.1.x' 2019-04-26 16:56:04 +02:00
Juergen Hoeller e5e2d2d661 Polishing (includes minor performance refinements from master) 2019-04-26 16:51:18 +02:00
Juergen Hoeller bdd9a557a5 Streamline ReactiveAdapterRegistry.getAdapter usage
Closes gh-22842
2019-04-26 16:49:16 +02:00
Phillip Webb 83cb51aec6 Add MergedAnnotation.getRoot() method
Update `MergedAnnotation` with a `getRoot()` method that allows the
root direct annotation to be retrieved easily.

Closes gh-22818
2019-04-25 14:14:03 -07:00
Christoph Dreis 29d021ae3c Avoid possible memory leak in ResolvableType 2019-04-23 21:07:35 +02:00
Sam Brannen dab90cb7cc Test status quo for MergedAnnotation.getParent()
See gh-22818
2019-04-21 16:32:09 +02:00
Сергей Цыпанов 18af3892dd Make inner classes static where possible
Closes gh-22804
2019-04-17 19:05:24 +02:00
Rossen Stoyanchev 261dcab8ce Merge branch '5.1.x' 2019-04-17 12:34:22 -04:00
Sam Brannen 52b6f9b56d Align Javadoc for Base64Utils.encodeToString() with implementation
Closes gh-22812
2019-04-17 12:33:22 -04:00
Rossen Stoyanchev de3238dbea Merge branch '5.1.x' 2019-04-16 21:08:54 -04:00
Rossen Stoyanchev 375090bb7c LeakAwareDataBuffer related fixes
Following on 3ebbfa2191 where the local
refCount was removed in favor of using the internal refCount of the
native data buffer, this commit ensures that LeakAwareDataBufferFactory
uses a PooledDataBufferFactory delegate by default.

There are also fixes for test issues with eager allocation uncovered by
these changes in StringDecoder and ResourceDecoder.
2019-04-16 20:52:19 -04:00
Juergen Hoeller 07738b9529 Recent fine-tuning from ASM master
See gh-22503
2019-04-12 10:26:42 +02:00
Rossen Stoyanchev 5fc18064f2 Use encode with an Object value where feasible
Closes gh-22782
2019-04-11 19:00:28 -04:00
Rossen Stoyanchev 181482fa15 Add option to encode with an Object value
See gh-22782
2019-04-11 19:00:28 -04:00
Rossen Stoyanchev a912d8de1e Add option to decode from a DataBuffer
See gh-22782
2019-04-11 19:00:28 -04:00
Rossen Stoyanchev 6e7da62085 Switch to Reactor snapshots and remove workaround
Following the 5.2 M1 release we can switch back to Reactor snapshots
and remove the workaround for a fix coming in Reactor Core 3.2.9.
2019-04-10 16:09:28 -04:00
Rossen Stoyanchev bb28477587 Merge branch '5.1.x' 2019-04-10 15:37:02 -04:00
Rossen Stoyanchev bd2c213b47 Remove buffer release used as workaround
The extra buffer release was used as a workaround for a reactor core
issue and should have already been removed as part of
b3bc2d9253.
2019-04-10 15:36:36 -04:00
Rossen Stoyanchev 3ebbfa2191 Fix refCount issue in LeakAwareDataBuffer
LeakAwareDataBuffer was keeping its own refCount rather than checking
through the delegate. This leads to false leak reports in a sequence
where an allocated buffer is retained and then sliced since it is not
aware of the changes to the refCount through the slice.
2019-04-10 15:33:19 -04:00
Rossen Stoyanchev d707d382b4 Merge branch '5.1.x' 2019-04-09 22:38:15 -04:00
Rossen Stoyanchev b11e7feff6 Polish during review of DataBuffer handling 2019-04-09 22:19:05 -04:00
Juergen Hoeller dc14ea86eb Fix regression for nested AnnotationAttributes.annotationType() result
See gh-22738
2019-04-09 09:40:53 +02:00
Juergen Hoeller 4ec9aff01d Polishing 2019-04-08 19:59:06 +02:00
Sam Brannen bd414df944 Remove JMXMP from TestGroup
Due to the changes in a7425c81c0, we no
longer need to execute tests using the JMXMP protocol in PERFORMANCE
builds.

This commit removes the JMXMP constant from the TestGroup enum and
updates affected tests, thereby effectively including such tests in
the standard build from now on.

See gh-22757
2019-04-08 17:05:16 +02:00
Juergen Hoeller fd8fa301a6 Consistent non-exposure of inherited annotations in AnnotationMetadata
Closes gh-22766
2019-04-08 15:59:06 +02:00
Sebastien Deleuze 2e7ed915cd Merge branch '5.1.x' 2019-04-08 15:46:47 +02:00
Juergen Hoeller 43cb1af26a Polishing 2019-04-08 15:33:26 +02:00
Phillip Webb e905f1712e Refine MergedAnnotation.asMap
Add a convenience method that allows a `MergedAnnotation` to be
converted into an `AnnotationAttributes` instance. Also rename
the `MapValues` enum to `Adapt` which generally seems to read
better.

Closes gh-22738
2019-04-05 13:22:18 -07:00
Phillip Webb ef151f578d Polishing 2019-04-05 13:22:18 -07:00
Phillip Webb 1221b0650b Add MissingMergedAnnotation Tests
Add tests for `MissingMergedAnnotation`

See gh-21697
2019-04-05 13:21:46 -07:00
Phillip Webb 8bc74ad18d Delete AnnotationAttributeExtractor
Delete `AnnotationAttributeExtractor` which is package private and
no longer used.

Closes gh-22753
2019-04-05 13:20:47 -07:00
Sam Brannen e4525cf4c1 Modify ByteArrayEncoder so that it works in Eclipse IDE 2019-04-05 19:55:22 +02:00
Sebastien Deleuze a8d6ba9965 Add support for Coroutines Flow
Flow is a Kotlin Coroutines related cold asynchronous
stream of the data, that emits from zero to N (where N
can be unbounded) values and completes normally or with
an exception.

It is conceptually the Coroutines equivalent of Flux with
an extension oriented API design, easy custom operator
capabilities and some suspending methods.

This commit leverages Flow <-> Flux interoperability
to support Flow on controller handler method parameters
or return values, and also adds Flow based extensions to
WebFlux.fn. It allows to reach a point when we can consider
Spring Framework officially supports Coroutines even if some
additional work remains to be done like adding
interoperability between Reactor and Coroutines contexts.

Flow is currently an experimental API that is expected to
become final before Spring Framework 5.2 GA.

Close gh-19975
2019-04-04 19:06:32 +02:00
stsypanov 383f18e214 Use StringJoiner where possible to simplify String joining 2019-04-04 16:11:32 +02:00
Arjen Poutsma b3d3778269 Do not resolve DTDs in Stax Tests 2019-04-04 12:10:10 +02:00
Juergen Hoeller 52f90c303e Rename LogMessage.lazy(Supplier) to LogMessage.of(Supplier)
See gh-22726
2019-04-04 10:39:42 +02:00
Juergen Hoeller 9080ae24f9 First-class support for printf-style format strings in LogMessage
LogMessage is an abstract class now: with internal subclasses for Supplier bindings as well as printf-style format strings with a variable number of arguments (some fixed for efficiency, varargs array as fallback), created through corresponding static factory methods.

Closes gh-22726
2019-04-04 01:52:51 +02:00
Rossen Stoyanchev 88a7a68a71 Revert to Californium-SR6 for M1 release 2019-04-03 19:25:34 -04:00
Rossen Stoyanchev 2c28e4e972 Merge branch '5.1.x' 2019-04-03 16:29:28 -04:00
Rossen Stoyanchev b3bc2d9253 Remove workaround for reactor-core issue 2019-04-03 16:27:02 -04:00
Rossen Stoyanchev 72119ac076 ProducesRequestCondition caches accepted media types
Closes gh-22644
2019-04-03 14:56:30 -04:00
Juergen Hoeller 8f967129b9 Merge branch '5.1.x' 2019-04-03 19:05:42 +02:00
Juergen Hoeller 0cc6a9ef11 Avoid getDeclaredMethod check in ReflectionUtils.isObjectMethod
Closes gh-22730
2019-04-03 18:21:26 +02:00
Sam Brannen 807828b2b7 Polish Javadoc for MergedAnnotation support
See gh-21697
2019-04-03 16:55:34 +02:00
Sam Brannen a4279c5d00 Rename MergedAnnotations.SearchStrategy.SUPER_CLASS to SUPERCLASS
For consistency within the framework, this commit renames the SUPER_CLASS enum constant
to SUPERCLASS.

See gh-21697
2019-04-03 16:44:36 +02:00
Juergen Hoeller e2e91e2196 Switch LogAccessor argument order to have message supplier last
Closes gh-22726
2019-04-02 21:01:56 +02:00
Juergen Hoeller 2e63c66b0d Merge branch '5.1.x' 2019-04-02 20:13:29 +02:00
Juergen Hoeller 0babc1fb64 Polishing 2019-04-02 20:04:07 +02:00