Commit Graph

3259 Commits

Author SHA1 Message Date
Sam Brannen
bcd8896689 Polish contribution
See gh-25200
2021-05-10 12:50:13 +02:00
Vlad Kisel
53b8d73078 Support single-value request param resolution for data class constructors
Prior to this commit, when Web MVC attempted to resolve a constructor
argument for a data class constructor with @ModelAttribute binding,
ModelAttributeMethodProcessor failed to unwrap the array returned by
WebRequest.getParameter(String).

According to the Javadoc for WebRequest.getParameter(String), "a
single-value parameter will be exposed as an array with a single
element."

This commit fixes this issue by extracting the single value from such
an array and using that as the constructor argument (potentially
converted by the WebDataBinder).

Closes gh-25200
2021-05-10 12:47:47 +02:00
Sam Brannen
08663d4792 Polish Javadoc 2021-05-03 18:58:12 +02:00
Juergen Hoeller
19474e2d03 Nullability refinements
(cherry picked from commit f31933e67e)
2021-04-13 12:32:16 +02:00
Juergen Hoeller
428dbc43da Add missing nullable annotation to ResponseEntity ok convenience method
Closes gh-26613
2021-02-26 17:42:05 +01:00
Sam Brannen
33add3350b Sync changes in MockHttpServletResponse test fixture
See gh-26558
2021-02-17 14:51:09 +01:00
Rossen Stoyanchev
6051f4ecbd Handle forwarded header parse issues
Closes gh-26459
2021-01-29 20:48:51 +00:00
Sam Brannen
94ac2e4de7 Fix UriComponentsBuilder examples in ref docs
Closes gh-26453
2021-01-27 15:17:32 +01:00
Juergen Hoeller
7325a863bb Consistent declarations and assertions in MockMultipartFile
See gh-26261

(cherry picked from commit fbd2ffdd23)
2020-12-17 10:50:47 +01:00
Brian Clozel
fe26b7d3fd Fix NPE when calling NettyHeadersAdapter.add()
Prior to this commit, the `NettyHeadersAdapter` would directly delegate
the `add()` and `set()` calls to the adapted
`io.netty.handler.codec.http.HttpHeaders`. This implementation rejects
`null` values with exceptions.

This commit aligns the behavior here with other implementations, by not
rejecting null values but simply ignoring them.

Fixes gh-26277
(cherry-picked from commit 83c19cd60e)
2020-12-15 13:36:03 +01:00
Rossen Stoyanchev
33476a2eae Backport fixes for discarding data buffers
Closes gh-26232
2020-12-08 22:00:28 +00:00
Brian Clozel
a8091b916b Avoid closing Jackson JsonGenerator for error cases
Prior to this commit, a change introduced in gh-25910 would close the
`JsonGenerator` after it's been used for JSON serialization. This would
not only close it and recycle resources, but also flush the underlyning
buffer to the output.
In a case where the JSON serialization process would throw an exception,
the buffer would be still flushed to the response output. Before the
change introduced in gh-25910, the response body could be still empty at
that point and error handling could write an error body instead.

This commits only closes the `JsonGenerator` when serialization has been
successful.

Note that we're changing this in the spirit of backwards compatibility
in the 5.2.x line, but change this won't be merged forward on the 5.3.x
line, for several reasons:

* this behavior is not consistent. If the JSON output exceeds a
certain size, or if Jackson has been configured to flush after each
write, the response output might still contain an incomplete JSON
payload (just like before this change)

* this behavior is not consistent with the WebFlux and Messaging codecs,
which are flushing or closing the generator

* not closing the generator for error cases prevents resources from
being recycled as expected by Jackson

Fixes gh-26246
2020-12-08 20:50:26 +01:00
Rossen Stoyanchev
736af46fc0 ContentCachingResponseWrapper skips contentLength for chunked responses
Closes gh-26182
2020-12-01 17:50:07 +00:00
Сергей Цыпанов
b929edb221 Remove unused package-private class o.s.w.u.p.SubSequence
(cherry picked from commit 42216b77df)
2020-11-26 15:38:14 +01:00
Juergen Hoeller
e238c8a87c Declare resolvedCharset as transient (restoring serializability)
Closes gh-26127
2020-11-20 18:57:30 +01:00
Rossen Stoyanchev
37bda566eb Allow "*" for Access-Control-Expose-Headers
Closes gh-26113
2020-11-19 09:48:41 +00:00
Rossen Stoyanchev
db2786264b UrlPathHelper.removeJsessionid correctly appends remainder
Closes gh-26079
2020-11-16 11:18:20 +00:00
Juergen Hoeller
e9416b369e Polishing 2020-11-09 18:23:45 +01:00
Juergen Hoeller
7881329cf7 Polishing 2020-11-05 18:18:38 +01:00
Rossen Stoyanchev
8c3cdc6118 Remove unused import 2020-10-30 18:43:19 +00:00
Rossen Stoyanchev
01827fd8d2 Ensure response not closed by MappingJackson2HttpMessageConverter
Closes gh-25987
2020-10-30 18:42:11 +00:00
Sam Brannen
449377908f Fix JUnit 4 to AssertJ migration bugs
The migration from JUnit 4 assertions to AssertJ assertions resulted in
several unnecessary casts from int to long that actually cause
assertions to pass when they should otherwise fail.

