Commit Graph

995 Commits

Author SHA1 Message Date
Sam Brannen a5828ca14e Polish JavaDoc for AbstractView in spring-webflux 2019-06-11 16:28:25 +03:00
Sam Brannen 7a87d86b80 Fix documentation for FreeMarker `bind` macro in spring-webflux
See gh-23002
2019-06-10 16:39:54 +03:00
Sam Brannen 2f640fe205 Polish FreeMarker macro support in spring-webflux
See gh-23002
2019-06-10 16:13:20 +03:00
Sam Brannen ac28de0dc1 Polish Javadoc for FreeMarker support 2019-06-10 16:03:16 +03:00
Issam EL-ATIF b58f34d802 Add FreeMarker macro support in spring-webflux
Closes gh-23002
2019-06-09 16:30:05 +03:00
Rossen Stoyanchev 331463739d Merge branch '5.1.x' 2019-06-07 16:26:00 -04:00
Rossen Stoyanchev 9ce5a18d96 Ignore null attributes in AbstractView
Consistent with ConcurrentModel and also with treatment of empty values
from async attributes.

Closes gh-23038
2019-06-07 16:25:47 -04:00
Sebastien Deleuze 098ac0bbb8 Annotate Object#equals parameter with @Nullable
Closes gh-23093
2019-06-06 14:18:30 +02:00
Sebastien Deleuze 23e617160f Use a timeout != 0 in InvocableHandlerMethodTests 2019-06-05 11:52:08 +02:00
Сергей Цыпанов aaeabc3c85 Simplify iteration over maps
Closes gh-23053
2019-05-29 18:00:34 +02:00
Brian Clozel 4b8ce04bdc Mark Spring web config classes as proxyBeanMethods=false
Closes gh-23004
2019-05-28 19:11:35 +02:00
Sam Brannen 141ef9082f Clean up Mockito usage
This commit migrates to the MockitoJUnitRunner where sensible, which
will later allow for an easier migration to Mockito's extension for
JUnit Jupiter.

In addition, this commit deletes unnecessary stubbing for various mocks
and polishes test fixture setup in various test classes.
2019-05-28 13:59:43 +02:00
Phillip Webb 9d74da006c Migrate JUnit 4 assertions to AssertJ
Migrate all existing JUnit 4 `assert...` based assertions to AssertJ
and add a checkstyle rule to ensure they don't return.

See gh-23022
2019-05-23 15:52:49 -07:00
Phillip Webb 95a9d46a87 Migrate Hamcrest assertions to AssertJ
Migrate all existing `assertThat(..., Matcher)` assertions to AssertJ
and add checkstyle rules to ensure they don't return.

See gh-23022
2019-05-23 15:49:59 -07:00
Juergen Hoeller 8a33ef2d14 Merge branch '5.1.x' 2019-05-21 21:06:38 +02:00
Juergen Hoeller 5aa0de7ac8 Upgrade to OkHttp 3.14.2, Joda-Time 2.10.2, OpenPDF 1.2.17, JRuby 9.2.7 2019-05-21 20:47:06 +02:00
Arjen Poutsma 9b3c92e8d2 Add leading slash for path predicate if not present
This commit adds a leading slash for path predicates in both
WebFlux.fn and WebMvc.fn.

Closes gh-22795
2019-05-21 12:09:36 +02:00
Phillip Webb 02850f357f Migrate exception checking tests to use AssertJ
Migrate tests that use `@Test(expectedException=...)` or
`try...fail...catch` to use AssertJ's `assertThatException`
instead.
2019-05-20 10:47:53 -07:00
Rossen Stoyanchev bd910fc62b Fix checkstyle errors 2019-05-16 20:49:49 -04:00
Rossen Stoyanchev 60e4649ff3 Merge branch '5.1.x' 2019-05-16 20:42:09 -04:00
Rossen Stoyanchev da4430e27e BindingResult for resolved async attributes
ViewResolutionResultHandler no longer adds BindingResult objects for
async model attributes. Instead AbstractView adds them later when
those attributes are resolved to concrete values.

