Commit Graph

14803 Commits

Author SHA1 Message Date
Juergen Hoeller fd53d2a51a Consistent use of @Nullable in spring-test
This commit also removes nullability from two common spots: ResolvableType.getType() and TargetSource.getTarget(), both of which are never effectively null with any regular implementation. For such scenarios, a non-null empty type/target is the cleaner contract.

Issue: SPR-15540
2017-06-08 22:52:59 +02:00
Juergen Hoeller ee5fa2633a Protect against null return value from DataSource.getConnection()
Issue: SPR-15641
2017-06-08 22:51:41 +02:00
Arjen Poutsma bf66f45283 Support overriding, removing headers in ClientRequest
This commit adds two Consumer based methods to ClientRequest that allow
for direct manipulation of the underlying headers or cookies map. As
such, these methods can be used to override or remove existing entries.

Issue: SPR-15635
2017-06-08 14:00:39 +02:00
Juergen Hoeller e6f1950952 Missing @Nullable annotations for findAnnotation/getValue/getDefaultValue
Note that synthesizeAnnotation has an assertion now, keeping its non-null policy.

Issue: SPR-15642
2017-06-08 10:35:54 +02:00
Phillip Webb 72cd24446d Make resolvePropertyName available to subclasses
Change `SystemEnvironmentPropertySource.resolvePropertyName` to a
protected final method so that subclasses may call it.

Issue: SPR-15617
2017-06-07 17:03:31 -07:00
Phillip Webb c675424189 Restore AnnotationUtils null argument support
Update AnnotationUtils to restore support for `null` arguments in
certain methods. Some existing upstream projects were relying on this
behavior.

Issue: SPR-15642
2017-06-07 16:59:24 -07:00
Juergen Hoeller 7eaedf2916 Debug-level log entry for any Jackson exception during canConvert
Issue: SPR-15582
2017-06-07 18:33:19 +02:00
Juergen Hoeller 55b0fe1027 Unwrap SpringValidatorAdapter (e.g. CustomValidatorBean) to native Validator
Issue: SPR-15629
(cherry picked from commit 8330134)
2017-06-07 18:33:13 +02:00
Arjen Poutsma 510436bae9 Copy header values instead of header lists in DefaultClientRequestBuilder
This commit changes the `headers(HttpHeaders)` method in
DefaultClientRequestBuilder so that it copies the individual header
values instead of using the `List<String>` value directly. The reason
for this change is that the list of values can be immutable, and adding
additional values after that could result in
UnsupportedOperationExceptions.
2017-06-07 17:55:51 +02:00
Juergen Hoeller a0bce618c2 Latest dependency updates (Undertow 1.4.16, Caffeine 2.5.2, JavaMail 1.6 RC2) 2017-06-07 14:19:58 +02:00
Juergen Hoeller f813712f5b Consistent use of @Nullable across the codebase (even for internals)
Beyond just formally declaring the current behavior, this revision actually enforces non-null behavior in selected signatures now, not tolerating null values anymore when not explicitly documented. It also changes some utility methods with historic null-in/null-out tolerance towards enforced non-null return values, making them a proper citizen in non-null assignments.

Some issues are left as to-do: in particular a thorough revision of spring-test, and a few tests with unclear failures (ignored as "TODO: NULLABLE") to be sorted out in a follow-up commit.

Issue: SPR-15540
2017-06-07 14:19:15 +02:00
Stephane Nicoll ffc3f6d87d Merge pull request #1445 from diguage:dev
* pr/1445:
  Polish "Refactor duplicated code"
  Refactor duplicated code
2017-06-04 13:06:26 +02:00
Stephane Nicoll 6e3a9cbbb4 Polish "Refactor duplicated code"
Closes gh-1445
2017-06-04 13:06:09 +02:00
diguage 5288641c50 Refactor duplicated code
See gh-1445
2017-06-04 13:01:03 +02:00
Stéphane Nicoll a1a6157fb1 Merge pull request #1444 from diguage/dev
Fix reference
2017-06-03 15:20:28 +02:00
diguage eae63786c2 Fixed reference 2017-06-03 15:19:36 +08:00
Andy Clement 77576ed6fe Fix PathPattern comparator result for wildcard suffix usage
Without this change the comparator thinks "/{foo}"
is more specific than "/{foo}.*". The minimal fix here
to address it is to copy what the AntPathMatcher
comparator does which is to consider '.*' as *not*
a usage of a wildcard. See PatternInfo#initCounters()
for the AntPathMatcher handling of this.

