Commit Graph

1940 Commits

Author SHA1 Message Date
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