Commit Graph

3050 Commits

Author SHA1 Message Date
Lorenzo Torracchi afae8c3045 Avoid default "Accept" from HttpUrlConnection
Closes gh-23740
2019-11-08 08:43:25 +00:00
Arjen Poutsma 55f3f128c9 Polishing 2019-11-07 14:29:47 +01:00
Arjen Poutsma bf36f49dc5 Corrupt multipart should not hang SynchronossPartHttpMessageReader
This commit notifies the Synchronoss listener that the buffer stream
has ended.

Closes gh-23768
2019-11-07 09:10:07 +01:00
Rossen Stoyanchev 3a241b546f Relax domain name checks in ResponseCookie
Closes gh-23924
2019-11-06 17:54:39 +00:00
Sam Brannen 29599a93a4 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 18:28:28 +01:00
Sam Brannen 92228f0fc0 Test status quo for @RequestHeader UUID conversion support
See gh-23939
2019-11-06 13:49:44 +01:00
AlexeyAnufriev 2d208de145 Clear connection pool for OkHttpClient
Closes gh-23628
2019-11-01 11:44:16 +00:00
Rossen Stoyanchev fd9678833f Use int for maxParts instead of long 2019-10-31 14:13:44 +00:00
Brian Clozel 3b724c72b6 Polish
See gh-23884
2019-10-30 19:57:17 +01:00
Sam Brannen 9f00eb68e9 Clean up warnings 2019-10-30 19:14:58 +01:00
Sam Brannen cef4478b7b 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 15:59:44 +01:00
Juergen Hoeller 19ff7d84ab Polishing 2019-10-30 14:31:46 +01:00
Juergen Hoeller 19107649d2 Revise concurrent JAXBContext creation towards computeIfAbsent
Closes gh-23879
2019-10-30 14:31:34 +01:00
Rossen Stoyanchev 422c26832b Minor follow-up to previous commit
See gh-23741
2019-10-30 12:38:26 +00:00
Rossen Stoyanchev 34cfbe5d26 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:10:45 +00:00
Juergen Hoeller 046380988b Nullability refinements 2019-10-30 00:26:11 +01:00
Rossen Stoyanchev 5abf24e7d7 Expose maxInMemorySize via CodecConfigurer
Centralized maxInMemorySize exposed via CodecConfigurer along with
ability to plug in an instance of MultipartHttpMessageWrite.

Closes gh-23884
2019-10-29 12:33:16 +00:00
Rossen Stoyanchev 00ead7a756 Refine multipart parsing limits
See gh-23884
2019-10-29 12:33:16 +00:00
Brian Clozel ea6f51e9e3 Configurable limits with Synchronoss
See gh-23884
2019-10-29 12:33:16 +00:00
Brian Clozel 69bcdfc17f Polishing 2019-10-29 12:33:16 +00:00
Rossen Stoyanchev 89d053d7f4 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.

See gh-23884
2019-10-29 12:33:16 +00:00
Sam Brannen ce0b012f43 Polish contribution
See gh-23769
2019-10-29 13:27:39 +01:00
Vedran Pavic 9b2087618b 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 12:56:24 +01:00
Rossen Stoyanchev 780eef8d36 Update comment in HttpWebHandlerAdapter
See gh-23780
2019-10-23 17:31:59 +01:00
Johnny Lim 33bf09d513 Polish HttpWebHandlerAdapter.handleUnresolvedError() 2019-10-23 16:57:20 +01:00
Rossen Stoyanchev 2733511ea2 Charset argument in RestClientResponseException
See gh-23764
2019-10-23 16:49:32 +01:00
Rossen Stoyanchev 4932196b87 RestClientResponseException defaults to UTF-8
Closes gh-23764
2019-10-23 16:26:57 +01:00
Sam Brannen 112bbe859c Fix grammar in Javadoc 2019-10-22 18:07:41 +02:00
Brian Clozel a65c6f6884 Fix APPLICATION_PROBLEM_JSON_UTF8 media type value
This commit adds the missing "+json" suffix to the "application/problem"
media type for its deprecated UTF-8 variant.