Closes gh-22933
2019-05-16 20:41:37 -04:00
Rossen Stoyanchev 172afb510a Polish AbstractView in WebFlux 2019-05-16 14:37:04 -04:00
stsypanov 9ca8681f79 Iteration over a map using EntrySet 2019-05-13 15:38:13 +02:00
Juergen Hoeller cfc4a59135 Merge branch '5.1.x' 2019-05-13 13:40:07 +02:00
Juergen Hoeller daee6f5bd9 Avoid expensive assertions in web resource resolution
Closes gh-22955
2019-05-13 13:28:07 +02:00
Sam Brannen 73dbd06361 Enforces static imports for JUnit 4 assertions and assumptions
This commit configures Checkstyle to enforces static imports for JUnit 4
assertions and assumptions.

See gh-22932
2019-05-12 15:13:07 +02:00
Sam Brannen 724c805211 Discontinue use of JUnit 3 APIs
This commit also ensures that the JSR-330 TCK is executed with the
normal build by adhering to naming conventions for test classes.

See gh-22894
2019-05-12 14:46:55 +02:00
Phillip Webb 798b51f4a3 Migrate to BDD Mockito
Migrate all tests to consistently use BDD Mockito. Also add
checksyle rule to enforce going forwards.
2019-05-08 13:46:13 -07:00
Phillip Webb 816bbee8de Remove '.*' imports from tests
Organize test imports to expand all '.*' static imports into
fully qualified imports.

