Commit Graph

2620 Commits

Author SHA1 Message Date
Juergen Hoeller
5dbd3b0bbf Avoid ByteArrayOutputStream for source values without the need to be encoded
Closes gh-24154
2019-12-09 13:56:50 +01:00
Brian Clozel
a21df0cc6d Provide default codecs config callback to custom codecs
As a follow-up of gh-23961, this change provides a way for custom codecs
to align with the default codecs' behavior on common features like
buffer size limits and logging request details.

Closes gh-24119
Co-authored-by: Rossen Stoyanchev <rstoyanchev@pivotal.io>
2019-12-02 23:16:49 +01:00
Brian Clozel
83683a13bb Allow ExchangeStrategies customizations in WebClient
Backport of d4209392 and acfeb77d

Closes gh-23961
2019-12-02 17:10:29 +00:00
Brian Clozel
25554d0b21 Revert "Allow ExchangeStrategies customizations in WebClient"
This reverts commit 43e047c523.
2019-12-02 10:29:24 +01:00
Juergen Hoeller
4f86282b14 Polishing 2019-12-01 01:55:26 +01:00
Brian Clozel
43e047c523 Allow ExchangeStrategies customizations in WebClient
Prior to this commit, developers could configure their WebClient to use
their custom `ExchangeStrategies`, by providing it in the
`WebClient.Builder` chain.
Once created, an `ExchangeStrategies` instance is not mutable, which
makes it hard for further customizations by other components. In the
case of the reported issue, other components would override the default
configuration for the codecs maxInMemorySize.

This commit makes the `ExchangeStrategies` mutable and uses that fact to
further customize them with a new `WebClient.Builder#exchangeStrategies`
`Consumer` variant. This commit is also deprecating those mutating
variants in favor of a new `WebClient.Builder#exchangeStrategies` that
takes a `ExchangeStrategies#Builder` directly and avoids mutation issues
altogether.

Closes gh-24106
2019-11-29 23:35:20 +01:00
Arjen Poutsma
f5b082d3b3 Remove println 2019-11-25 18:27:13 +01:00
Arjen Poutsma
c164759c41 Fix NullPointerException in Jackson2SmileDecoder
Fix uncommon case in Jackson2SmileDecoder, where a null token,
incicating a document separator in streaming mode, is followed by
NOT_AVAILABLE.

Closes gh-24009

(cherry picked from commit 5f3c7ca559)
2019-11-25 16:37:36 +01:00
Rossen Stoyanchev
fbde98f36e Add missing verify() in Jackson2TokenizerTests
Closes gh-24056
2019-11-22 16:39:14 +00:00
Rossen Stoyanchev
529f8ba786 Extra isReady-onWritePossible after last write
Closes gh-24050
2019-11-22 15:58:25 +00:00
Sam Brannen
ffcd83e3a8 Ignore scoped proxy targets for @ControllerAdvice beans
Prior to this commit, methods in a @ControllerAdvice bean were
registered and invoked twice if the advice was a scoped bean (e.g.,
request or session scoped). In other words, both the proxy bean and the
target bean were wrapped in ControllerAdviceBean instances.

This commit fixes this bug by modifying the findAnnotatedBeans() method
in ControllerAdviceBean so that it filters out targets of scoped
proxies.

Closes gh-24017
2019-11-19 15:21:48 +01:00
Rossen Stoyanchev
64db939e4a Javadoc update for content negotiation
Closes gh-23409
2019-11-11 12:08:05 +00:00
Arjen Poutsma
c2e7b6341c Polishing 2019-11-07 15:03:28 +01:00
Arjen Poutsma
e75556bc7b Polishing 2019-11-07 15:02:34 +01:00
Arjen Poutsma
d3d40983d6 Corrupt multipart should not hang SynchronossPartHttpMessageReader
This commit notifies the Synchronoss listener that the buffer stream
has ended.

Closes gh-23768

(cherry picked from commit bf36f49dc5)
2019-11-07 14:48:18 +01:00
Arjen Poutsma
32adf77b22 Corrupt multipart should not hang SynchronossPartHttpMessageReader
This commit notifies the Synchronoss listener that the buffer stream
has ended.

See gh-23768
2019-11-07 09:42:36 +01:00
Sam Brannen
ca3440cb42 Re-enable support for invalid Expires attributes in MockCookie
Changes introduced in commit 9b2087618b
caused a regression for Cookie support in MockHttpServletResponse.
Specifically, an Expires attribute that cannot be parsed using
`ZonedDateTime.parse()` now results in an exception; whereas,
previously an entry such as `Expires=0` was allowed.