This change ensures the PathPattern comparator now produces
the expected result but suffix usage in general needs more
thought at some point.

Issue: SPR-15597
2017-06-02 15:40:16 -07:00
Rossen Stoyanchev 4244df740b Consolidate matrix vars parsing in HttpRequestPathHelper
Restore matrix variable parsing code not resorting to the use of
WebUtils which brings Servlet API dependencies with it.

Instead the parsing logic is now exposed through HttpRequestPathHelper
which already contained the decoding logic and also the knowledge of
whether to decode the parsed variables or not.

Issue: SPR-15397
2017-06-02 15:52:44 -04:00
Rossen Stoyanchev d2685dfe67 Add static factory/accessor methods to LookupPath
Issue: SPR-15397
2017-06-02 15:15:42 -04:00
Rossen Stoyanchev a7020e419a Polish use of LookupPath 2017-06-02 14:46:34 -04:00
Sebastien Deleuze 90df7dd279 Add missing @Nullable annotation
Issue: SPR-15540
2017-06-02 14:16:19 +02:00
Brian Clozel 74fb2645fd Fix LookupPath parsing
Issue: SPR-15397
2017-06-02 09:26:35 +02:00
Rossen Stoyanchev 4d52590964 Improve docs on forwarded headers
Issue: SPR-15612
2017-06-01 22:36:12 -04:00
Rossen Stoyanchev 895fa2ea7b Add removeOnly mode to ForwardedHeaderFilter
Issue: SPR-15610
2017-06-01 15:39:19 -04:00
Brian Clozel cf1bc81199 Introduce LookupPath in WebFlux request routing
This commit adds the `LookupPath` class that contains the full
request path relative to the web context; the application can
get from it various information, including the file extension
and path parameters (if any).

Since that operation is done multiple times for each request, this
object is stored as an attribute at the `ServerWebExchange` level.

