Prior to this commit, repeated calls to `DataBuffer.write(CharSequence,
Charset)` would not write the given chars to the expected position in
the original buffer.
This commit fixes that by writing to the `outBuffer.position()`, offset
by the current `DataBuffer.writePosition()`.
Fixes gh-22484
Prior to this commit, calls to `MimeType` and `MediaType` would create a
significant amount of garbage:
* during startup time, in the static sections of `MimeType` and
`MediaType` when creating well-known types
* at runtime, when parsing media types for content negotiation or
writing known media types as strings in HTTP response headers
This commit does the following:
* Avoid parsing the well-known types and use regular constructors
instead
* Cache types in a simple LRU cache once they've been parsed, since an
application is likely to deal with a limited set of types
* Avoid using `java.util.stream.Stream` in hot code paths
Benchmarks show that a complete revision of the `MimeTypeUtils` parser
is not required, since the LRU cache is enough there.
Closes gh-22340
Prior to this commit, profiling sessions would show that using
`java.util.stream.Stream` in some hot code paths creates significant
garbage.
Where streams aren't really required, this commit turns those snippets
into imperative logic because those are likely to be called once or
multiple times per request.
Closes gh-22341
Prior to this commit, `DataBuffer.write` would throw an
`IllegalStateException` when called with an empty `String`, since the
`CharsetEncoder` would be flushed on an incorrent state.
This commit skips entirely the encoding phase for empty `String`.
Fixes#22262
This allows for proper nested type conversion in @Value Optional fields analogous to method parameters, through a new TypeDescriptor-based method in the TypeConverter SPI. As an additional and less involved measure that is worth backporting, DefaultListableBeanFactory defensively checks for pre-converted Optional wrappers.
Issue: SPR-17607
Aalto's InputFactoryImpl already disables loading of external entities
by default (property "javax.xml.stream.isSupportingExternalEntities").
This commit goes further by applying the same defensive measures as we
do elsewhere for XMLInputFactory, which disables DTD completely.
Arguably there is no good reason to enable that by default in WebFlux.
Typically a straight up equals as well as Collections#contains
checks for MediaType.ALL is susceptible to the presence of
media type parameters.
This commits adds equalsTypeAndSubtype as well as an
isPresentIn(Collection<MimeType>) methods to MimeType to faciliate
with checks for MediaType.ALL.
Issue: SPR-17550
Prior to this commit, one could write a `CharSequence` to an existing
`DataBuffer` instance by turning it into a byte array or `ByteBuffer`
first. This had the following disadvantages:
1. Memory allocation was not efficient (not leveraging pooled memory
when available)
2. Dealing with `CharsetEncoder` is not always easy
3. `DataBuffer` implementations, like `NettyDataBuffer` can use
optimized implementations in some cases
This commit adds a new `DataBuffer#write(CharSequence, Charset)` method
for those cases and also an `ensureCapacity` method useful for checking
that the current buffer has enough capacity to write to it..
Issue: SPR-17558