This update will allow us to use additional checkstyle rules in
the future, and will also help if we migrate fully to AssertJ.
2019-05-08 09:55:09 -07:00
Juergen Hoeller d3b713d5f0 Upgrade to Protobuf 3.7.1 and HtmlUnit 2.35 2019-05-08 17:52:56 +02:00
Sam Brannen 4d1637a9b7 Avoid warnings in RequestMappingHandlerMappingTests 2019-05-08 16:29:31 +02:00
Phil Webb d7320de871 Migrate away from ExpectedException (#22922)
* Add limited checkstyles to test code

Add a limited set of checkstyle rules to the test codebase to improve
code consistency.

* Fix checksyle violations in test code

* Organize imports to fix checkstyle for test code

* Migrate to assertThatExceptionOfType

Migrate aware from ExpectedException rules to AssertJ exception
assertions. Also include a checkstyle rules to ensure that the
the ExpectedException is not accidentally used in the future.

See gh-22894
2019-05-08 16:25:52 +02:00
Arjen Poutsma 2352688ccb MultipartIntegrationTests should not bind to same part multiple times
DefaultMultipartMessageReader does not cache the part contents, so
binding to the same part multiple times does not work.
Rewrote this test to use separate HTTP request instead.
2019-05-08 12:10:20 +02:00
Rossen Stoyanchev 45147c23c1 Empty body checks in ConsumesRequestCondition
Normally consumes matches the "Content-Type" header but what should be done if
there is no content? This commit adds checks for method parameters with
@RequestBody(required=false) and if "false" then also match requests with no content.

Closes gh-22010
2019-05-07 22:03:36 -04:00
Arjen Poutsma 59f6044c09 Add route(RequestPredicate, HandlerFunction) to RouterFunctions builder
Closes gh-22701
2019-05-07 15:06:59 +02:00
Juergen Hoeller 28c5d7b586 Merge branch '5.1.x' 2019-05-07 02:12:11 +02:00
Juergen Hoeller d16beb0e55 Polishing
See gh-22900
2019-05-07 01:40:53 +02:00
Juergen Hoeller f56c70d2f0 Merge branch '5.1.x' 2019-05-07 01:23:16 +02:00
Stephane Maldini fd36d1efe6 Use explicit expectError(class.java) instead of reactor kotlin extension 2019-05-06 16:22:25 -07:00
Juergen Hoeller c841b62bb0 Consistent parameter retrieval across InvocableHandlerMethod variants
See gh-22900
2019-05-07 01:20:05 +02:00
Stephane Maldini 3f8be3416e Use explicit cast to avoid dependency on reactor-core kotlin extension 2019-05-06 16:13:05 -07:00
Juergen Hoeller 4b06d8e511 Merge branch '5.1.x' 2019-05-07 00:59:56 +02:00
Juergen Hoeller 3f85a7db1b Consistent exception naming across InvocableHandlerMethod variants
See gh-22900
2019-05-07 00:48:27 +02:00
Ippei Nawate 47ff92873b Add null check 2019-05-07 00:23:48 +02:00
Sebastien Deleuze e16a134075 Refine WebFlux Kotlin extensions
ServerRequest:
 - awaitPrincipalOrNull is renamed to awaitPrincipal since
 there is no non-nullable variant

ServerResponse:
 - new BodyBuilder.sse() extension
 - BodyBuilder.bodyToServerSentEvents is deprecated in favor
   of sse().body()
 - BodyBuilder.bodyAndAwait(flow: Flow<T>) is renamed to
   bodyFlowAndAwait to avoid shadowing of
   BodyBuilder.bodyAndAwait(body: Any)
 - BodyBuilder.bodyToServerSentEventsAndAwait is removed,
   sse().bodyAndAwait() should be used instead

Closes gh-22899
2019-05-06 11:00:58 +02:00
Sam Brannen 47c39304af Use assertThat from Hamcrest instead of JUnit 4
org.junit.Assert.assertThat() is deprecated as of JUnit 4.13.

See gh-22894
2019-05-05 18:27:38 +02:00
Juergen Hoeller 28039057fd Consistent naming of HandlerMethodArgumentResolver implementations
Includes combined imports of assertion methods and related polishing.

Closes #22889
2019-05-04 18:30:56 +02:00
Juergen Hoeller f0f6af2926 Merge branch '5.1.x' 2019-05-03 18:13:12 +02:00
Juergen Hoeller ea4a174583 Polishing 2019-05-03 18:10:41 +02:00
Juergen Hoeller 3d6476da46 Polishing 2019-05-03 17:29:22 +02:00
Juergen Hoeller a7949ac84a Consistent use of StringUtils.hasLength(String) vs isEmpty(Object) 2019-05-03 17:29:14 +02:00
Juergen Hoeller ec8689d1fc Merge branch '5.1.x' 2019-05-03 14:23:59 +02:00
Juergen Hoeller 84266d71e9 Polishing 2019-05-03 14:08:20 +02:00
Juergen Hoeller eaa9a78d5d Merge branch '5.1.x' 2019-05-03 00:23:57 +02:00
Juergen Hoeller 31c3b8a291 Avoid unguarded String concatenation for debug/trace logging
Closes gh-22874
2019-05-03 00:10:56 +02:00
Rossen Stoyanchev bd8d71be0e canWrite uses actual return value type if known
Closes gh-22803
2019-05-01 16:52:23 -04:00
Rossen Stoyanchev 07c9a0e1f5 Merge branch '5.1.x' 2019-05-01 04:03:21 -04:00
Rossen Stoyanchev b5327ef60f Fix regression in ProducesRequestCondition
Closes gh-22853
2019-05-01 02:59:19 -04:00
Juergen Hoeller 52657b68ea Merge branch '5.1.x' 2019-04-30 18:55:34 +02:00
Juergen Hoeller 90d4e9090c Polishing 2019-04-30 18:43:16 +02:00
Sebastien Deleuze 89454e69c3 Deprecate MediaType.APPLICATION_JSON_UTF8
This commit deprecates MediaType.APPLICATION_JSON_UTF8 and
MediaType.APPLICATION_PROBLEM_JSON_UTF8 in favor of
MediaType.APPLICATION_JSON and MediaType.APPLICATION_PROBLEM_JSON since
UTF-8 encoding is now handled correctly by most browsers
(related bug has been fixed in Chrome since September 2017).

MediaType.APPLICATION_JSON is now used as the default JSON content type.

Closes gh-22788
2019-04-30 16:11:50 +02:00
Juergen Hoeller f8dc8523da Merge branch '5.1.x' 2019-04-26 23:00:40 +02:00
Juergen Hoeller 1f473261a8 Polishing 2019-04-26 22:56:23 +02:00
Juergen Hoeller 55418b256d Merge branch '5.1.x' 2019-04-26 16:56:04 +02:00
Juergen Hoeller e5e2d2d661 Polishing (includes minor performance refinements from master) 2019-04-26 16:51:18 +02:00
Juergen Hoeller ad497c259a Merge branch '5.1.x' 2019-04-25 14:55:04 +02:00
Juergen Hoeller 42fda0ba15 Upgrade to Tomcat 9.0.19, Jetty 9.4.17, Netty 4.1.35, OkHttp 3.14.1
Includes upgrade to Hibernate ORM 5.3.10 (for branch 5.1.x)
2019-04-25 14:32:37 +02:00
Sebastien Deleuze aee2df8919 Improve WebFlux suspending handler method support
Support for suspending handler methods introduced in Spring
Framework 5.2 M1 does not detect types correctly and does not
support suspending handler methods returning Flow which is a
common use case with WebClient.

This commit fixes these issues and adds Coroutines integration
tests.

Closes gh-22820
Closes gh-22827
2019-04-23 11:32:32 +02:00
Rossen Stoyanchev de3238dbea Merge branch '5.1.x' 2019-04-16 21:08:54 -04:00
Rossen Stoyanchev 15b2fb1210 Polish
Replacing a couple of calls to Mono.fromCallable with Mono.just which
seems to work with doOnDiscard except when nested inside Flux.defer.
2019-04-16 20:52:19 -04:00
Rossen Stoyanchev 375090bb7c LeakAwareDataBuffer related fixes
Following on 3ebbfa2191 where the local
refCount was removed in favor of using the internal refCount of the
native data buffer, this commit ensures that LeakAwareDataBufferFactory
uses a PooledDataBufferFactory delegate by default.

There are also fixes for test issues with eager allocation uncovered by
these changes in StringDecoder and ResourceDecoder.
2019-04-16 20:52:19 -04:00
Sebastien Deleuze e84347554e Ignore Kotlin script templating tests
Ignore these tests for the time being since they trigger
a NoClassDefFoundError exception with Kotlin 1.3.30.
2019-04-12 11:17:19 +02:00
Rossen Stoyanchev d1f888a7a9 Empty path mapping behaves consistently
An empty path mapping in an @RequestMapping now consistently matches to
empty paths regardless of whether there are both type and method level,
annotations, or method-level only.

Closes gh-22543
2019-04-09 15:03:43 -04:00
Rossen Stoyanchev f839c1f9cd Remove warning about empty @RequestMapping path
See gh-22543
2019-04-09 15:03:43 -04:00
Sebastien Deleuze cd0b517abf Improve Kotlin documentation 2019-04-09 12:28:00 +02:00
Sam Brannen 85f05023c6 Pull WebFlux getMappingPathPatterns() implementation up in the hierarchy
This commit moves the WebFlux getMappingPathPatterns() implementation
from RequestMappingHandlerMapping to
RequestMappingInfoHandlerMapping so that subclasses of the latter no
longer need to re-implement the method.

See gh-22543
2019-04-09 10:58:04 +02:00
Sam Brannen 55b764bac3 Remove unused import
See gh-22543
2019-04-06 12:14:46 +02:00
Sam Brannen 164ee2a4e1 Polishing
See gh-22543
2019-04-06 11:25:44 +02:00
Sam Brannen 510c0c5ef7 Return Set<PathPattern> from AbstractHandlerMethodMapping.getMappingPathPatterns
This commit revises the signature of getMappingPathPatterns() in
AbstractHandlerMethodMapping to return a set of PathPatterns instead of
a set of Strings.

See gh-22543
2019-04-06 11:18:25 +02:00
Rossen Stoyanchev 02da8486a3 Merge branch '5.1.x' 2019-04-05 21:53:55 -04:00
Rossen Stoyanchev 57558a481a DataBuffer fixes in View implementations
Closes gh-22754
2019-04-05 21:42:12 -04:00
Rossen Stoyanchev 6cabb79f0f Decode resourcePath for classpath locations
Closes gh-22272
2019-04-05 16:23:33 -04:00
Sam Brannen 72027b1746 Log warning if @RequestMapping method has no explicit mapping
Commit c0b52d09f5 introduced support for
throwing an exception if a @RequestMapping handler method in a Spring
MVC controller was mapped to an empty path. This had negative side
effects for applications that intentionally mapped to an empty path,
potentially alongside a mapping to an explicit path for the same
handler method.

This commit addresses this by logging a warning (instead of throwing an
exception) if a @RequestMapping method is mapped only to empty paths.

This commit also introduces the same support for WebFlux-based
@RequestMapping handler methods.

Closes gh-22543
2019-04-05 19:55:22 +02:00
Rossen Stoyanchev e0c2a1c59d Polish
Closes gh-22705
2019-04-04 17:13:57 -04:00
Jeoffrey Haeyaert 9976783639 WebClient uri method with uriTemplate and UriBuilder
See gh-22705
2019-04-04 17:13:57 -04:00
Sebastien Deleuze a8d6ba9965 Add support for Coroutines Flow
Flow is a Kotlin Coroutines related cold asynchronous
stream of the data, that emits from zero to N (where N
can be unbounded) values and completes normally or with
an exception.

It is conceptually the Coroutines equivalent of Flux with
an extension oriented API design, easy custom operator
capabilities and some suspending methods.

This commit leverages Flow <-> Flux interoperability
to support Flow on controller handler method parameters
or return values, and also adds Flow based extensions to
WebFlux.fn. It allows to reach a point when we can consider
Spring Framework officially supports Coroutines even if some
additional work remains to be done like adding
interoperability between Reactor and Coroutines contexts.

Flow is currently an experimental API that is expected to
become final before Spring Framework 5.2 GA.

Close gh-19975
2019-04-04 19:06:32 +02:00
Juergen Hoeller 1741b6dcd9 Merge branch '5.1.x' 2019-04-04 16:12:07 +02:00
Juergen Hoeller 95232d5bf8 Upgrade to Apache HttpClient 4.5.8 and Jetty Reactive HttpClient 1.0.3 2019-04-04 16:10:16 +02:00
Sebastien Deleuze 9217f0b63e Convert CoRouterFunctionDsl indents to tabs 2019-04-04 12:14:27 +02:00
Sebastien Deleuze 2eb631aaad Avoid exposing (Co)RouterFunctionDsl#invoke
WebFlux.fn RouterFunctionDsl#invoke and CoRouterFunctionDsl#invoke
were wrongly exposed on public API and have never been designed to
be used by end users, but rather only invoked from router { } or
coRouter { } builders.

To fix that, avoiding this method being accessible from the DSL and
for the sake of consistency with WebMvc.fn RouterFunctionDsl,
Spring Framework 5.2 turns public fun invoke() method to
an internal fun build() one.

As a consequence RouterFunctionDsl and CoRouterFunctionDsl are not
open anymore, they are expected to be extended via Kotlin
extensions if needed.

Closes gh-22736
2019-04-04 12:14:27 +02:00
Sebastien Deleuze 92d5f6395e Rename awaitPrincipal to awaitPrincipalOrNull
See gh-19975
2019-04-04 12:14:27 +02:00
Rossen Stoyanchev 72119ac076 ProducesRequestCondition caches accepted media types
Closes gh-22644
2019-04-03 14:56:30 -04:00
Rossen Stoyanchev bb9fcad58a RequestCondition implementations minor refactoring
Reduce object creation by pre-computing instances that can be re-used,
and eliminating collection copying and sorting where not needed.

See gh-22644
2019-04-03 14:56:30 -04:00
Brian Clozel 47c8d1de7b Avoid calling other bean methods in web config
This commit changes the main configuration classes for Spring MVC and
Spring WebFlux to not call other bean methods when setting up the web
infrastructure. This allows configuration classes extending
`DelegatingWebFluxConfiguration` and `DelegatingWebMvcConfiguration`
to opt-in the lite-mode, as introduced in gh-22461.
2019-04-03 10:16:41 +02:00
Sebastien Deleuze d2fa5536db Use more efficient Reactor operators
Use handle/flatMapIterable instead of flatMap/flatMapMany
when possible.

Closes gh-22727
2019-04-02 15:49:59 +02:00
Sebastien Deleuze d27b5d0ab6 Improve CORS handling
This commit improves CORS support by:
 - Using CORS processing only for CORS-enabled endpoints
 - Skipping CORS processing for same-origin requests
 - Adding Vary headers for non-CORS requests

It introduces an AbstractHandlerMapping#hasCorsConfigurationSource
method in order to be able to check CORS endpoints efficiently.

Closes gh-22273
Closes gh-22496
2019-04-01 17:42:51 +02:00
Sebastien Deleuze beb491b840 Use Dispatchers.Unconfined for Coroutines
As of Coroutines 1.2.0-alpha, Dispatchers.Unconfined
is a stable API so we can leverage it in order to get
better performances in our Reactive to Coroutines
bridge.

See gh-19975
2019-03-31 10:56:05 +02:00
Sebastien Deleuze 3387d3ec89 Upgrade to Coroutines 1.2.0-alpha
This commit also switches on kotlin-compiler-embeddable to
improve isolation of its dependencies

See gh-19975
2019-03-31 10:55:13 +02:00
Rossen Stoyanchev 8dc535c15c Match declared parameters on produces condition
Closes gh-21670
2019-03-29 17:03:40 -04:00
Rossen Stoyanchev c0be1c5100 Polish 2019-03-29 16:01:22 -04:00