Commit Graph

1919 Commits

Author SHA1 Message Date
Juergen Hoeller 0d3fa4eb70 Upgrade to Apache Johnzon 1.1.4 2017-10-10 20:35:47 +02:00
Juergen Hoeller cc6e6490d2 Polishing 2017-10-09 13:59:29 +02:00
Rossen Stoyanchev 48c41049b1 Correct package for MockServerWebExchange
Discovered late, but not too late. MockServerWebExchange is now in the
proper package matching to the location of ServerWebExchange.
2017-09-29 17:03:23 -04:00
Rossen Stoyanchev 223e27d53d Package private request and response implementations
Concrete server and client, reactive request and response
implementations should not have to be accessed outside their package.
They could be seen as private to their HttpHandler adapters and
ClientHttpConnector's respectively.

The one exception, WebSocket upgrades in spring-webflux, is an internal
framework use case, accommodated via downcast + accessors in the
abstract base classes.
2017-09-29 13:04:03 -04:00
Rossen Stoyanchev 13c959296a Polish 2017-09-27 22:04:07 -04:00
Brian Clozel 126ac849e5 Fix behavior of ClientResponse#bodyTo** with Void
Prior to this commit, asking for a `Void` type using any of the
`ClientResponse#bodyTo*` methods would immediately return an empty
`Publisher` without consuming the response body.

Not doing so can lead to HTTP connection pool inconsistencies and/or
memory leaks, since:

* a connection that still has a response body being written to it cannot
be properly recycled in the connection pool
* incoming `DataBuffer` might not be released

This commit detects when `Void` types are asked as body types and in
those cases does the following:

1. Subscribe to the response body `Publisher` to allow the connection to
be returned to the connection pool
2. `cancel()` the body `Publisher` if the response body is not empty; in
that case, we choose to close the connection vs. consume the whole
response body

Those changes imply that `ClientHttpResponse` and other related
contracts don't need a `close()` method anymore.

Issue: SPR-16018
2017-09-28 00:58:38 +02:00
Juergen Hoeller ec345bf162 Revised handling of missing data class arguments
Includes unified detection of Kotlin's optional parameters in MethodParameter.isOptional(), reduces BeanUtils.findPrimaryConstructor to Kotlin semantics (for reuse in AutowiredAnnotationBeanPostProcessor), and finally introduces a common KotlinDetector delegate with an isKotlinType(Class) check.

Issue: SPR-15877
Issue: SPR-16020
2017-09-28 00:31:12 +02:00
Rossen Stoyanchev 6ee1af27c6 WebFlux supports HTTP HEAD
Issue: SPR-15994
2017-09-27 15:25:29 -04:00
Juergen Hoeller a1a7c62127 Consistent configurer access in WebMvcConfigurationSupport
Issue: SPR-16017

(cherry picked from commit 40ba95f)
2017-09-27 19:52:48 +02:00
Brian Clozel 10139d42fc Revisit meaning of response.close() in HTTP client
Prior to this issue, SPR-15920 added this new `close()` method which was
supposed to be called to clean resources after response processing.

This commit changes the meaning of that method: calling `close()` will
close the underlying HTTP connection. This has to be called if the
response body is not consumed by the application, since at that point
the underlying connection might be in an inconsistent state if shared in
a connection pool.

Issue: SPR-15993
2017-09-27 14:03:55 +02:00
Rossen Stoyanchev ec5969c578 InMemoryWebSession cleans up expired sessions
Issue: SPR-15963
2017-09-27 01:43:11 -04:00
Rossen Stoyanchev 15cc44e6e8 Add WebSession.invalidate()
Issue: SPR-15960
2017-09-27 00:10:38 -04:00
Rossen Stoyanchev 6da3518a66 WebSessionStore updates lastAccessTime on retrieve
Now that WebSessionStore is in charge of expiration checks on retrieve
it makes sense to also update the lastAccessTime on retrieve at the
same time, saving the need to call it after a retrieve.

Issue: SPR-15963
2017-09-26 23:12:58 -04:00
Rossen Stoyanchev cb2deccb2d WebSessionStore performs expiration check on retrieve
Issue: SPR-15963
2017-09-26 23:12:12 -04:00
Juergen Hoeller efce7902c4 Polishing 2017-09-27 01:34:11 +02:00
Rossen Stoyanchev eb6bd2d7b8 Remove args and return value lists from @RequestMapping
It is no longer adequate to list supported arguments and return values
-- between Web MVC and WebFlux, directly on the annotation.

Instead we have tables in the respective chapters in the reference with
cross references to each other.

