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
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
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
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
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
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
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
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
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
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
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
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