Fixes gh-23825
2019-10-17 09:36:05 +02:00
Sam Brannen 972337e8f9 Introduce common .gitattributes file
Closes gh-23376
2019-10-02 15:22:39 +02:00
Juergen Hoeller 2861fc65bd Polishing 2019-09-27 10:17:56 +02:00
Sam Brannen f05b4625de Merge branch '5.1.x' 2019-09-26 10:55:55 +02:00
Sam Brannen 7d126d3288 Improve documentation regarding "annotated classes"
See gh-23638
2019-09-26 10:26:36 +02:00
Juergen Hoeller 3616e96792 Upgrade to SLF4J 1.7.28, Groovy 2.5.8, RxJava 2.2.12, Joda-Time 2.10.4, Rome 1.12.2, OkHttp 3.14.3, Apache HttpClient 4.5.10, Apache Johnzon 1.1.13 2019-09-25 22:27:41 +02:00
Rossen Stoyanchev 2995b6f224 Merge branch '5.1.x' 2019-09-25 17:28:24 +01: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 30e1257dda Merge branch '5.1.x' 2019-09-24 13:39:42 +01:00
Sam Brannen 402046f3c7 Polish data buffer allocation tests 2019-09-24 14:24:36 +02: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
Sam Brannen 2572cd0503 Make PathPatternParserTests compatible with JDK 13
Closes gh-23669
2019-09-21 17:33:28 +02:00
Brian Clozel 4cfcc108fe Merge branch '5.1.x' 2019-09-17 09:49:47 +02: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
Sam Brannen 52128fe863 Polish RequestLoggingFilterTests 2019-09-16 11:35:26 +02:00
Napster 33cee066e5 Log HTTP method in logging filters and revise log message format
Closes gh-23567
2019-09-16 11:35:26 +02:00
Sam Brannen cf5cb9484a Add additional tests for HttpHeaders.keySet() operations
See gh-22821
2019-09-15 15:48:37 +02:00
Sam Brannen 957f0fac7a Polishing 2019-09-13 12:55:59 +02:00
Phillip Webb 5d785390eb Add `ClientHttpRequestInitializer` support
Add `ClientHttpRequestInitializer` interface that can be used with any
`HttpAccessor` to initialize each `ClientHttpRequest` before it's used.

This provides a useful alternative to `ClientHttpRequestInterceptor`
when users need to configure things like `HttpHeaders`.

Closes gh-22002
2019-09-12 16:01:46 -07:00
Rossen Stoyanchev 7194261961 Merge branch '5.1.x' 2019-09-12 21:17:00 +01: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 30cff46e7f Prevent improper use of testing framework APIs
Prior to this commit, a lot of work had been done to prevent improper
use of testing Framework APIs throughout the codebase; however, there
were still some loopholes.

This commit addresses these loopholes by introducing additional
Checkstyle rules (and modifying existing rules) to prevent improper use
of testing framework APIs in production code as well as in test code.

- Checkstyle rules for banned imports have been refactored into
  multiple rules specific to JUnit 3, JUnit 4, JUnit Jupiter, and
  TestNG.
- Accidental usage of org.junit.Assume has been switched to
  org.junit.jupiter.api.Assumptions.
- All test classes now reside under org.springframework packages.
- All test classes (including abstract test classes) now conform to the
  `*Tests` naming convention.
  - As an added bonus, tests in the renamed
    ScenariosForSpringSecurityExpressionTests are now included in the
    build.
- Dead JUnit 4 parameterized code has been removed from
  DefaultServerWebExchangeCheckNotModifiedTests.

Closes gh-22962
2019-09-12 11:20:56 +02:00
Sam Brannen 5d5f9aceca Avoid accidental usage of JUnit 4 assumptions
This commit also avoids starting a server if an assumption fails.
2019-09-06 16:03:36 +02:00
Sam Brannen 591995ecc8 Polish and revive disabled tests
This commit revives some previously disabled tests and converts
some usage of @Disabled to @EnabledForTestGroups(...).
2019-09-06 15:57:27 +02:00
Sam Brannen d9e3b8b9a5 Introduce default constructor in TomcatHttpServer 2019-09-05 13:45:38 +02:00
Sam Brannen 73f5d05fd9 Avoid deprecation warning in RandomHandlerIntegrationTests 2019-09-05 13:29:01 +02:00
Phillip Webb deba2ed1b3 Add blank line between java and javax imports
See gh-23539
2019-09-04 22:05:46 -07:00
Rossen Stoyanchev bc81fa520e Reject range starting above resource length
Closes: gh-23576
2019-09-04 18:05:59 +01:00
Brian Clozel 0c7359911a Re-enable StreamingSimpleClientHttpRequestFactoryTests
Since the okhttp3 3.14 downgrade, we don't need to ignore this test
anymore.
2019-09-04 16:02:43 +02:00
Brian Clozel cccd9c8bb0 Fix okhttp3 downgrade 2019-09-04 15:07:17 +02:00
Sam Brannen 00983a1141 Update @Disabled for StreamingSimpleClientHttpRequestFactoryTests.interceptor() 2019-09-04 14:37:37 +02:00
Sam Brannen 4d819128db Fix Javadoc 2019-09-04 14:33:02 +02:00
Sam Brannen 513ce7824f Disable StreamingSimpleClientHttpRequestFactoryTests.interceptor() test 2019-09-03 16:43:48 +02:00
Rossen Stoyanchev d927d31e13 Remove reflection from ContentDispositionTests
Also minor refactoring in decoding in order to tolerate the absence of
a charset and treat as US_ASCII.