Issue: SPR-15149
2017-09-26 15:29:58 -04:00
Eddú Meléndez 6f2d58fac6 Remove jackson-datatype-jdk7 auto registration
`jackson-datatype-jdk7` is not provided anymore. It's handlers are
incorporated in core databind.
2017-09-26 14:48:34 +02:00
Brian Clozel 95b83fe1ba Add zero copy support in reactor-based WebClient
This commit makes Reactor Netty `WebClient` instances
support zero-copy requests by implementing `ZeroCopyHttpOutputMessage`.

The implementation leverages the optimized `sendFile` mechanism if
available.
2017-09-26 11:05:48 +02:00
Andy Clement 07b961caa6 Empty path should match the "/" PathPattern
This commit makes both slash "/" and empty "" request paths match the
"/" `PathPattern`.

Issue: SPR-15653
2017-09-26 10:59:13 +02:00
Sebastien Deleuze 74120ef00f Add custom deserializers support to AbstractJackson2Decoder
Issue: SPR-15975
2017-09-25 23:21:50 +02:00
Juergen Hoeller e2882fe1db Build against EE 8 API level wherever possible
Upgrade to JAXB 2.3, JAX-WS 2.3, Annotations 1.3.1, Interceptor 1.2.1.
Also includes Log4J 2.9.1 and Asciidoctor 1.5.6.
2017-09-24 17:18:21 +02:00
Juergen Hoeller 9190b76ab9 Latest dependency updates (POI 3.17, Rome 1.8, EhCache 3.4, Caffeine 2.5.6, RxJava 2.1.4, Tomcat 8.5.21, JRuby 9.1.13, Rhino 1.7.7.2) 2017-09-23 11:28:19 +02:00
Stephane Maldini 21203921f0 sync with reactor-core snapshot 2017-09-22 13:56:39 -07:00
Juergen Hoeller 7ae59d0c2a Nullability refinements on private and static methods
Based on IntelliJ IDEA 2017.3 introspection results.

Issue: SPR-15756
2017-09-22 18:22:14 +02:00
Brian Clozel 60f47f4489 Fix memory leak in reactive multipart parser 2017-09-22 17:03:38 +02:00
Andreas Ahlenstorf b30f6fd991 Ensure that JSON is written to response body
Issue: SPR-15988
2017-09-21 12:19:35 +02:00
Juergen Hoeller 15c82afc1c Consistent conversion of Optional array/list arrangements
Issue: SPR-15918
Issue: SPR-15919
Issue: SPR-15676
2017-09-20 18:28:49 +02:00
Juergen Hoeller ea01c4113a Revisit MockPart constructors
Issue: SPR-15854
2017-09-20 10:55:06 +02:00
Juergen Hoeller 4cbef27f90 Consistent tolerance of unknown HTTP status codes behind RestTemplate
Issue: SPR-15978
2017-09-20 10:54:58 +02:00
Juergen Hoeller 3bd2154046 Polishing 2017-09-19 00:02:40 +02:00
areshetnikov 0f0b8dc745 Fix class name in javadoc
Closes gh-1530
2017-09-18 14:28:37 +02:00
Sebastien Deleuze 1bc93e3d0f Revisit nullability annotations
This commit introduces the following changes.

1) It adds a new Spring @NonNull annotation which allows to apply
@NonNullApi semantic on a specific element, like @Nullable does.
Combined with @Nullable, it allows partial null-safety support when
package granularity is too broad.

2) @Nullable and @NonNull can apply to ElementType.TYPE_USE in order
to be used on generic type arguments (SPR-15942).

3) Annotations does not apply to ElementType.TYPE_PARAMETER anymore
since it is not supported yet (applicability for such use case is
controversial and need to be discussed).

4) @NonNullApi does not apply to ElementType.FIELD anymore since in a
lot of use cases (private, protected) it is not part for the public API
+ its usage should remain opt-in. A dedicated @NonNullFields annotation
has been added in order to set fields default to non-nullable.

5) Updated Javadoc and reference documentation.

Issue: SPR-15756
2017-09-15 13:26:41 +02:00
Violeta Georgieva ec2218c967 AbstractListenerWriteFlushProcessor: Ensure the last flush will be performed
When writing Publisher<Publisher<T>>, a flush operation is performed onComplete
for every Publisher. If the flush operation is not able to be performed immediately
it will be retried before starting to process data provided by the next Publisher.
For the last Publisher the implementation needs to ensure that the flush will
be performed only then whole operation will complete.

Issue: SPR-15949
2017-09-15 08:53:00 +02:00
Arjen Poutsma 2510db0683 Javadoc 2017-09-14 17:23:25 +02:00
Arjen Poutsma e70210a1da Introduce ForwardedHeaderFilter for WebFlux
This commit introduces a ForwardedHeaderFilter for WebFlux, similar to
the existing Servlet version. As part of this the
DefaultServerHttpRequestBuilder had to be changed to no longer use
delegation, but instead use a deep copy at the point of mutate().
Otherwise, headers could not be removed.

