Commit Graph

13300 Commits

Author SHA1 Message Date
Sebastien Deleuze b4641b2306 Polishing 2016-09-01 14:48:16 +02:00
Arjen Poutsma f1319f58ec Introduce new functional web API
This commit introduces a new, functional web programming model in the
org.springframework.web.reactive.function package. The key types
are:

 - Request and Response are new Java 8-DSLs for access to the HTTP
   request and response
 - HandlerFunction represents a function to handle a request to a
   response
 - RoutingFunction maps a request to a HandlerFunction
 - FilterFunction filters a routing as defined by a RoutingFunction
 - RequestPredicate is used by Router to create RoutingFunctions
 - RequestPredicates offers common RequestPredicate instances
2016-09-01 14:38:13 +02:00
Arjen Poutsma 18e491ac0a Merge pull request #1143 from poutsma/server_sent_event
* server_sent_event:
  Refactored SseEvent to ServerSentEvent
2016-09-01 13:51:25 +02:00
Arjen Poutsma 16b525f698 Refactored SseEvent to ServerSentEvent
- Renamed SseEvent to ServerSentEvent to make the name less redundant.
 - ServerSentEvent is now immutable, having a builder to create new instances.
 - Realigned the class properties to more closely match the events
   described in the spec, so that `reconnectTime` becomes `retry`, and
   `name` becomes `event`.
2016-09-01 13:47:50 +02:00
Sam Brannen d9eaa5f3ac Use Map.computeIfAbsent() in SpringClassRule
Replace manual synchronization block in SpringClassRule with Java 8's
Map.computeIfAbsent().

Issue: SPR-12421
2016-09-01 13:38:42 +02:00
Juergen Hoeller 1cf503f939 Upgrade to JSR-354 API 1.0.1 and Jackson 2.8 javadocs 2016-09-01 12:49:01 +02:00
Juergen Hoeller aff914c98e Documentation updates around configuration classes 2016-09-01 12:41:55 +02:00
Arjen Poutsma 35cf4f173b Copied getAndSub() over from Reactor
Operators.getAndSub was removed in Reactor 3.0.1, this commit copies the
implementation over to AbstractRequestBodyPublisher, which used it.
2016-09-01 11:16:01 +02:00
Sam Brannen feb02f813e Polishing 2016-08-31 20:52:39 +02:00
Sam Brannen e574820dc9 Introduce tests for @Nested tests in JUnit Jupiter
This commit introduces integration tests that verify the expected
behavior for @Nested tests in conjunction with the SpringExtension for
JUnit Jupiter, including automatic application of
TestExecutionListeners to the enclosing test instance of a @Nested
test instance.

Issue: SPR-14150
2016-08-31 20:29:08 +02:00
Sam Brannen ab7b5e5c77 Demo how to use SpringClassRule in nested test classes
Due to restrictions imposed by JUnit 4, the SpringClassRule must be
declared as a public static field, which makes it impossible to be
declared directly within a nested (i.e., inner) test class.

This commit demonstrates a work-around that makes it possible to use
the SpringClassRule and SpringMethodRule in a nested (i.e., inner) test
class when using a custom JUnit 4 runner such as the
HierarchicalContextRunner from Stefan Bechtold.

The trick is to have inner test classes extend a class that properly
declares the SpringClassRule and SpringMethodRule. The
SpringRuleConfigurer in this commit serves as an example.

Note, however, that each such nested test class must declare its own
@ContextConfiguration. Furthermore, TestExecutionListeners in the
Spring TestContext Framework are not applied to the enclosing instance
of such an inner test class, meaning that @Autowired fields in the
enclosing instance will not be injected, etc.

Issue: SPR-14150
2016-08-31 19:35:00 +02:00
Rob Winch 09f16747b5 Fix MergePlugin transitive dependencies
A little terminiology first:

* merge.from - a project that contains source that will be merged
               into merge.into
* merge.into - a project that contains source code that will have
               code from merge.from merged into it.

Previously a module that dependended on merge.into would not see
the merge.from module as a transitive dependency. This worked fine
from a Gradle build because all the code from merge.from is merged
into the merge.into jar. However, in an IDE it did not work because
the IDE does not assemble a jar.

This fix ensures that merge.from modules are automatically added
to the classpath of any module relying on the merge.into project.

Fixes SPR-14650
2016-08-31 11:38:24 -05:00
Sam Brannen 634d1c03a3 Introduce @EnabledIf support for JUnit Jupiter
This commit picks up where SPR-14614 left off by introducing a new
@EnabledIf annotation to serve as a logical companion to @DisabledIf.

In addition, this commit extracts common logic from DisabledIfCondition
into a new AbstractExpressionEvaluatingCondition base class which the
new EnabledIfCondition also extends.

An @EnabledOnMac annotation is also included in the Javadoc as well as
in the test suite to demonstrate support for custom composed annotations.