Issue: SPR-15397
2017-06-01 18:31:04 +02:00
Brian Clozel 0557404715 Throw exception for illegal PathMatch configurations
With the new `ParsingPathMatcher` implementation, new patterns are now
allowed, such as `"/foo/{*bar}". The `"{*bar}"` segment will capture
everything until the end of the given path. Adding other elements after
that segment is illegal and will throw exceptions.

One can configure on a `PathMatchConfigurer` various options like
`useTrailingSlashMatch` and `useSuffixPatternMatch`; those options, when
enabled, will try to append suffixes like `".*"` and `"/"` to existing
path patterns. In case of a "capture the rest" pattern segment, those
options won't be honored.

This is why this commit ensures that an exception is thrown at the start
of the application if an illegal configuration is applied to the
`PathMatchConfigurer`.

Issue: SPR-15303, SPR-15558
2017-06-01 18:30:18 +02:00
Arjen Poutsma 8ea54270e1 Allow for null query parameter values in ServerRequest
With this commit, ServerRequest allows for `null` values in query
parameters, treating them as empty values instead.

Issue: SPR-15609
2017-06-01 18:00:54 +02:00
Rossen Stoyanchev b93579a43e Polish 2017-06-01 09:28:55 -04:00
Violeta Georgieva e8d2c6c74b AbstractListenerWriteProcessor/AbstractListenerWriteFlushProcessor error handling
When an exception happens while writing/flushing, the exception handling
for Servlet 3.1 based implementation will happen when
WriteListener#onError and AsyncListener#onError events are received
2017-06-01 09:19:45 -04:00
Violeta Georgieva 23a052c160 Clear the buffer provided by Undertow before reading the request
When reading more that once for a given request, the position/limit of
the buffer provided by Undertow should be reset in order to use the
full capacity of the buffer.
2017-06-01 15:14:25 +03:00
Arjen Poutsma 8504084553 Add package-info.java to mock.web.reactive.function.server 2017-06-01 12:37:42 +02:00
Arjen Poutsma 7894efdd1e Allow for null values in ExtractingResponseErrorHandler.hasError
This commit fixes the implementation of
ExtractingResponseErrorHandler.hasError to allow for null values,
indicating an override of the behavior inherited from
DefaultResponseErrorHandler.

Issue: SPR-15544
2017-06-01 11:44:08 +02:00
Rossen Stoyanchev d3e3365990 Merge pull request #1439 from dreis2211/SPR-15602 2017-05-31 22:46:09 -04:00
Rossen Stoyanchev 4a3f6e4546 Polish 2017-05-31 22:43:25 -04:00
Christoph Dreis 0ef1623643 Optimize DefaultUserDestinationResolver.resolveDestination()
Issue: SPR-15602
2017-05-31 22:37:42 -04:00
Kazuki Shimizu 1412c2c577 Fix sample code in WebFlux chapter 2017-05-31 22:05:38 -04:00
QBNemo 94618c4f37 Polish doc on RequestMappingHandlerMapping#isHandler 2017-05-31 21:25:44 -04:00
Rossen Stoyanchev e81651b657 Ignore empty Accept-Language header value
Issue: SPR-15603
2017-05-31 21:10:08 -04:00
Sebastien Deleuze b494c53b40 Avoid defining nullability for non-relevant API
Defining nullability of some API like EnvironmentCapable
or ConditionContext causes issues in Spring Boot because
in the context where they are used, it is known for sure
they will return non-null values even if their API can in
other context return null values.

It is better in this case for both Java and Kotlin to
not define at all the nullabity of such API.

In practice, this is achieved by removing the package level
@NonNullApi annotation and adding it only on the
relevant classes.

Issue: SPR-15540
2017-05-31 22:51:33 +02:00
Sebastien Deleuze 1f28825f9d Add more @Nullable parameters based on null usage
Issue: SPR-15540
2017-05-31 21:42:23 +02:00
Gary Russell f9b319d3ba Revert Incorrect MessagingTemplate Change
The change to "optimize" the template by not rebuilding the reply
message when the original header channels was null was incorrect.

We need to null out those headers if they were originally null.

Issue: SPR-15991
2017-05-31 15:12:46 -04:00
Sebastien Deleuze c3e6afb879 Improve null-safety to fix some Spring Boot warnings
Issue: SPR-15540
2017-05-31 17:14:49 +02:00
Sebastien Deleuze b47d713e14 Add missing @Nullable annotations on parameters
Issue: SPR-15540
2017-05-31 16:56:08 +02:00
Sebastien Deleuze ad2c0f8410 Improve @Nullable annotation
This commit makes Spring @Nullable annotation leveraging
JSR 305 @TypeQualifierNickname + @Nonnull(when= When.MAYBE)
instead of directly using @javax.annotation.Nullable which
seems not designed to be used as a meta-annotation.

It also removes @TypeQualifierDefault since the purpose of
this annotation when applied at method level is to only
change return value nullability, not parameters one.

Issue: SPR-15540
2017-05-31 16:56:08 +02:00
Rossen Stoyanchev abcc4ac979 Fix composability issue in ExchangeMutatorWebFilter
This commit replaces the UnaryOperatory<ServerWebExchange> inputs with
Function<ServerWebExchange, ServerWebExchange> instead. Unfortunately
the composability methods inherited from Function don't work in terms
of generics for composing multiple UnaryOperator's.

Issue: SPR-15599
2017-05-31 09:30:04 -04:00
Gary Russell e06c4d5116 Timeout Overrides in Messaging Templates
Provide a mechanism to override the configured send and receive
timeouts in the GenericMessagingTemplate.

- overload `doReceive()` to take a receive timeout argument
- for `sendAndReceive()` methods examine message headers for these
  timeout values
  - remove headers to avoid propagation
  - avoid the unconditional rebuild of the reply message if the
    original headers weren't present
- also remove headers from simple `send()` operations
- change javadocs for the setters to indicate they are now defaults
- add properties to allow the user to override the header names used
- change `TemporaryReplyChannel` to use `send` arg and change to static
  - add package-protected ctor to avoid the compiler creating a
    synthetic constructor for access

Issue: SPR-15591
2017-05-30 17:03:46 -04:00
Rossen Stoyanchev 5dcfd84d3b MockServerHttpRequest and Response set cookie headers
Issue: SPR-15522
2017-05-30 11:00:15 -04:00
Rossen Stoyanchev 67bcef22e4 Polish MockServerHttpRequest|Response 2017-05-30 11:00:15 -04:00
Arjen Poutsma 4b0dedc45e Add ExtractingResponseErrorHandler
This commit introduces ExtractingResponseErrorHandler: an alternative
ResponseErrorHandler that uses `HttpMessageConverter`s to convert HTTP
error responses to `RestClientException`.

Issue: SPR-15544
2017-05-30 13:17:25 +02:00
Stephane Nicoll beb7ed9715 Polish
Issue: SPR-15592
2017-05-29 17:04:10 +02:00