Commit Graph

1850 Commits

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