This commit fixes this issue in MockCookie by catching and ignoring any
DateTimeException thrown while attempting to parse an Expires attribute.

Closes gh-23911
2019-11-06 22:23:20 +01:00
Rossen Stoyanchev
e0faaa4807 Relax domain name checks in ResponseCookie
Closes gh-23924
2019-11-06 18:05:44 +00:00
Rossen Stoyanchev
e731a0a164 Use int for maxParts instead of long 2019-10-31 14:16:48 +00:00
Brian Clozel
0f2efdbe97 Polish
See gh-23884
2019-10-30 19:58:06 +01:00
Juergen Hoeller
82751141ac Revise concurrent JAXBContext creation towards computeIfAbsent
Closes gh-23879
2019-10-30 16:26:13 +01:00
Sam Brannen
9f43ee3304 Treat InvalidPathException like an IOException in MockServletContext
Prior to this commit, if MockServletContext was configured with a
FileSystemResourceLoader, invocations of the following methods on a
Microsoft Windows operating system resulted in an InvalidPathException
if the supplied path contained a colon (such as "C:\\temp"). This is
inconsistent with the behavior on non-Windows operating systems. In
addition, for comparable errors resulting in an IOException, those
methods (except getRealPath()) return null instead of throwing the
exception.

- getResourcePaths()
- getResource()
- getResourceAsStream()
- getRealPath()

This commit makes handling of InvalidPathException and IOException
consistent for these methods: both exceptions now result in null be
returned by these methods.

Closes gh-23717
2019-10-30 16:19:40 +01:00
Rossen Stoyanchev
614c7b0f8e ResponseStatusException associated headers
A ResponseStatus exception now exposes extra method to return headers
for the response. This is used in ResponseStatusExceptionHandler to
apply the headers to the response.

Closes gh-23741
2019-10-30 12:34:24 +00:00
Juergen Hoeller
f16aa4a9b5 Nullability refinements 2019-10-30 10:30:36 +01:00
Sam Brannen
a3c9e8d4fc Polish contribution
See gh-23769
2019-10-29 13:50:38 +01:00
Vedran Pavic
3814f12b67 Preserve expires attribute in MockCookie
At present, MockCookie doesn't preserve expires attribute. This has a
consequence that a cookie value set using
MockHttpServletResponse#addHeader containing an expires attribute will
not match the cookie value obtained from
MockHttpServletResponse#getHeader, since the expires attribute will get
calculated based on current time.

This commit enhances MockCookie to preserve the expires attribute.

Closes gh-23769
2019-10-29 13:50:38 +01:00
Rossen Stoyanchev
871464811c Limits on input stream in codecs
- Add maxInMemorySize property to Decoder and HttpMessageReader
  implementations that aggregate input to trigger
  DataBufferLimitException when reached.

- For codecs that call DataBufferUtils#join, there is now an overloaded
  variant with a maxInMemorySize extra argument. Internally, a custom
  LimitedDataBufferList is used to count and enforce the limit.

- Jackson2Tokenizer and XmlEventDecoder support those limits per
  streamed JSON object.

- Configurable limits for multipart requests with Synchronoss NIO.

- Centralized maxInMemorySize exposed via CodecConfigurer along with
  ability to plug in an instance of MultipartHttpMessageWrite.

Closes gh-23884
2019-10-29 12:36:36 +00:00
Rossen Stoyanchev
7854f49643 Polishing in HttpWebHandlerAdapter
Closes gh-23780
2019-10-24 20:57:25 +01:00
Rossen Stoyanchev
562c0871e9 Charset argument in RestClientResponseException
See gh-23803
2019-10-24 20:51:16 +01:00
Sam Brannen
7d126d3288 Improve documentation regarding "annotated classes"
See gh-23638
2019-09-26 10:26:36 +02:00
Rossen Stoyanchev
17c423f5af Support for sameSite attribute in WebFlux
Bypass server cookie and write Set-Cookie header directly for Reactor
Netty, and Servlet API which do not provide options.

For Undertow use the sameSite attribute.

Closes gh-23693
2019-09-25 17:16:48 +01:00
Rossen Stoyanchev
4edc7196fb Refine disconnected client handling in WebFlux
If an error looks like a "disconnected client" but the response is not
yet committed then it can't be an I/O error from writing to the server
response. It is most likely as a result of a remote call as part of
request handling.