This commit fixes all such bugs for the pattern `.isNotEqualTo((long)`.
2020-10-26 14:53:09 +01:00
Brian Clozel
7bee3d1574 Optimize Jackson resource management in codecs
Prior to this commit, references to `JsonGenerator` and
`ByteArrayBuilder` were not closed/released within codecs calls.
This prevents Jackson from reusing more efficiently shared memory
resources.

This commit properly closes/releases Jackson resources in Spring MVC,
Spring WebFlux and Spring Messaging codecs.
A benchmark on WebFlux codecs (in both single value/streaming mode)
shows significant throughput and allocation improvements for small
payloads.

Closes gh-25910
2020-10-20 15:36:23 +02:00
Rossen Stoyanchev
431ec906c4 Ensure buffers released in HttpHeadResponseDecorator
See gh-25908
2020-10-13 23:38:59 +01:00
Rossen Stoyanchev
1d96f6a266 HttpHeaderResponseDecorator checks for "Transfer-Encoding"
This commit extends the fix from b86c11cc9b
by checking for both existing Content-Length and Transfer-Encoding.

Closes gh-25908
2020-10-13 23:06:06 +01:00
Juergen Hoeller
7b6293fa05 Avoid outdated Jackson API in tests
See gh-25907
2020-10-13 11:13:54 +02:00
Juergen Hoeller
06b6a4be16 Polishing 2020-10-13 01:39:12 +02:00
Juergen Hoeller
f3f19504c6 Polishing 2020-10-13 00:21:07 +02:00
Juergen Hoeller
e176c4e799 Polishing 2020-10-12 19:40:50 +02:00
Juergen Hoeller
66a67ec807 Polishing 2020-10-12 18:26:14 +02:00
Juergen Hoeller
69c330d905 Attempt fallback Part resolution even without StandardMultipartHttpServletRequest
Closes gh-25829
2020-10-12 18:25:55 +02:00
Rossen Stoyanchev
eb11c6fa23 Reinstate removal of jsessionid from lookup path
Closes gh-25864
2020-10-07 11:31:52 +01:00
Juergen Hoeller
f83bb7183e Polishing 2020-10-06 15:31:34 +02:00
Rossen Stoyanchev
2533ba5253 Use Mono.fromDirect for Jetty ReactiveRespnose
Closes gh-25849
2020-10-02 13:43:42 +01:00
Rossen Stoyanchev
e44b08f1fc Minor refactoring in JettyClientHttpConnector
See gh-25849
2020-10-02 13:32:00 +01:00
Juergen Hoeller
6e4fcb69f0 Polishing 2020-09-25 11:26:01 +02:00
Juergen Hoeller
c1617d3c52 Polishing 2020-09-18 18:15:36 +02:00
Juergen Hoeller
f010368a66 Polishing 2020-09-15 10:08:01 +02:00
Juergen Hoeller
3c84863271 Polishing 2020-09-14 22:18:30 +02:00
Juergen Hoeller
c2f6a98c90 Lenient handling of empty Content-Disposition filename
Closes gh-25769
2020-09-14 22:16:12 +02:00
Arjen Poutsma
07d2c08f48 Do not tokenize Forward header value
This commit remove the tokenization previously used in
UriComponentsBuilder#adaptFromForwardedHeaders, in order to support
Forwarded headers that have multiple, comma-separated 'for' elements.

Closes gh-25737
2020-09-09 16:31:24 +02:00
Juergen Hoeller
ae1d15c8f4 Declare protected getCharset method as non-static
See gh-25509
2020-09-08 12:22:25 +02:00
Rossen Stoyanchev
b6ff12d2f5 Expose protected method in AbstractJackson2HttpMessageConverter
Closes gh-25509
2020-09-07 21:27:52 +01:00
Rossen Stoyanchev
b1d84067cd UriComponentsBuilder Javadoc update
Closes gh-25604
2020-09-07 21:27:52 +01:00
Rossen Stoyanchev
899761f0a8 Avoid unnecessary parsing of path params
See gh-25690
2020-09-07 21:27:52 +01:00
Rossen Stoyanchev
f88759c3c9 Shared read-only instances of UrlPathHelper
UrlPathHelper is often created and used without customizations or with
the same customizations. This commit introduces re-usable, instances.
Effectively a backport of commit 23233c.

See gh-25690
2020-09-07 21:27:52 +01:00
Juergen Hoeller
141470ff58 Explicit nullability declarations for getTarget() implementations 2020-09-01 23:26:22 +02:00
Juergen Hoeller
d62202f464 Polishing 2020-09-01 10:27:36 +02:00
Juergen Hoeller
bcdc2503fa Avoid repeated calls to getPathWithinApplication from getLookupPathForRequest
Closes gh-25669
2020-09-01 10:27:04 +02:00
Juergen Hoeller
6d9d4157ef Specifically detect Joda-Time 2.x
Closes gh-25655
2020-08-28 19:57:51 +02:00