See gh-23485
2019-09-03 12:31:13 +01:00
Rossen Stoyanchev c97580035e Polish ContentDispositionTests
Closes gh-23485
2019-09-03 12:31:13 +01:00
Jonathan Bluett-Duncan f084b63286 Fix "array index out of bounds" problem reported by LGTM.com 2019-09-03 12:31:13 +01:00
Sam Brannen 5fd81d2a26 Avoid deprecation warning in AbstractMockWebServerTests
MockResponse.setHeaders(Headers) is now deprecated.
2019-09-03 12:13:09 +02:00
Brian Clozel d4089747b8 Use dependency management in Framework build
Prior to this commit, the Spring Framework build would partially use the
dependency management plugin to import and enforce BOMs.

This commit applies the dependency management plugin to all Java
projects and regroups all version management declaration in the root
`build.gradle` file (versions and exclusions).

Some versions are overridden in specific modules for
backwards-compatibility reasons or extended support.

This commit also adds the Gradle versions plugin that checks for
dependency upgrades in artifact repositories and produces a report; you
can use the following:

    ./gradlew dependencyUpdates
2019-09-02 18:01:09 +02:00
Sebastien Deleuze ca02cc1194 Migrate to AssertJ in Kotlin tests
Closes gh-23475
2019-09-02 15:59:26 +02:00
康智冬 a6f4862f13 Fix typos related to indefinite articles
Closes gh-23555
2019-09-01 15:45:49 +02:00
Sam Brannen 0103fec5de Convert assertions to AssertJ
See gh-23551
2019-08-31 13:13:44 +02:00
Sam Brannen 5a22eafcb4 Merge branch '5.1.x' 2019-08-31 13:10:58 +02: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 67d48ed821 Merge branch '5.1.x' 2019-08-29 17:18:22 +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 117119a88d Merge branch '5.1.x' 2019-08-29 15:13:36 +03: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
Sebastien Deleuze f65cc9a438 Remove explicit disabling of buffer recycling in Jackson codec
Since now https://github.com/FasterXML/jackson-core/issues/476
and https://github.com/FasterXML/jackson-core/issues/479 are fixed.

This commit also raises the minimum version of Jackson to 2.9.7.

Closes gh-23522
2019-08-28 18:47:21 +02:00
Sam Brannen c004ef888c Configure index in @ParameterizedTest display names
This commit prepends "[{index}] " to all custom display names
configured via @ParameterizedTest.

This provides better diagnostics between the "technical names" reported
on the CI server vs. the "display names" reported within a developer's
IDE.

See gh-23451
2019-08-28 17:06:23 +02:00
Rossen Stoyanchev 4e39450dbe Merge branch '5.1.x' 2019-08-27 21:49:51 +03:00
Rossen Stoyanchev dd22b8fd39 Fix race condition with onCompletion/onError
Closes gh-23096
2019-08-27 21:43:33 +03:00
Сергей Цыпанов 6ef75d76cd Simplify String concatenation
Closes gh-23470
2019-08-27 18:22:44 +02:00
Sam Brannen b2ad16aaa7 Merge branch '5.1.x' 2019-08-27 17:37:25 +02: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
Sam Brannen ad6231ad29 Add missing @Override annotations 2019-08-23 13:50:58 +02:00
Sam Brannen 3e2b977d5d Re-enable shadowed, overridden @Test and lifecycle methods
Due to a bug (or "unintentional feature") in JUnit 4, overridden test
and lifecycle methods not annotated with @Test, @Before, @After, etc.
are still executed as test methods and lifecycle methods; however,
JUnit Jupiter does not support that. Thus, prior to this commit, some
overridden test and lifecycle methods were no longer executed after the
migration from JUnit 4 to JUnit Jupiter.

This commit addresses this issue for such known use cases, but there
are likely other such use cases within Spring's test suite.

See gh-23451
2019-08-23 13:50:57 +02:00
Arjen Poutsma 8e4f2c89ff Add headers(Consumer<HttpHeaders>) to RequestEntity and ResponseEntity
Closes gh-23404
2019-08-23 11:23:26 +02:00
Rossen Stoyanchev 274eab7c5d Merge branch '5.1.x' 2019-08-21 13:36:11 +03: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 78abc27432 Remove statusCode state tracking
Closes gh-23490
2019-08-21 11:45:56 +03:00
Rossen Stoyanchev 0a7fdb380f Fix checkstyle error 2019-08-21 11:02:10 +03:00
Rossen Stoyanchev ff6ccd0d04 Adapt tests changed in 5.1.x to master 2019-08-21 10:24:46 +03:00
Rossen Stoyanchev 364c7c459d Merge branch '5.1.x' 2019-08-21 10:21:32 +03:00
Rossen Stoyanchev b86c11cc9b Respect existing content-length for HTTP HEAD
Closes gh-23484
2019-08-21 02:28:19 +03:00
Brian Clozel e9523161f0 Revert "Revert "Refactor Gradle tasks in Spring Framework build""
This reverts commit fb0d618751.
2019-08-20 20:26:43 +02:00