Not setting the response to 500 in this case results in a 200 response
status despite the error. Even if it was an I/O error from the server
response, setting the status won't impact a failed response.

Closes gh-23319
2019-09-24 11:09:42 +01:00
Brian Clozel
ca2b2f5533 Wait for complete disposal of Reactor Netty resources
Fixes gh-23631
2019-09-17 09:49:05 +02:00
Phillip Webb
d945ae9191 Add blank line between java and javax imports
See gh-23539

Co-authored-by: Sam Brannen <sbrannen@pivotal.io>
2019-09-16 13:41:59 +02:00
Sam Brannen
bd28bb1f56 Add additional tests for HttpHeaders.keySet() operations
See gh-22821
2019-09-16 12:36:05 +02:00
Phillip Webb
aa69703f3b 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-09-16 12:36:05 +02:00
Sam Brannen
a871f609ea Introduce failing tests for HttpHeaders
See gh-22821
2019-09-16 12:28:38 +02:00
Rossen Stoyanchev
23be5dfb0e Handle invalid MediaType in Jetty/Tomcat adapters
See: gh-23553
2019-09-12 20:58:47 +01:00
Rossen Stoyanchev
b7eaab4c5d Handle very early completion notification
On a Servlet container a completion notification may come at any time
even in the UNSUBSCRIBED state, i.e. before the write Publisher has
called onSubscribe.

See: gh-23553
2019-09-12 14:14:11 +01:00
Rossen Stoyanchev
07b0fa132e doFilterNestedErrorDispatch delegates to filter chain
Closes: gh-23596
2019-09-12 13:42:12 +01:00
Sam Brannen
9729b460f1 Retain entry set order in read-only HttpHeaders
Prior to this commit, the entry set of read-only HttpHeaders lost the
original headers' ordering.

The changes in commit ce7278aaf4 introduced a regression in the read-only
HttpHeaders support. Specifically, the implementation of entrySet() in
the internal ReadOnlyHttpHeaders class converted the original entry set
to an immutable, non-ordered set of immutable entries.

This commit fixes this issue by converting the original entry set to an
immutable, ordered set of immutable entries.

Closes gh-23551
2019-08-31 13:10:07 +02:00
Sam Brannen
a496353770 Delete dead code 2019-08-31 11:44:04 +02:00
Arjen Poutsma
d709a69ff1 Remove buffering of encoded parts in MultipartHttpMessageWriter
Closes gh-23518
2019-08-29 16:34:36 +02:00
Rossen Stoyanchev
88e9dcef0c Consistently apply onCompletion/onError handling
Follow-up change in addition to dd22b8fd.

See gh-23096
2019-08-29 09:20:50 +03:00
Rossen Stoyanchev
dd22b8fd39 Fix race condition with onCompletion/onError
Closes gh-23096
2019-08-27 21:43:33 +03:00
Sam Brannen
8189c90741 Allow Set-Cookie header to be overwritten in MockHttpServletResponse
Prior to this commit, there was no way to replace the Set-Cookie header
via MockHttpServletResponse. Specifically, an invocation of setHeader()
for the Set-Cookie header resulted in an additional Set-Cookie header
instead of replacing the existing one, which is in violation of the
contract for javax.servlet.http.HttpServletResponse.setHeader(...).

This commit refactors the internals of MockHttpServletResponse to ensure
that an existing Set-Cookie header is overwritten when set via an
invocation of setHeader(). This commit also verifies the expected
behavior for addHeader() and addCookie() with regard to multiple cookies.

Closes gh-23512
2019-08-27 17:20:38 +02:00
Rossen Stoyanchev
a7bb5ca473 Remove unnecessary iteration over headers
The use of LinkedCaseInsensitiveMap, going back to 3.0, makes it
unnecessary to iterate over keys which can cause
ConcurrentModificationException.

Closes gh-23460
2019-08-21 13:34:17 +03:00
Rossen Stoyanchev
b86c11cc9b Respect existing content-length for HTTP HEAD
Closes gh-23484
2019-08-21 02:28:19 +03:00
Juergen Hoeller
ea4f7d365f Deprecate logger field in HandlerMethodArgumentResolverComposite 2019-07-31 23:48:21 +02:00
Juergen Hoeller
960079e5f5 Retain non-null HttpStatus return value in Client(Http)Response
See gh-23366
2019-07-30 22:26:46 +02:00