Issue: SPR-14644
2016-08-31 16:11:58 +02:00
Juergen Hoeller 1a30252fc9 ResolvableType.java.forRawClass(Class) supports isAssignableFrom(ResolvableType) as well
Issue: SPR-14648
2016-08-31 14:45:22 +02:00
Juergen Hoeller e08b1b75b6 @PathVariable supports 'required' attribute (for model attribute methods)
Issue: SPR-14646
2016-08-31 14:43:39 +02:00
Juergen Hoeller faf6e5d8fa Annotation tests should not rely on JDK-specific toString() representation
Issue: SPR-14645
2016-08-31 14:42:08 +02:00
Brian Clozel 7a88776329 Fix missing ResourceHttpRequestHandler init in registry
Issue: SPR-14577
2016-08-31 10:43:11 +02:00
Juergen Hoeller ab9fea6b8d Polishing
(cherry picked from commit 3767092)
2016-08-31 02:08:31 +02:00
Juergen Hoeller 31c5644691 ResponseStatusExceptionHandler in web.server.handler (plus related polishing) 2016-08-30 23:58:14 +02:00
Juergen Hoeller 4ef428de28 Polishing 2016-08-30 23:57:11 +02:00
Juergen Hoeller 03609c1518 Consistent comma splitting without regex overhead
Issue: SPR-14635
2016-08-30 23:56:58 +02:00
Juergen Hoeller 58fa63fdd1 ApplicationListenerMethodAdapter resolves order on construction
Issue: SPR-14642
2016-08-30 20:50:02 +02:00
Rossen Stoyanchev 391752abc2 Polish and update reactive getting started reference
This commit updates the instructions on getting started with
Spring Web Reactive and also updates constructors and setters to
streamline the getting started procedure.

Issue: SPR-14640
2016-08-30 14:36:19 -04:00
Rossen Stoyanchev 436486b8a1 Relax ServletContext check for resource handling
This is a follow-up on commit 3b95e0b relaxing the expectation that a
ServletContext is present. Instead we check defensively and fall back
on PathExtensionContentNegotiationStrategy which can use JAF.

Issue: SPR-14577
2016-08-30 13:04:58 -04:00
Artem Yakshin e7aecb44bb Update for IntelliJ Idea 2016.2.2
Update tutorial for import and build project in IntelliJ IDEA 2016.2.2. Steps are outdated and existing issues is not applicable in new versions.
2016-08-30 16:40:49 +02:00
Rossen Stoyanchev 16879a2cf0 Harden synchronization around SockJS heartbeats
Create an explicit heartbeat task with an experiration flag so that
it can be cancelled reliably vs relying on the ScheduledFutureTask
cancel method which may return true even if the task is already
running.

Issue: SPR-14356
2016-08-30 09:26:15 -04:00
Juergen Hoeller 2aab08f093 Polishing 2016-08-30 12:59:40 +02:00
Juergen Hoeller b19d3fc0e1 Upgrade to Jackson 2.8.2 and Netty 4.1.5 2016-08-30 12:58:44 +02:00
Juergen Hoeller 58ffca76c3 CommonsMultipartResolver explicitly converts FileSizeLimitExceededException
Issue: SPR-14638
2016-08-30 12:57:46 +02:00
Brian Clozel 960d335c35 Don't wrap resolver exceptions in InvocableHandlerMethod
Prior to this commit, exceptions thrown by the
`HandlerMethodArgumentResolver` would be wrapped into
`IllegalStateException`s.

This commit makes sure that a DEBUG log is written with the relevant
information and that the root cause is not wrapped into another
exception, so that the appropriate `ExceptionHandler` can be used to
deal with this error.

Issue: SPR-14618
2016-08-30 11:50:40 +02:00
Sebastien Deleuze e8530c917e Add Smile and CBOR Jackson data formats support
This commit adds Smile and CBOR Jackson HttpMessageConverters
and make it possible to create Smile and CBOR ObjectMapper via
Jackson2ObjectMapperBuilder, which now allows to specify any
custom JsonFactory.

Like with JSON and XML Jackson support, the relevant
HttpMessageConverters are automaticially configurered by
Spring MVC WebMvcConfigurationSupport if jackson-dataformat-smile
or jackson-dataformat-cbor dependencies are found in the classpath.

Issue: SPR-14435
2016-08-30 11:06:40 +02:00
Stephane Nicoll c399b4b3ad Upgrade to SonarQube plugin 2.1-rc1
This commit upgrades the SonarQube plugin so that it is compatible with
Gradle 3.