Issue: SPR-15954
2017-09-14 16:27:12 +02:00
Arjen Poutsma 4a0784bea8 Test HTTPS in ReactorServerHttpRequest URI
This commit adds a test for ReactorServerHttpRequest.getUri() to check
whether it returns a HTTPS scheme when configured with SSL.

Issue: SPR-15931
2017-09-12 15:14:54 +02:00
Juergen Hoeller 4371350b5d Polishing 2017-09-10 21:56:31 +02:00
Rossen Stoyanchev bc470fca30 Polish 2017-09-09 17:40:59 -04:00
Juergen Hoeller fd0132c7e6 Polishing 2017-09-08 16:56:22 +02:00
Yi EungJun cf106ec99e Fix typo 2017-09-08 10:48:27 +02:00
Brian Clozel 1a883b863d Remove temporary workaround for reactor-netty client
Now that https://github.com/reactor/reactor-netty/issues/138 is solved,
this commit removes the temporary workaround introduced in SPR-15784
but leaves the general mechanism for detecting empty responses.
2017-09-08 10:27:35 +02:00
Andy Clement 3956423afe Polish
The high level matchStarting API was removed a few commits ago.
This change tidies up by removing the supporting infrastructure
for that from the PathElements.
2017-09-07 14:03:46 -07:00
Arjen Poutsma ec6475a24c Expose scheme in ReactorServerHttpRequest URI
This commit determines fixes ReactorServerHttpRequest.getUri() so that
it includes a URL scheme.

Issue: SPR-15931
2017-09-07 12:29:28 +02:00
Rossen Stoyanchev 2fc2dab230 Fold DefaultWebSession within InMemoryWebSessionStore
InMemoryWebSessionStore is very closely associated to DefaultWebSession
passing it to it several fields and functions. Now that the store also
creates the session, it makes sense to bring the latter in as an inner,
nested class.

Issue: SPR-15875, 15876
2017-09-06 11:47:43 -04:00
Rossen Stoyanchev c7d54c8b52 Polish 2017-09-06 11:47:43 -04:00
Rob Winch 8ad14ae95c DefaultWebSessionManager decoupled from DefaultWebSession
DefaultWebSessionManager no longer requires the WebSessionStore
to use DefaultWebSession.

Removed explicit start() in save(). This seemed unnecessary since at
that point isStarted is guaranteed to return true. The status can
be updated through the copy constructor.

DefaultWebSessionTests added.

Issue: SPR-15875
2017-09-06 11:47:43 -04:00
Rob Winch 86912475af Refactor WebSessionStore
- Add WebSessionStore.createWebSession.

- Remove remove WebSessionStore.changeSessionId

- Add WebSessionStore updateLastAccessTime which allows updating the
WebSession lastAccessTime without exposing a method on WebSession in
an implementation independent way.

- Remove WebSessionStore.storeSession. This method is not necessary
since the WebSession that is returned allows saving the WebSession.
Additionally, it is error prone since the wrong type might be passed
into it.

Issue: SPR-15875, 15876
2017-09-06 11:47:43 -04:00
Rob Winch b7280472d6 Improve WebSession related tests
Add missing DefaultWebSessionManagerTests .block(). Previously
session.save() was invoked, but we did not ensure it was completed.
This commit makes it block on session.save()

Fix existingSessionIsExpired. This test is actually broken and is
testing a new session is created because the session id returned
by the idResolver does not match the existing WebSession.
This commit ensures that the id of the WebSession found by idResolver
matches the existing WebSession.

DefaultWebSessionManagerTests use Mockito. To ensure we test with
independence from InMemoryWebSessionStore we use Mockito for the
DefaultWebessionManager collaborators.

Add test for response.setComplete(). We want to ensure that when the
response is completed, it saves the WebSession and writes it to the
response using idResolver
2017-09-06 11:47:43 -04:00
Rob Winch 167ddc7cfc Polish HeaderWebSessionIdResolver
Use constant for default header name and make getHeaderName private.

Also switch HeaderWebSessionIdResolverTests to unit tests rather than
testing with DefaultWebSessionManager.

Issue: SPR-15917
2017-09-06 11:47:43 -04:00
Brian Clozel 16f3f8d28f Add close() method on HTTP client response
Before this commit, there was no way to signal the HTTP client that we
were done consuming the response. Without that, the underlying client
library cannot know when it is safe to release the associated resources
(e.g. the HTTP connection).

This commit adds new `close()` methods on both `ClientHttpResponse`
and `ClientResponse`. This methods is non-blocking and its behavior
depends on the library, its configuration, HTTP version, etc.

At the `WebClient` level, `close()` is called automatically if we
consume the response body through the `ResponseSpec` or the
`ClientResponse` itself.

Note that it is *required* to call `close()` manually otherwise; not
doing so might create resource leaks or connection issues.

Issue: SPR-15920
2017-09-06 17:29:18 +02:00