Issue: SPR-14569
2016-08-30 10:42:32 +02:00
Rossen Stoyanchev 204a50ee6c Fix compile issue 2016-08-29 21:06:35 -04:00
Rossen Stoyanchev 4d3c3056ed Polish media type change in ResourceHttpRequestHandler 2016-08-29 19:49:24 -04:00
Rossen Stoyanchev 8b4f60b8e5 Support receipt on DISCONNECT with simple broker
Issue: SPR-14568
2016-08-29 18:31:19 -04:00
Rossen Stoyanchev 3b95e0b6e0 Fix media type regression in resource handling
Issue: SPR-14577
2016-08-29 16:27:24 -04:00
Sebastien Deleuze 417a9d4559 Ensure correct array elements order in Jackson2JsonEncoder
Issue: SPR-14586
2016-08-29 16:22:25 +02:00
Sam Brannen b6220cc19d Trim expressions supplied to @DisabledIf
Prior to this commit, the DisabledIfCondition did not trim whitespace
from expressions configured via @DisabledIf. Consequently, results such
as "  true  " would evaluate to "false".

This commit fixes this problem by trimming all expressions configured
via @DisabledIf.

Issue: SPR-14614
2016-08-29 15:47:38 +02:00
Sam Brannen d6d05e8ca0 Remove trailing whitespace in Java source code 2016-08-29 15:25:10 +02:00
Sam Brannen 9d21abcd37 Introduce dedicated tests for DisabledIfCondition
This commit introduces tests for DisabledIfCondition that verify actual
condition evaluation results and exception handling; whereas, the
existing tests in DisabledIfTestCase only test the "happy paths" and
standard cases.

Issue: SPR-14614
2016-08-29 15:17:59 +02:00
Sam Brannen 54d6f250e2 Disallow empty expression in @DisabledIf
This commit ensures that a user provides a non-empty expression in
declarations of @DisabledIf.

Issue: SPR-14614
2016-08-29 13:43:38 +02:00
Juergen Hoeller 899ebd8ee2 Avoid collection lookups in StompCommand
Issue: SPR-14636
2016-08-29 11:54:21 +02:00
Juergen Hoeller 728a548199 Consistent use of JDK 7 AssertionError with root cause
Issue: SPR-13188
2016-08-29 11:53:00 +02:00
Sam Brannen 655097a343 Merge pull request #1144 from ttddyy/SPR-14614
* ttddyy-SPR-14614:
  Revise @DisabledIf support for JUnit Jupiter
  Introduce @DisabledIf annotation for JUnit 5
2016-08-28 21:16:59 +02:00
Sam Brannen 19369094ac Revise @DisabledIf support for JUnit Jupiter
- Extracted stand-alone DisabledIfCondition from the SpringExtension
  so that the condition is only evaluated when necessary.

- Simplified implementation of DisabledIfCondition.

- Overhauled and extended logging in DisabledIfCondition.

- DisabledIfCondition now throws an IllegalStateException if @DisabledIf
  is not present on the test element or if the expression does not
  evaluate to a String or Boolean.

- Each generated ConditionEvaluationResult now includes the actual
  expression in the default reason.

- @DisabledIf is now auto-configured to be evaluated by the
  DisabledIfCondition since it is now meta-annotated with
  @ExtendWith(DisabledIfCondition.class)

- Overhauled documentation for @DisabledIf and provided standard
  examples as well as an @DisabledOnMac annotation to demonstrate
  support for custom composed annotations.

Issue: SPR-14614
2016-08-28 21:12:38 +02:00
Tadaya Tsuyukubo c03f6c6d85 Introduce @DisabledIf annotation for JUnit 5
This commit introduces @DisabledIf annotation that takes SpEL as a
condition.  The condition is evaluated at run time whether to disable
JUnit 5 (Jupiter) test method/class.

Issue: SPR-14614
2016-08-28 21:12:38 +02:00
Stephane Nicoll eb193aea5f IDEA -> IntelliJ IDEA 2016-08-28 17:49:58 +02:00
Juergen Hoeller 57cb7c7e0a LiveBeansView exposes aliases as well
Issue: SPR-14632
2016-08-26 20:04:23 +02:00
Juergen Hoeller dfdfd72a3e Polishing
(cherry picked from commit 430180a)
2016-08-26 18:59:40 +02:00
Brian Clozel b84fefc430 Wrap RestTemplate extractor exceptions in RestClientExceptions
When using a `RestTemplate` instance within a Spring MVC application,
client exceptions may propagate in the MVC stack and can be wrongly
mapped by server `ExceptionHandlers`, leading to a wrong HTTP response
sent to the MVC client.

The `RestTemplate` instance uses `HttpMessageConverter` to decode
the remote service responses; and when those fail decoding an HTTP
response, they can throw an `HttpMessageNotReadableException`. That
exception then bubbles up through the `HttpMessageConverterExtractor`,
`RestTemplate` and the whole MVC stack, later mapped to HTTP 400
responses, since those exceptions can also be throws by the server stack
when the incoming requests can't be deserialized.

This commit wraps all `IOException` and `HttpMessageNotReadableException`
instances thrown by the extractor into `RestClientException`` instances.
It's now easier to consistently handle client exceptions and avoid such
edge cases.

Issue: SPR-13592
2016-08-26 17:56:00 +02:00