Commit Graph

1839 Commits

Author SHA1 Message Date
Rossen Stoyanchev 0be8c20fca Consistent logging of selected media types 2018-07-24 20:47:26 -04:00
Rossen Stoyanchev 6372c0f47c Ensure headers work with ResponseEntity + reactive body
Issue: SPR-17076
2018-07-24 00:24:29 -04:00
Sebastien Deleuze b09fad13a1 Catch errors when adding SourceHttpMessageConverter
This commit ignores errors like TransformerFactoryConfigurationError
that can be thrown when instantiating SourceHttpMessageConverter on
platforms where no TransformerFactory implementation is available,
like when compiling/running as GraalVM native images.

Issue: SPR-17007
2018-07-23 10:39:26 +02:00
Juergen Hoeller 9a43d2ec20 Revised log levels: less WARN and INFO, fine-tuned DEBUG vs TRACE
Issue: SPR-16946
2018-07-20 15:05:16 +02:00
Rossen Stoyanchev 07653bfd0c Fix for encoding issue with MvcUriComponentsBuilder
Provide method for stronger encoding of expanded URI variables when
building links from views.

Issue: SPR-17027
2018-07-19 19:07:42 -04:00
Rossen Stoyanchev 93b7a4838e UriComponentsBuilder method to configure URI variables
See Javadoc on UriComponentsBuilder#uriVariables for details.

This helps to prepare for SPR-17027 where the MvcUriComponentsBuilder
already does a partial expand but was forced to build UriComonents
and then create a new UriComponentsBuilder from it to continue. This
change makes it possible to stay with the same builder instance.

Issue: SPR-17027
2018-07-19 19:07:42 -04:00
Juergen Hoeller 867b3d233d Upgrade to OkHttp 3.11, Apache HttpClient 4.5.6, Hibernate Validator 6.0.11 2018-07-19 17:52:08 +02:00
Rossen Stoyanchev 66d73017d5 PathVariable consistently reflects value up to 1st ";"
Given "/{foo}" and "/a=42;c=b", previously that would be treated as a
sequence of matrix vars with an empty path variable. After the change
the path variable "foo" is "a=42".

This should be ok for backawards compatibility since it's unlikely for
anything to rely on an empty path variable.

Issue: SPR-11897
2018-07-18 22:14:02 -04:00
Juergen Hoeller c77dbbb1e6 Specific exception for missing request header, cookie, matrix variable
Issue: SPR-14818
2018-07-18 18:56:51 +02:00
Juergen Hoeller 790d515f8c HandlerMethod exposes interface parameter annotations as well
The HandlerMethodParameter arrangement uses an approach similar to ModelAttributeMethodProcessor's FieldAwareConstructorParameter, merging the local parameter annotations with interface-declared annotations.

Issue: SPR-11055
2018-07-18 17:13:55 +02:00
Sebastien Deleuze 3c9049d530 Leverage Jetty BOM
Issue: SPR-17058
2018-07-18 14:49:49 +02:00
Juergen Hoeller ef9027e1c1 Polishing 2018-07-17 17:59:16 +02:00
Juergen Hoeller b8d2a16c31 UrlBasedViewResolver exposes redirect/forward prefix as bean name
Issue: SPR-17045
2018-07-17 17:58:19 +02:00
Juergen Hoeller 88e4006790 CookieLocaleResolver is RFC6265 and language tag compliant by default
Like CookieLocaleResolver, LocaleChangeInterceptor parses both locale formats by default now. Since it does not need to render the locale, its languageTagCompliant property is not relevant anymore at all.

The parseLocale method in StringUtils validates the locale value now and turns an empty locale into null, compatible with parseLocaleString behavior and in particular aligned with web locale parsing needs.

Issue: SPR-16700
Issue: SPR-16651
2018-07-17 17:57:59 +02:00
Juergen Hoeller 955665b419 Consistent processing of binding/validation failures for data classes
Includes an extension of SmartValidator for candidate value validation, as well as nullability refinements in Validator and BindingResult.

Issue: SPR-16840
Issue: SPR-16841
Issue: SPR-16854
2018-07-17 17:01:34 +02:00
Juergen Hoeller b915e42c38 Resolve target type for GenericHttpMessageConverter.canWrite/write
Issue: SPR-16877
2018-07-16 19:45:35 +02:00
Juergen Hoeller 680afa75d8 ListableBeanFactory.getBeansOfType does not include null bean entries
Issue: SPR-17034
2018-07-14 01:02:39 +02:00
Rossen Stoyanchev 7b3a72f483 Warn when SimpleAsyncTaskExecutor is used
Issue: SPR-16203
2018-07-11 11:10:03 -04:00
Rossen Stoyanchev 1b1bc7f5b5 Switch defaults and model for logging sensitive data
Issue: SPR-17029
2018-07-11 11:10:03 -04:00
Rossen Stoyanchev a40d25a760 Remove no-op classes in web-related Java config 2018-07-11 11:10:03 -04:00
Juergen Hoeller c2fbd9f321 Upgrade to Rome 1.11 and OpenPDF 1.1 2018-07-11 16:48:12 +02:00
Brian Clozel 818e4b0776 Refine Content-Range support for Resources
This commit restricts the support of `"Content-Range"` when returning
`Resource` instances from Controllers - now only "HTTP 200 OK" responses
will be considered, as Controllers might want to handle content range
themselves.

Issue: SPR-16921
2018-07-10 12:11:23 +02:00
Juergen Hoeller 83faee67d5 HttpMessageNotReadableException provides access to HttpInputMessage
Issue: SPR-15588
2018-07-04 22:46:09 +02:00
Juergen Hoeller 641039d85d Polishing 2018-06-29 22:36:08 +02:00
Juergen Hoeller e22466e9d5 Polishing 2018-06-29 19:44:15 +02:00
Juergen Hoeller df6b01a329 Remove deprecated classes and methods from early 5.0.x phase 2018-06-29 19:44:08 +02:00
Juergen Hoeller d34e6f7f70 Polishing 2018-06-28 18:02:07 +02:00
Juergen Hoeller 40efcc933c Polishing 2018-06-28 14:51:33 +02:00
Juergen Hoeller 08e1c8cfaf Fix FreeMarker escaping regression for messages and separators
Issue: SPR-16951
2018-06-28 14:15:16 +02:00
Phillip Webb a89e716cc7 Use tabs rather than spaces in tests
Update tests to ensure that tabs are used instead of spaces. Also
consistently apply a new line at the end of each file.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb 1c25cec44f Polish test code
Polish a few issue identified when adding checkstyle to the
build. Although checkstyle is not enforcing rules on tests,
these are a few minor changes that are still worth making.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb 81451aa800 Organize imports
Reorganize imports to ensure consistent ordering. This commit also
expands any `.*` static imports in favor of using fully-qualified
method references.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb 5cedd0d5d4 Consistently use tabs rather than spaces
Update code that has accidentally used spaces instead of tabs.
Also remove all trailing whitespace.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb 9de3689f63 Never use 'this.' when accessing loggers
Ensure that `this.` is never used when accessing loggers.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb 0b53c1096a Always use 'this.' when accessing fields
Ensure that `this.` is used consistently when accessing class
fields.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb eeebd51f57 Use consistent class design
Update all classes so that inner classes are always last. Also
ensure that utility classes are always final and have a private
constructor and make exceptions final whenever possible.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb 04a8c285df Fix annotation styling issues
Update all annotations so that each is on its own line and
consistently use the short form (i.e. don't use `value=`) when
possible.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb e9d1b39aff Apply consistent copyright header
Add copyright header to `package-info.java` files and fix a few
malformed headers on existing java files.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb c3a17dfd47 Ensure all files end with a newline
Update all files to ensure that they always end with a new line.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb e0480f75ac Fix javadoc checkstyle issues
Fix checkstyle violations for javadoc.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Rossen Stoyanchev 7ccd2b024d Refine logging for async requests
Issue: SPR-16898
2018-06-25 14:42:29 -03:00
Rossen Stoyanchev 900bc8a2e3 Logging improvements for WebFlux
Issue: SPR-16898
2018-06-22 22:44:24 -04:00
Rossen Stoyanchev 69d8f9d3ab Option to disable logging request details
Issue: SPR-16898
2018-06-19 16:53:37 -04:00
Rossen Stoyanchev 28a5c3009e Improve DEBUG/TRACE logging for Spring MVC
Issue: SPR-16898
2018-06-18 18:33:11 -04:00
Rossen Stoyanchev 58cce615f5 MvcUriComponentsBuilder is aware of path prefixes
Issue: SPR-16336
2018-06-14 22:11:53 -04:00
Rossen Stoyanchev e6fef9555d Check all HandlerMapping beans for named mappings
Related to (but not required by) SPR-16336.
2018-06-14 22:07:06 -04:00
Rossen Stoyanchev dad9ed83b7 Polish MvcUriComponentsBuilder 2018-06-14 22:07:06 -04:00
Juergen Hoeller 9c36b53833 Upgrade to JAXB 2.3.0.1, Aalto XML 1.1, Rome 1.10 2018-06-11 22:01:51 +02:00
Brian Clozel 417354da8a Remove dependency management noise from POMs
Prior to this commit, the generated POMs for Spring Framework modules
would contain unneeded/harmful information from the Spring Framework
build:

1. The BOM imports applied to each module by the dependency
management plugin, for example for Netty or Reactor Netty.
Spring should not export that opinion to its POMs.

2. The exclusion of "org.slf4:jcl-over-slf4j" from *all* dependencies,
which made the POMs much larger than necessary and suggested to
developers that they should exclude it as well when using all those
listed dependencies. In fact, only Apache Tiles currently brings that
transitively.

This commit removes that information from the POMs.
The dependencyManagement Gradle plugin is disabled for POM generation
and we manually resolve the dependency versions during the generation
phase.
The Gradle build is streamlined to exclude "org.slf4:jcl-over-slf4j"
only when necessary.

Issue: SPR-16893
2018-06-11 15:57:54 +02:00
Rossen Stoyanchev 86c861516d Accept Predicate instead of HandlerTypePredicate
Issue: SPR-16336
2018-06-08 15:32:07 -04:00
Sebastien Deleuze ac37b678a3 Remove JSONP support
CORS is now widely supported and should be used instead for cross-domain
requests.

Issue: SPR-16914
2018-06-08 12:15:48 +02:00
Rossen Stoyanchev 19dc981685 Path prefixes for groups of controllers
Issue: SPR-16336
2018-06-07 18:18:42 -04:00
Rossen Stoyanchev 3acb96efd0 CachingResourceResolver varies by known codings only
Issue: SPR-16381
2018-06-04 23:30:35 -04:00
Juergen Hoeller 356bfe6e2e Upgrade to Joda-Time 2.10 2018-05-31 23:35:15 +02:00
Juergen Hoeller f3e860e8f1 Resource handler tests expect status 404 for directory in jar file
Issue: SPR-16832
2018-05-30 00:31:35 +02:00
Juergen Hoeller 69f14a2038 ClassPathResource.isReadable() checks InputStream (for jar directories)
Resource.isReadable() is defined to semantically imply exists() now.

Issue: SPR-16832
2018-05-29 21:47:33 +02:00
Juergen Hoeller 8593fec22c Avoid ConstantConditions warnings suppression (plus related polishing)
Issue: SPR-15756
2018-05-29 21:47:10 +02:00
Juergen Hoeller 836a09d5c0 Upgrade to Woodstox 5.1, XMLUnit 2.6, Gson 2.8.5 2018-05-25 00:18:06 +02:00
Rossen Stoyanchev 85e8634810 Properly initialize URI/Matrix vars w/ urlDecode=false
Issue: SPR-16867
2018-05-24 15:08:39 -04:00
Rossen Stoyanchev b472d192f4 Improve support for caching encoded resources
The key in CachingResourceResolver now includes the "Accept-Encoding"
request header cleaned to exclude "*", "identity", and parameters, and
also sorted alphabetically.

For encoded resources the response now includes a response header with
"Vary: Accept-Encoding".

Issue: SPR-16381
2018-05-23 09:17:21 -04:00
Rossen Stoyanchev 9274de390a Polish resource handling tests 2018-05-23 09:17:21 -04:00
Rossen Stoyanchev f121aa5e31 Immutable Resource[Resolver|Transformer]Chains
Issue: SPR-16862
2018-05-23 09:17:21 -04:00
Rossen Stoyanchev 5207672b3f Configurable support for static resource encodings
The new EncodedResourceResolver is a generalized version of
GzipResourceResolver that can be configured to support different
content codings, by "br" and "gzip".

GzipResourceResolver is now deprecated.

Issue: SPR-16381
2018-05-23 09:17:21 -04:00
Juergen Hoeller 285eb94a03 Upgrade to Hibernate Validator 6.0.10 2018-05-18 22:22:12 +02:00
Rossen Stoyanchev 395792b302 Produces media types cleared prior to error handling
Issue: SPR-16318
2018-05-14 23:16:36 -04:00
Rossen Stoyanchev 6cf6d8834c List OPTIONS in OPTIONS responses for @RequestMapping
Issue: SPR-16513
2018-05-14 09:05:03 -04:00
Rossen Stoyanchev 4da43de7e1 Remove individual detection of forwarded headers
This commit removes all places where forwarded headers are checked
implicitly, on an ad-hoc basis.

ForwardedHeaderFilter is expected to be used instead providing
centralized control over using or discarding such headers.

Issue: SPR-16668
2018-05-11 09:31:39 -04:00
Rossen Stoyanchev 1aadf2c3a6 Refine compareTo for param and header conditions
Issue: SPR-16674
2018-05-08 18:12:51 -04:00
Juergen Hoeller c238fb441b Polishing
(cherry picked from commit 2da02cc)
2018-05-08 00:58:58 +02:00
Juergen Hoeller a200df6c8d Explicit coverage of root vs cause exception matching in MVC ref docs
Issue: SPR-16743
2018-05-07 22:30:26 +02:00
Juergen Hoeller 53aa9cc4cd Upgrade to Servlet API 4.0.1 (aligned with Tomcat 9 and Undertow 2)
Issue: SPR-16470
2018-05-07 14:17:28 +02:00
nkjackzhang 321d7b0b06 Put CacheControl.empty() in else part.
Make sure the constructor of `CacheControl` being invoked only once.
2018-05-07 13:13:44 +02:00
Juergen Hoeller d0bd57b100 Polishing
(cherry picked from commit 0795ae5)
2018-05-05 17:04:24 +02:00
Juergen Hoeller c9f488363d Fine-tuned assertions and related polishing 2018-05-05 14:39:43 +02:00
Juergen Hoeller 7b894fe73b ResponseEntityExceptionHandler rethrows unknown exception (for further processing in DispatcherServlet's HandlerExceptionResolver chain)
Issue: SPR-16743
2018-05-05 12:46:58 +02:00
Johnny Lim fb898e1727 Remove inconsistent spaces 2018-05-05 11:07:35 +02:00
Johnny Lim 6519e7b22a Polish 2018-04-27 14:06:48 -04:00
Rossen Stoyanchev de18d96413 Validate contextPath in RedirectView
Issue: SPR-16752
2018-04-23 15:26:18 -04:00
Brian Clozel e9a8a5065b Disable HTTP Range support for InputStreamResource
Prior to this commit, the `AbstractMessageConverterMethodProcessor`
would fail to convert `InputStreamResource` to `ResourceRegion` as
expected, since the content length cannot be read without consuming the
stream. This is enforced by the `HttpRange` class.

Now the method processor would still try to output HTTP range response
headers to provide range support information. This step is using the
resource content length and reads the input stream, leading to
exceptions such as "IllegalStateException: InputStream has already been
read".

This commit improves the return type detection and excludes early
`InputStreamResource` return types. With those types, HTTP range support
is now completely disabled.

Issue: SPR-16754
2018-04-23 18:39:05 +02:00
sdeleuze 1d6540b1c2 Enable KotlinScriptTemplateTests after KT-18833 fix 2018-04-23 14:49:22 +02:00
Juergen Hoeller 0754833b37 Local XMLUnit dependency declarations with consistent version 2.5.1 2018-04-14 21:03:20 +02:00
Juergen Hoeller 7ee6130680 Revised reference example for linkable controller method signature
Issue: SPR-16710
2018-04-12 14:45:11 +02:00
Juergen Hoeller f28a5d0cf7 Proper exception for controller method return types that do not work with MvcUriComponentsBuilder (e.g. final classes)
Includes direct use of ControllerMethodInvocationInterceptor for return type Object, avoiding the attempt to generate an Object subclass.

Issue: SPR-16710
2018-04-11 16:05:54 +02:00
Sam Brannen aba882af4c Clean up warnings in spring-webmvc 2018-04-04 14:04:54 +02:00
Sam Brannen 2c648379ab Delete dead code in spring-webmvc 2018-04-04 14:01:24 +02:00
Juergen Hoeller aa0face9a1 Upgrade to RxJava 1.3.8 and Rhino 1.7.9 2018-04-03 15:18:25 +02:00
Juergen Hoeller 8a9321652d Refined javadoc 2018-03-31 23:07:08 +02:00
Juergen Hoeller 912c270f2b Polishing 2018-03-31 17:49:21 +02:00
Juergen Hoeller 6393e5ce0c Consistent Ordered.LOWEST_PRECEDENCE declarations for default order 2018-03-31 00:20:44 +02:00
Rossen Stoyanchev b1048975d2 Minor updates based on PR#1058
The original repo no longer exists:
https://github.com/spring-projects/spring-framework/pull/1058
2018-03-30 13:36:20 -04:00
Rossen Stoyanchev 240d6f52c9 Replaces rather than prepend contextPath
Issue: SPR-16650
2018-03-29 18:17:29 -04:00
Rossen Stoyanchev dd96c873e3 Improve docs on forwarded headers
Issue: SPR-16660
2018-03-29 16:11:01 -04:00
Juergen Hoeller b165475eb6 Polishing 2018-03-29 16:05:52 +02:00
Juergen Hoeller 695bf2961f Consistent trace logging in PathResourceResolver
Issue: SPR-16616
2018-03-29 16:04:33 +02:00
igor-suhorukov e6020ed377 avoid unnecessary autoboxing 2018-03-28 23:48:12 +02:00
igor-suhorukov 4aae6a6dda Use Map.forEach instead of manual Map.Entry iteration wherever possible SPR-16646 2018-03-28 01:09:03 +02:00
Rossen Stoyanchev f3994467c4 Refine ContentNegotiationStrategy contract
Consistently return "*/*" if no media types were requested rather than
an empty list. Existing code has to check for both in any case to see
if nothing was requested.

Issue: SPR-16624
2018-03-27 16:54:19 -04:00
Juergen Hoeller 9a27bc9b3e Upgrade to Jackson 2.9.5 and Hibernate Validator 6.0.9 2018-03-27 17:33:34 +02:00
Juergen Hoeller 98ad23bef8 Consistent logging of encoded path evaluation failure
Issue: SPR-16616
2018-03-27 17:04:59 +02:00
Juergen Hoeller e3d0ef6015 Use Map.forEach instead of manual Map.Entry iteration wherever possible
Issue: SPR-16646
2018-03-27 00:38:32 +02:00
Juergen Hoeller f59ea610df Simplified separator check within isInvalidEncodedPath
Issue: SPR-16616
2018-03-27 00:23:36 +02:00
Juergen Hoeller c1405ef140 Polishing 2018-03-21 16:12:42 +01:00
Juergen Hoeller 91b803a231 Consistent encoded path evaluation in ResourceHttpRequestHandler and co
Issue: SPR-16616
2018-03-21 12:02:13 +01:00
Rossen Stoyanchev 0e28bee0f1 Clean duplicate separators in resource URLs
Most Servlet containers do this anyway, but not all, and not
consistently for forward and backslashes.

Issue: SPR-16616
2018-03-19 17:16:03 -04:00
Juergen Hoeller f8588e364a AcceptHeaderLocaleResolver keeps language match among supported locales
Issue: SPR-16599
2018-03-16 14:17:50 +01:00
Juergen Hoeller 2096676b3f Upgrade to Apache Johnzon 1.1.7 and JRuby 9.1.16 2018-03-15 15:43:45 +01:00
Juergen Hoeller 58011f71e9 Consistent assertions for template method result vs servlet registration 2018-03-14 18:55:50 +01:00
Juergen Hoeller 2a3f90dc7b Upgrade to Hibernate ORM 5.2.15 and Hibernate Validator 6.0.8 2018-03-09 09:40:12 +01:00
Brian Clozel ed7684d2b2 Don't implicitly check preconditions on PUT requests
Prior to this commit, the `HttpEntityMethodProcessor` would check HTTP
conditions on non-safe requests (i.e. not GET/HEAD). This would prevent
Controllers from returning `ResponseEntity` containing response headers
with updated values of `"Last-Modified"` or `ETag` once the resource has
been updated.

This commit avoids those checks for non GET/HEAD requests - this code
can still be leveraged from Controllers themselves using
`ServletWebRequest::checkNotModified` methods.

Issue: SPR-15780
2018-03-08 19:43:01 +01:00
Juergen Hoeller 139dc1d373 Polishing (collapsed if checks, consistent downcasts, refined javadoc) 2018-03-08 18:11:57 +01:00
igor-suhorukov 0f7485b01d Polish: reorder the modifiers to comply with the Java Language Specification. 2018-03-08 17:57:47 +01:00
Rossen Stoyanchev 568c93457a Improve ResponseBodyEmitter error handling
After send error, ignore calls to complete or completeWithError by the
application in the same thread (e.g. try-catch block), to avoid a
competing with an error callback from servlet container during which
the same action is taken.

Issue: SPR-16548
2018-03-07 15:25:31 -05:00
Rossen Stoyanchev e20652009d Improve docs on SseEmitter onComplete/onError
Issue: SPR-16548
2018-03-07 14:59:18 -05:00
Juergen Hoeller 934a995acb Strong recommendation for OpenPDF 1.0.5 instead of iText 2.1.7
Issue: SPR-16107

(cherry picked from commit b70d400)
2018-03-07 17:08:45 +01:00
Juergen Hoeller f57fcdee3c Polishing 2018-03-07 15:49:58 +01:00
Patrick0308 6f4d25a6e6 Polish "Use Java 8 forEach method on Map" 2018-03-07 15:39:58 +01:00
Brian Clozel 6d26e61ac7 Guard against invalid paths in ResourceUrlProvider
This commit makes sure that no `StringIndexOutOfBoundsException` is
thrown when `getForRequestUrl` is called with a URL that's shorter than
the expected context path.

Issue: SPR-16526
2018-03-05 15:26:56 +01:00
Juergen Hoeller cd4f0935c5 Revised deprecation markers 2018-03-01 23:43:06 +01:00
Rossen Stoyanchev 36cfdf68b1 Correct log level
Issue: SPR-16528
2018-03-01 15:52:59 -05:00
Juergen Hoeller bfddbbe731 Polishing 2018-03-01 01:39:06 +01:00
igor-suhorukov 83300c4b27 Polish: follow naming convention 2018-03-01 00:22:29 +01:00
igor-suhorukov 8080f56db8 Polish: "@Override" should be used on overriding and implementing methods 2018-03-01 00:15:18 +01:00
igor-suhorukov d1ccecd021 Polish: to get rid unnecessary array creation 2018-02-27 23:37:54 +01:00
igor-suhorukov 7bce04c06c Polish: combine catches block with same body 2018-02-27 12:51:28 +01:00
igor-suhorukov 49fd724d8f Polish: String function use should be optimized for single characters 2018-02-25 20:48:47 +01:00
Juergen Hoeller a5cbf5fe24 Consistent use of Collection.toArray with zero-sized array argument
Includes consistent use of ClassUtils.toClassArray (as non-null variant)

Issue: SPR-16523
2018-02-22 11:29:46 +01:00
Juergen Hoeller 0de36d2883 Consistent HttpMethod identity comparisons 2018-02-18 22:01:22 +01:00
Juergen Hoeller d7cab23e6d Consistent use of StringUtils.toStringArray
(cherry picked from commit 6d11b40)
2018-02-16 20:49:17 +01:00
Juergen Hoeller 8d3264f680 Prefer List.sort(Comparator) over Collections.sort(List, Comparator) 2018-02-16 10:23:18 +01:00
igor-suhorukov 2be4985b8f Polish: anonymous inner classes containing only one method should become lambdas,
use getOrDefault instead of ternary operator
2018-02-16 09:38:19 +01:00
Rossen Stoyanchev 9801afb85d Fix compile error
Update places that call UriUtils to catch the right exception that is
now raised as a result of using Charet.forName.
2018-02-15 15:59:21 -05:00
Juergen Hoeller cd8a1bdb8b AcceptHeaderLocaleContextResolver leniently handles invalid header value
Also falls back to language-only match among its supported locales now.

Issue: SPR-16500
Issue: SPR-16457
2018-02-15 13:14:49 +01:00
Juergen Hoeller 6d7573262e FormTag skips rendering of hidden fields in case of empty Map
Issue: SPR-16498
2018-02-14 17:41:45 +01:00
Juergen Hoeller 3b810f3544 Consistent Class array vs vararg declarations (and related polishing) 2018-02-14 14:44:00 +01:00
Juergen Hoeller 46cbdff5c3 Consistent ControllerAdvice applicability against user-declared class
Issue: SPR-16496
2018-02-14 14:41:16 +01:00
igor-suhorukov 711b0f50f2 Polish: replace the synchronized class "Stack" by an unsynchronized one such as "Deque". 2018-02-11 21:15:46 +01:00
igor-suhorukov 0ee505b73e Polish: assertion arguments should be passed in the correct order,
use assertNull instead of assertEquals(null, value),
declare delta as double value in assertEquals
2018-02-10 17:17:28 +01:00
Stephane Nicoll 991eb4858e Update copyright header 2018-02-09 10:16:58 +01:00
igor-suhorukov e381514b07 Collection.isEmpty() should be used to test for emptiness
Closes gh-1670
2018-02-09 10:11:44 +01:00
igor-suhorukov 4c888d0f32 Polish
Closes gh-1669
2018-02-09 10:10:05 +01:00
Juergen Hoeller 4dc964544f AcceptHeaderLocaleResolver falls back to language-only match among its supported locales
Issue: SPR-16457
2018-02-02 12:41:59 +01:00
Juergen Hoeller 7f96827ade Polishing 2018-02-02 11:34:03 +01:00
Juergen Hoeller 4a1cc9ced7 Constructor-provided field values get recorded for failed binding result
Also, TypeMismatchExceptions get registered via BindingErrorProcessor.

Issue: SPR-16449
2018-02-02 11:33:56 +01:00
Rossen Stoyanchev 0ded239453 [doc] Update Spring MVC exception handling content
Issue: SPR-16394
2018-01-31 23:03:10 -05:00
sdeleuze b6c78452b2 Update and improve script templating documentation
Issue: SPR-16447
2018-01-31 17:57:41 +01:00
Juergen Hoeller 8d42888476 Upgrade to RxJava 1.3.5 and WebJars Locator 0.35
Includes Rhino 1.7.8 and JRuby 9.1.15 as well.
2018-01-29 21:31:27 +01:00
Rossen Stoyanchev 97894a1c22 Improve logging dependencies for tests 2018-01-23 10:42:41 -05:00
Juergen Hoeller 91e6274b7d Upgrade to Apache HttpClient 4.5.5 and Tomcat 8.5.27 2018-01-22 22:11:00 +01:00
Juergen Hoeller 61579ffe7b Polishing 2018-01-22 21:34:44 +01:00
Juergen Hoeller 9d0e62ef68 Javadoc format and related polishing 2018-01-22 11:43:21 +01:00
Johnny Lim 36d42bcda4 Polish InterceptorRegistration
Closes gh-1647
2018-01-20 10:15:12 +01:00
Juergen Hoeller ea5f8f5a7c Consistently handle NoClassDefFoundError in BeanUtils and related places
Issue: SPR-16369
2018-01-17 20:24:57 +01:00
Juergen Hoeller 121f9e3734 BridgeMethodResolver properly resolves all declared interfaces
Issue: SPR-16288
2018-01-11 10:18:27 +01:00
Rossen Stoyanchev ea73ec5c41 ResourceUrlProvider handles sanitizes double slashes
Issue: SPR-16296
2018-01-10 17:48:43 -05:00
Rossen Stoyanchev 846636f2b9 Polish 2018-01-08 17:35:30 -05:00
Aleksey Voronenkov cb8ad46564 Overloaded methods in InterceptorRegistration
Issue: SPR-16324
2018-01-08 17:31:06 -05:00
Rossen Stoyanchev 446e7ed25c Links from @RequestMapping to reference docs
Issue: SPR-16266
2018-01-08 09:29:52 -05:00
Juergen Hoeller 7a55d932f9 Build against OpenPDF 1.0.5 instead of outdated iText 2.1.7
Issue: SPR-16352
2018-01-08 00:26:10 +01:00
Juergen Hoeller 9d27e86951 Upgrade to Hibernate Validator 6.0.7 2017-12-21 17:00:06 +01:00
Juergen Hoeller 3a51b5a9d2 Upgrade to Hibernate Validator 6.0.6 2017-12-15 15:58:12 +01:00
Rossen Stoyanchev fda08852ba Take content-type from ResponseEntity unconditionally
From #9a894a we began using the content-type from the ResponseEntity
but cross-checking it still against the requested content type.

Arguably there isn't any purpose in cross-checking. The only possible
outcomes are: a) it's compatible or b) it's not, which would result in
406 (NOT_ACCEPTABLE). As we've been given explicitly the media type to
use, it makes little sense to send 406, ignoring the wish to use that
content type.

Issue: SPR-16251
2017-12-02 00:43:43 -05:00
Rossen Stoyanchev 3650ecc3bb Polish 2017-11-28 22:16:07 -05:00
Juergen Hoeller a8323f6a27 Latest dependency updates (OkHttp 3.9.1, JRuby 9.1.14, Rome 1.9) 2017-11-26 16:03:48 +01:00
sdeleuze 652e5c5584 Disable CORS credentials by default
Access-Control-Allow-Credentials CORS header, used to
allow cookies with CORS requests, is not set to true
anymore by default when enabling CORS with
@CrossOrigin or global CORS configuration in order to
provide a more secured default CORS configuration.

The related allowCredentials property now requires to
be set to true explicitly in order to support cookies
with CORS requests.

Issue: SPR-16130
2017-11-22 22:46:44 +01:00
Juergen Hoeller 0cc644f61f Polishing 2017-11-21 16:34:08 +01:00
Rossen Stoyanchev bc8e525e60 Add shared instance of ReactiveAdapterRegistry
Issue: SPR-16218
2017-11-20 17:02:22 -05:00
Juergen Hoeller 40dacd3c1c Polishing 2017-11-20 22:27:07 +01:00
Juergen Hoeller 27bbb73583 Expose all HttpResource header values (even if commonly not multi-value)
Issue: SPR-14264
2017-11-20 15:31:34 +01:00
Juergen Hoeller 20fcefc647 ResourceHttpRequestHandler uses EmbeddedValueResolverAware 2017-11-19 21:16:29 +01:00
Juergen Hoeller 14a7da8183 Upgrade to Hibernate Validator 6.0.5 2017-11-19 21:16:10 +01:00
Rossen Stoyanchev b1b5353b7f Revise charset by location support for static resources 2017-11-17 12:33:58 -05:00
Juergen Hoeller cc7c90cca5 Polishing 2017-11-16 10:52:56 +01:00
Juergen Hoeller 7af9910244 Restored support for placeholders in mvc namespace resource locations
With the recent charset mechanism in place, we cannot rely on implicit placeholder parsing during String-to-Resource conversion anymore.
2017-11-16 09:36:23 +01:00
Juergen Hoeller 7697b398d5 Polishing 2017-11-14 17:11:16 +01:00
Juergen Hoeller b5cedd43eb Consistent and efficient access to BeanDefinition argument values
Issue: SPR-16192
2017-11-13 21:51:11 +01:00
Juergen Hoeller 72f20e8d4f Polishing 2017-11-11 00:37:50 +01:00
Rossen Stoyanchev 9a894ab61e Use ResponseEntity Content-Type as producible media type
Issue: SPR-16172
2017-11-10 15:05:03 -05:00
Juergen Hoeller 780993ce75 Polishing 2017-11-10 20:21:26 +01:00
Rossen Stoyanchev 369d33c3d0 Support charset config by (static) resource location
This commit adds support for configuring static resource locations
with a charset to be applied to relative paths.
2017-11-09 13:15:06 -05:00
Juergen Hoeller a75dd2dd3e Consistent getDateHeader checks in spring-webmvc unit tests
Issue: SPR-16160
2017-11-05 17:00:18 +01:00
Juergen Hoeller e5c8dc0d65 MessageSource.getMessage returns null default message as-is (again)
Issue: SPR-16127
2017-10-31 11:06:42 +01:00
Juergen Hoeller 9bab7a2708 Upgrade to Java Activation Framework 1.2 for test runtime
Includes upgrade to Hibernate Validator 6.0.4 (where applicable)

Issue: SPR-16115
2017-10-25 19:18:10 +02:00
Juergen Hoeller 9efdadcdca Compatibility with OpenPDF as alternative to iText 2.1.7
Issue: SPR-16107
2017-10-24 13:14:53 +02:00
Rossen Stoyanchev 1cc5afe24b Fix lines over 120 characters
https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-Code-Style#line-wrapping
2017-10-20 16:42:26 -04:00
Juergen Hoeller e17ad551f3 Latest dependency updates (RxJava 1.3.3, Hibernate ORM 5.2.12, Hibernate Validator 5.4.2 & 6.0.3) 2017-10-20 16:16:06 +02:00
Juergen Hoeller d1fac36e3e SchedulingConfigurer and JmsListenerConfigurer respect @Order
Issue: SPR-16090
2017-10-20 16:10:12 +02:00
Rossen Stoyanchev ab92754a2e @MatrixVariable resolvers for WebFlux
The information was already parsed and available in a request attribute
but until now there were no argument resolvers to expose it.

Issue: SPR-16005
2017-10-19 21:01:38 -04:00
Juergen Hoeller 9df6f3e6b8 Polishing 2017-10-18 20:21:49 +02:00
Juergen Hoeller bec1fc1852 ModelAttributeMethodProcessor detects re-enabled binding declaration
Issue: SPR-16083
2017-10-18 12:31:22 +02:00
Rossen Stoyanchev 32d78e60b6 Update information on WebApplicationContext hierarchy
Issue: SPR-16041
2017-10-17 21:49:57 -04:00
Rossen Stoyanchev cd634633d8 MockMvc re-uses response instance on async dispatch
MockMvc now properly detects the presence of an AsyncContext and
re-uses the response instance used to start it.

This commit also includes a minor fix in
ResponseBodyEmitterReturnValueHandler to ensure it does not disable
ETag related content buffering for reactive return values that do not
result in streaming (e.g. single value or collections).

Issue: SPR-16067
2017-10-17 16:57:35 -04:00
Juergen Hoeller 3d1023be8c Polishing 2017-10-17 11:56:30 +02:00
Juergen Hoeller ef6aef9107 Allow PropertyEditor conversion as fallback for enums
Issue: SPR-16082
2017-10-17 11:49:54 +02:00
Juergen Hoeller c3cf0840b7 Polishing 2017-10-16 15:34:39 +02:00
Juergen Hoeller d611486978 HandlerMappingIntrospector.getHandlerMappings() never returns null 2017-10-12 15:31:11 +02:00
Brian Clozel 1356bd4359 Share HandlerInterceptors in ResourceHandlerMapping
Prior to this commit, the Resource `HandlerMapping` configured by
`@EnableSpringMvc` would be set up with only one custom
`HandlerInterceptor` (the one exposing the `ResourceUrlProvider` for
resolving URLs of static resources).

This behavior is not consistent with the rest of the default
configuration which leverages the interceptors configured against the
interceptor registry (with possible user-provided ones).

This change allows to register interceptors against resource handling;
this can be useful for metrics purposes, as in
spring-projects/spring-boot#10335.

Issue: SPR-16034
2017-10-10 22:57:52 +02:00
Juergen Hoeller 699fde91db Polishing 2017-10-10 22:18:09 +02:00
Juergen Hoeller cc6e6490d2 Polishing 2017-10-09 13:59:29 +02:00
Rossen Stoyanchev eea8ee2165 Migrate JSP tag library appendix reference to Javadoc.
The Javadoc on tag classes now has all the information including a
list of all tags at the package level, HTML tables listing tag
attributes in each tag class, and class level description that is
as good or in many cases better than what was in the reference.

Issue: SPR-16045
2017-10-05 14:25:23 -04:00
nkjackzhang b11d1f5f9b Fix typos in spring-mvc.xsd
Closes gh-1535
2017-09-29 14:36:26 +02:00
Rossen Stoyanchev 0f1bd49f6d HandlerMappingIntrospector is a bean 2017-09-27 21:28:49 -04: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
Juergen Hoeller a1a7c62127 Consistent configurer access in WebMvcConfigurationSupport
Issue: SPR-16017

(cherry picked from commit 40ba95f)
2017-09-27 19:52:48 +02:00
Juergen Hoeller efce7902c4 Polishing 2017-09-27 01:34:11 +02:00
Juergen Hoeller 9ff4c0bff8 DispatcherServlet.getHandlerMappings() accessor declared as final
Issue: SPR-15934
2017-09-25 22:45:04 +02:00
Rossen Stoyanchev 2da2c17fbb WebFlux supporst HttpHeaders return values
Issue: SPR-16006
2017-09-25 16:09:28 -04: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
Rossen Stoyanchev 132022861e Remove ResourceServlet deprecated in 4.3.x
Issue: SPR-15984
2017-09-22 20:14:06 -04:00
Rossen Stoyanchev 816a58fcf9 RouterFunctionMapping provides getter for RouterFunction
Issue: SPR-15991
2017-09-22 15:15:41 -04: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
Rossen Stoyanchev 819ca0dbd4 Expose getters for the configured HandlerMapping's
Issue: SPR-15934
2017-09-21 09:46:26 -04:00
Juergen Hoeller 5bdcb895c0 HttpEntityMethodProcessor lets entity headers override existing headers (again)
Issue: SPR-15952
2017-09-19 13:47:30 +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
Grant Hutchins f4ef5cd451 Fix broken RequestMappingHandlerAdapter setter
RequestMappingHandlerAdapter.setReactiveRegistry() doesn't actually set the value appropriately.

FYI: I found this using lgtm.com

https://lgtm.com/projects/g/spring-projects/spring-framework/alerts/?mode=list
2017-09-12 15:04:33 -04:00
Juergen Hoeller b122bc6dcc Upgrade to Hibernate Validator 6.0.2
Includes latest dependency updates (Netty 4.1.15, Undertow 1.4.19)

Issue: SPR-15808
2017-08-29 15:04:17 +02:00
Brian Clozel 582014e944 Support HTTP range requests in MVC Controllers
Prior to this commit, HTTP Range requests were only supported by the
ResourceHttpRequestHandler when serving static resources.

This commit improves the `HttpEntityMethodProcessor` and
the `RequestResponseBodyMethodProcessor`. They now extract
`ResourceRegion`s from the `Resource` instance returned by the
Controller and let the Resource-related message converters
handle the writing of the resource (including partial writes).

Controller methods can now handle Range requests for
return types that extend Resource or HttpEntity:

    @RequestMapping("/example/video.mp4")
    public Resource handler() { }

    @RequestMapping("/example/video.mp4")
    public HttpEntity<Resource> handler() { }

Issue: SPR-15789, SPR-13834
2017-08-24 20:50:37 +02:00
Brian Clozel 397fd24849 Revert "Leverage Kotlin plugin dependency management"
This reverts commit 3e2f6c848a.
2017-08-22 21:29:39 +02:00
Sebastien Deleuze 3e2f6c848a Leverage Kotlin plugin dependency management 2017-08-22 17:35:57 +02:00
Brian Clozel cc3d7d2d48 Apply dependency management to selected modules
This commit applies the Dependency Management Plugin to modules that
require it; right now Spring Framework is importing BOMs for Netty and
Reactor dependencies only.

Instead of applying those BOMs to all modules, they're applied only
where they're needed.

Issue: SPR-15885
2017-08-21 14:42:03 +02:00
Brian Clozel 2eeb428e95 Move modules to independent build files
The main `build.gradle` file contains now only the common build
infrastructure; all module-specific build configurations have
been moved to their own build file.

Issue: SPR-15885
2017-08-21 14:41:55 +02:00
Juergen Hoeller fac1f236c3 Upgrade to Servlet API 4.0 for MVC and merge EhCache 3 tests into spring-context-support
Includes general streamlining of dependency declarations with reduced version variables, direct use of EclipseLink 2.7 and its implicit JPA 2.2 dependency in spring-orm, mixed use of Hibernate 5.2.10 and 5.1.10 for integration tests, as well as an upgrade to Jetty 9.4.7 RC0 and a downgrade to Groovy 2.4.12 (since Groovy 2.5 won't be final in time for Spring Framework 5.0).

Issue: SPR-15879
Issue: SPR-15880
2017-08-21 01:34:11 +02:00
Stephane Nicoll f6e7fef236 Polish 2017-08-19 10:50:41 +02:00
Juergen Hoeller 9aa369f402 Data class construction supports field default/marker parameters
Issue: SPR-15871
2017-08-18 17:59:06 +02:00
Sebastien Deleuze 73cf07e9a4 Fix overridden methods nullability
Issue: SPR-15869
2017-08-17 15:02:59 +02:00
Juergen Hoeller 61cdc842e0 BindingResult support for constructor argument mismatch on immutable data object
Issue: SPR-15542
2017-08-17 11:02:40 +02:00
Juergen Hoeller b8f5e97ae5 Properly retrieve and expose HttpServletResponse for async requests
Issue: SPR-15867
2017-08-17 08:52:05 +02:00
Sebastien Deleuze f57e5584af Add a reference to KT-18833 in JDK 9 ignored tests 2017-08-14 11:47:08 +02:00
Rossen Stoyanchev b1440b6816 Remove ParsingPathMatcher
Now that we also have RequestPath and PathContainer with the latter as
the required input, the ParsingPathMatcher adapter can be removed.
2017-08-01 13:35:21 +02:00
Rossen Stoyanchev 4fc0ce1206 Properly detect null value params in params conditions
Issue: SPR-15831
2017-08-01 13:01:09 +02:00
Rossen Stoyanchev bb684ce60b Improve decoding support for multipart filename
StandardMultipartHttpServletRequest now properly decodes RFC-5987
encoded filenames (i.e. filename*) by delegating to ContentDisposition
and also support RFC-2047 syntax through javax.mail MimeUtility.

Issue: SPR-15205
2017-07-20 14:26:20 +02:00
Sebastien Deleuze fa4d139684 Support instantiating Kotlin classes with optional parameters
This commit updates BeanUtils class in order to add Kotlin optional
parameters with default values support to the immutable data classes
support introduced by SPR-15199.

Issue: SPR-15673
2017-07-20 10:44:06 +02:00
Juergen Hoeller ac1d3b22c9 Polishing 2017-07-19 22:22:27 +02:00
Juergen Hoeller 46eba3dbfa Nullability fine-tuning around declaration inconsistencies
Issue: SPR-15720
Issue: SPR-15792
2017-07-19 22:22:20 +02:00
Juergen Hoeller 9fc4fb10b0 Nullability fine-tuning around bean properties
Issue: SPR-15720
Issue: SPR-15792
2017-07-19 11:43:58 +02:00
Sebastien Deleuze fb4ddb0746 Make getters and setters null-safety consistent
This commit ensure that null-safety is consistent between
getters and setters in order to be able to provide beans
with properties with a common type when type safety is
taken in account like with Kotlin.

It also add a few missing property level @Nullable
annotations.

Issue: SPR-15792
2017-07-19 09:07:56 +02:00
Juergen Hoeller c292a89b24 Http(Async)Client not actually nullable, plus MethodInterceptor nullability
Issue: SPR-15720
2017-07-19 00:15:37 +02:00
Rossen Stoyanchev 70252a7335 Add tests for SPR-15777 2017-07-17 08:35:58 +02:00
Rossen Stoyanchev b0fc83ee05 Polish CssLinkResourceTransformer 2017-07-17 08:16:25 +02:00
Rossen Stoyanchev e37af83459 Improve docs on on use of urlDecode=false
Issue: SPR-15643
2017-07-14 16:52:02 +02:00
Rossen Stoyanchev 134ceac58e Set all strategies in CNM factory bean
ContentNegotiationManagerFactoryBean now provides an option to
explicitly set the strategies to use vs customizing a fixed
list of default strategies.

Issue: SPR-11114
2017-07-11 21:00:57 +02:00
Juergen Hoeller 00f4c36d7a Nullability fine-tuning (RequestContext, LocaleResolver)
Includes page-level JSTL time zone support for JSP tags.

Issue: SPR-15720
Issue: SPR-15746
2017-07-07 18:46:19 +02:00
Sebastien Deleuze 1fa8410995 Leverage RFC_1123_DATE_TIME formatter in tests
Issue: SPR-15661
2017-07-02 22:33:43 +02:00
Juergen Hoeller cc74a2891a @Nullable all the way: null-safety at field level
This commits extends nullability declarations to the field level, formalizing the interaction between methods and their underlying fields and therefore avoiding any nullability mismatch.

Issue: SPR-15720
2017-06-30 01:54:16 +02:00
Rossen Stoyanchev 67330dfc23 Expose mapped handler as an exchange attribute
Issue: SPR-15564
2017-06-29 13:18:39 -04:00
Juergen Hoeller 98642c7e29 Consistent ScriptTemplateView locale resolution via request
Issue: SPR-15064
2017-06-26 23:28:49 +02:00
Rossen Stoyanchev 5b8f7f503f Deprecate adapter classes for async interceptors 2017-06-26 15:34:51 -04:00
Rossen Stoyanchev eb0479dee8 Polish 2017-06-26 14:50:11 -04:00
Violeta Georgieva e0678ba583 Add onError callback to DeferredResult
Issue: SPR-15614
2017-06-26 14:12:56 -04:00
Juergen Hoeller 098ff6f0f8 Compatibility with JDK 9 release candidate build (175)
Includes upgrade to Objenesis 2.6, Gradle 3.5.1, RxJava 2.1.1, JSON Binding API 1.0 final.

Issue: SPR-15686
Issue: SPR-15600
2017-06-26 18:58:59 +02:00
Juergen Hoeller 155a1c6c71 AsyncHandlerInterceptor.afterConcurrentHandlingStarted declared as default method
Issue: SPR-15702
2017-06-26 18:58:39 +02:00
Rossen Stoyanchev 782c595cf7 Polish 2017-06-22 18:33:27 -04:00
Eko Kurniawan Khannedy ac68cc35c2 Ordered WebMvcConfigurer interceptor registrations
Issue: SPR-15620
2017-06-22 18:33:27 -04:00
Sebastien Deleuze d5f9ad03a7 Support ScriptEngine#eval(String, Bindings) in ScriptTemplateView
Supporting ScriptEngine#eval(String, Bindings) when no render function
is specified allows to support use cases where script templates are
simply evaluating a script expression with an even more simplified
configuration.

This improvement also makes it possible to use script engines that
do not implement Invocable.

Issue: SPR-15115
2017-06-16 10:38:59 +02:00
Rossen Stoyanchev ef3e309c12 Adjust timeout in Spring MVC for reactive streaming
Issue: SPR-15669
2017-06-15 13:11:59 -04:00
Juergen Hoeller 72a8868f84 FreeMarker macros based on HTML output format (requires FreeMarker 2.3.24+)
Issue: SPR-14740
2017-06-13 14:21:09 +02:00
Juergen Hoeller 779deb0fa7 Cleanup of duplicate semicolons
Issue: SPR-15654
2017-06-13 11:38:05 +02:00
Juergen Hoeller 7dd8dc62a5 Fixes for ignored tests after last week's nullability commit
Issue: SPR-15540
2017-06-13 11:37:58 +02:00
Stephane Nicoll 58242f2249 Polish 2017-06-13 10:13:14 +02:00
Stephane Nicoll fc64b8040f Polish "Replace relevant code with lambda"
Closes gh-1454
2017-06-13 09:42:20 +02:00
diguage 4b1478d830 Replace relevant code with lambda
See gh-1454
2017-06-13 08:55:38 +02:00
Juergen Hoeller 14161d1dbf Protected applyLifecycleMethods in UrlBasedViewResolver
Issue: SPR-15219
2017-06-12 15:48:59 +02:00
Stephane Nicoll 451b419624 Polish "Use Map#forEach instead of Map#entrySet#forEach"
Closes gh-1449
2017-06-12 14:37:33 +02:00
diguage 2efa06237a Use Map#forEach instead of Map#entrySet#forEach
See gh-1449
2017-06-12 14:37:33 +02:00
diguage c1d44d9a34 Use the diamond syntax
Closes gh-1450
2017-06-12 09:19:06 +02:00
Stephane Nicoll 27aabb15f9 Polish "Refact iterator of Map with Java 8 forEach"
Closes gh-1451
2017-06-12 08:53:56 +02:00
diguage dab7a7f0ee Refact iterator of Map with Java 8 forEach
See gh-1451
2017-06-12 08:11:32 +02:00
Sebastien Deleuze 86580b2358 Polishing 2017-06-09 01:49:56 +03:00
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 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
Rossen Stoyanchev 4d52590964 Improve docs on forwarded headers
Issue: SPR-15612
2017-06-01 22:36:12 -04: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
QBNemo 94618c4f37 Polish doc on RequestMappingHandlerMapping#isHandler 2017-05-31 21:25:44 -04:00
Sebastien Deleuze 1f28825f9d Add more @Nullable parameters based on null usage
Issue: SPR-15540
2017-05-31 21:42:23 +02: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 87598f48e4 Introduce null-safety of Spring Framework API
This commit introduces 2 new @Nullable and @NonNullApi
annotations that leverage JSR 305 (dormant but available via
Findbugs jsr305 dependency and already used by libraries
like OkHttp) meta-annotations to specify explicitly
null-safety of Spring Framework parameters and return values.

In order to avoid adding too much annotations, the
default is set at package level with @NonNullApi and
@Nullable annotations are added when needed at parameter or
return value level. These annotations are intended to be used
on Spring Framework itself but also by other Spring projects.

@Nullable annotations have been introduced based on Javadoc
and search of patterns like "return null;". It is expected that
nullability of Spring Framework API will be polished with
complementary commits.

In practice, this will make the whole Spring Framework API
null-safe for Kotlin projects (when KT-10942 will be fixed)
since Kotlin will be able to leverage these annotations to
know if a parameter or a return value is nullable or not. But
this is also useful for Java developers as well since IntelliJ
IDEA, for example, also understands these annotations to
generate warnings when unsafe nullable usages are detected.

Issue: SPR-15540
2017-05-27 08:57:01 +02:00
skarafaz 3d290165fb Find exact matches in WebJarsResourceResolver
Prior to this commit, resolving resources from webjars using the
`WebJarAssetLocator.getFullPath` could lead to multiple candidates,
since this method is trying to find *any* resource matching that path
under the given webjar location.

This commit replaces that call with
`WebJarAssetLocator.getFullPathExact`, which avoids those multiple
matches and only resolves resources if the given path is exact.

Issue: SPR-15526
(cherry picked from commit e2aa117ff9)
2017-05-24 10:46:35 +02:00
Juergen Hoeller 0183576215 Polishing 2017-05-23 22:05:22 +02:00
Juergen Hoeller db69a082d9 Avoid java.util.Optional signatures for simple field access
Issue: SPR-15576
2017-05-23 22:05:15 +02:00
Rossen Stoyanchev 48a5938cd4 Polish 2017-05-19 16:59:36 -04:00
Martin Švorc bf83e4e861 Use original query string of forwarded request
Prior to this commit, the AbstractFlashMapManager has used the
originating URI but the query string of the forwarded request. That
resulted to FlashMap not being matched even when both originating
URI and query string matched the FlashMap attributes. The originating
query string is now used to match the forwarded request.

Issue: SPR-15505
2017-05-19 16:49:29 -04:00
Juergen Hoeller 92f18a4985 HandlerExecutionChain.toString() includes reliable interceptor number
Issue: SPR-15525
2017-05-07 21:05:16 +02:00
Juergen Hoeller 25aef4d3cc ResponseStatusException reason is optional (with lazily constructed message)
Issue: SPR-15524
2017-05-06 12:53:03 +02:00
Juergen Hoeller 39f8bd663e Polishing 2017-05-05 23:19:08 +02:00
Juergen Hoeller 4fdd85324d Aligned exception handling in Jackson and JAXB codecs
Issue: SPR-15516
2017-05-05 23:19:01 +02:00
Rossen Stoyanchev 4d962a1793 Remove HttpStatus from HttpMessageConversionException
HttpMessageConverter's are client and server and arguably shouldn't
contain a server-side concept such a response status.

The status field is recent, it was added to differentiate 400 vs 500
errors with Jackson 2.9+ but there is no need for it since the same
distinction is reflected in raising an HttpMessageNotReadableException
vs a general HttpMessageConversionException.

Issue: SPR-15516
2017-05-05 14:44:08 -04:00
Stephane Nicoll 1b9e12f52f Polish "Use Java 8 forEach method on Map"
Closes gh-1404
2017-04-28 11:07:08 +02:00
Jon Borenstein 13dc0cd828 Use Java 8 forEach method on Map 2017-04-28 11:07:08 +02:00
Juergen Hoeller 1ea54eb2c6 GenericFilterBean lazily initializes its default environment
Alignment with HttpServletBean; consistent use of EnvironmentCapable.

Issue: SPR-15469
2017-04-27 21:38:30 +02:00
Juergen Hoeller c668d9a473 Polishing 2017-04-26 18:20:19 +02:00
Rossen Stoyanchev abe3cfd8de Flux<String> + "application/json" renders as text
Spring MVC now treats Flux<String> + "application/json" as (serialized)
text to be written directly to the response as is. This is consistent
with the rendering of String + "application/json".

Issue: SPR-15456
2017-04-25 12:47:13 -04:00
Rossen Stoyanchev c67b0d6507 Properly support ResponseEntity<Flux<T>> in Spring MVC
Issue: SPR-15478
2017-04-25 12:03:59 -04:00
Stephane Nicoll 239b7086c6 Polish "Reuse constant in DispatcherServlet"
Closes gh-1398
2017-04-25 10:06:51 +02:00
QBNemo 224e369484 Reuse constant in DispatcherServlet
See gh-1398
2017-04-25 09:51:38 +02:00
Rossen Stoyanchev 7df3d68b2a Replace WebMvcConfigurerAdapter with default methods
Issue: SPR-15465
2017-04-20 16:14:13 -04:00
Rossen Stoyanchev d3b178a812 Consistent JSON array result for Flux<T> in Spring MVC
Issue: SPR-15456
2017-04-20 09:19:38 -04:00
Rossen Stoyanchev a93698487e Fix handling for ResponseEntity<Flux<T>> in Spring MVC
Issue: SPR-15456
2017-04-20 09:19:38 -04:00
Rossen Stoyanchev 633544943f Polish 2017-04-20 09:19:38 -04:00
Juergen Hoeller 0b118322b0 Polishing 2017-04-13 16:17:05 +02:00
Rossen Stoyanchev 46a790f9be Remove EmitterProcessor#connect (dropped upstream) 2017-04-13 09:58:48 -04:00
Juergen Hoeller cec36fe784 Configurable locale/timezone attribute name for SessionLocaleResolver
Issue: SPR-15450
2017-04-13 13:07:54 +02:00
Rossen Stoyanchev 043c7070e3 Polish default content type change
Issue: SPR-15367
2017-04-11 11:54:40 -04:00
Ryan O'Meara 4a890226ea Support for multiple default content types
Enhance FixedContentNegotiationStrategy and places where it is exposed
to also accept a list of media types.

Issue: SPR-15367
2017-04-11 11:54:40 -04:00
Rossen Stoyanchev 5d92a85fcb Mock Servlet request/response support Accept-Language
Issue: SPR-15209
2017-04-11 07:19:07 -04:00
Juergen Hoeller 15b5dd9f12 Polishing 2017-04-10 15:36:45 +02:00
Juergen Hoeller cf306037b5 Support for JSON Binding API (JSON-B)
Issue: SPR-14923
2017-04-10 15:36:38 +02:00
Juergen Hoeller ea98ee820a AcceptHeaderLocaleResolver returns default locale in case of no supported locale found
Issue: SPR-15426
2017-04-10 15:36:13 +02:00
Juergen Hoeller 5986f881d0 HandlerMethod evaluates ResponseStatus annotation for early caching
Issue: SPR-15227
2017-04-08 15:56:05 +02:00
Dávid Karnok 68cc57549a Restore correct order of terminated flag check 2017-04-06 14:01:49 -04:00
Rossen Stoyanchev 43eea41dd6 Polish 2017-04-06 12:54:49 -04:00
akarnokd 3312ef0aa2 Refactor AbstractEmitterSubscriber 2017-04-06 12:54:49 -04:00
Sebastien Deleuze ed8565894a Return 5xx HTTP status for invalid target types with Jackson
InvalidDefinitionException has been introduced in Jackson 2.9 to be
able to differentiate invalid data sent from the client (should still
generate a 4xx HTTP status code) from server side errors like beans with
no default constructor (should generate a 5xx HTTP status code).

Issue: SPR-14925
2017-04-05 11:31:26 +02:00
Rossen Stoyanchev f293c4d84b Doc use of reactive types in Spring MVC controllers
Issue: SPR-15365
2017-04-04 17:32:24 -04:00
Rossen Stoyanchev de6f34893a Restore ResponseBodyEmitterReturnValueHandler constructor
Issue: SPR-15410
2017-04-04 14:23:47 -04:00
Rossen Stoyanchev d9221fb87d Async boundary for Spring MVC reactive type streaming
Issue: SPR-15365
2017-04-04 11:22:40 -04:00
Juergen Hoeller f29ffb37f7 Compatibility with Servlet 4.0 b05
Issue: SPR-15379
2017-04-04 17:17:23 +02:00
Rossen Stoyanchev 62c1e44db2 Spring MVC supports reactive return values
This commit adds support for reactive library types to be returned
directly from controller methods adapting them either to a
ResponseBodyEmitter (streaming) or DeferredResult (non-streaming).

The reactive libraries supported are the ones that can adapted to a
Reactive Streams Publisher through the ReactiveAdapterRegistry.

Issue: SPR-15365
2017-04-03 09:01:49 -04:00
Rossen Stoyanchev ae1ed16cb8 Async return values refactoring in Spring MVC
Revise Javadoc on AsyncHandlerMethodReturnValueHandler to clarify its
main purpose is to prioritze custom async return value handlers ahead
of built-in ones. Also replace the interface from built-in handlers
which are prioritized already.

Remove DeferredResultAdapter and ResponseBodyEmitterAdapter --
introduced in 4.3 for custom async return value handling, since for
5.0 we will add built-in support for reactive types and the value of
these contracts becomes very marginal.

Issue: SPR-15365
2017-04-03 09:01:49 -04:00
Brian Clozel 2baceac5ff Resolve ResourceUrlProvider from current request
This commit changes `ResourceTransformerSupport` to look for the
`ResourceUrlProvider` in the current request if none is configured on
the resource transformer itself.

Issue: SPR-15369
2017-03-24 16:09:14 +01:00
Brian Clozel fdd503152d VersionResourceResolver should delegate to the chain
Prior to this commit, the `VersionResourceResolver` implementations of
`resolveUrlPathInternal` would delegate to the resolver chain but would
never use the give result if the current request didn't match a
configured version strategy pattern.

This is a problem if the resolver supposed to resolve the resource path
is configured after a `VersionResourceResolver` in the resolver chain;
this means that other resolver never gets to participate in the result
of the chain.

Issue: SPR-15372
2017-03-24 14:14:43 +01:00
Juergen Hoeller 65ba865d70 Support for populating model attributes through data class constructors
Includes a new overloaded ModelAndView constructor with an HttpStatus argument, as well as a HandlerMethodArgumentResolverSupport refactoring (revised checkParameterType signature, actually implementing the HandlerMethodArgumentResolver interface).

Issue: SPR-15199
2017-03-24 12:15:45 +01:00
Juergen Hoeller 5ea4abdb85 Revised supportedMethods null handling in HttpRequestMethodNotSupportedException
Issue: SPR-15377
2017-03-24 11:06:47 +01:00
Arjen Poutsma a287e67992 Introduce 'useRegisteredExtensionsOnly' property in classes using MediaTypeFactory
This commit introduces a `useRegisteredExtensionsOnly` property that
indicates whether classes that use the `MediaTypeFactory` for supplying
default media types can do so.

 - In classes that were introduced in Spring 5.0, the
 `useRegisteredExtensionsOnly` property takes the place of the
 `useJaf` property that was removed in 0aaa652
 - In classes that existed before Spring 5.0, the
 `useRegisteredExtensionsOnly` property is added in addition to the
 deprecated `useJaf`, the latter delegating to the former, but with
 flipped behavior.

Issue: SPR-14908
2017-03-23 17:16:46 +01:00
Juergen Hoeller e892e02f41 Polishing 2017-03-21 17:44:47 +01:00
Arjen Poutsma d414718467 Update MockServletContext to MediaTypeFactory
This commit changes the `MockServletContext.getMimeType` method to use
`MediaTypeFactory` instead of JAF. It also adds a `addMimeType(String,
MediaType)` method to customize the mime types returned from said
method.

Issue: SPR-14908
2017-03-21 09:39:22 -04:00
Arjen Poutsma 0aaa6528dc Remove JAF references
This commit updates the main code base to conform to the dropped JAF
dependency in MediaTypeFactory. Specifically, it

 - Removes JAF detection (JAF_PRESENT constants)
 - Deprecated useJaf properties, with no direct replacement.
 - Updated docs to remove JAF references, in favor of MediaTypeFactory.

Issue: SPR-14908
2017-03-21 09:11:10 -04:00
Sebastien Deleuze 9963c4a495 Fix Kotlin warnings 2017-03-10 10:35:30 +01:00
Rossen Stoyanchev 84d11e9c17 Update Javadoc on exception resolvers in MVC config
Issue: SPR-15324
2017-03-07 20:50:10 -05:00
stonio 7d062df992 Use String#isEmpty()
Closes gh-1335
2017-02-22 11:55:17 +01:00
Juergen Hoeller d2cc97af47 Polishing 2017-02-21 22:41:40 +01:00
Rossen Stoyanchev 5ea5f81c00 Support flash attributes on ResponseEntity redirect
Issue: SPR-15176
2017-02-21 14:44:17 -05:00
Juergen Hoeller 1ddf8ec625 Polishing 2017-02-21 00:04:08 +01:00
Juergen Hoeller 73493bc490 Revised imports in tests (org.jetbrains.annotations.NotNull etc) 2017-02-20 23:00:22 +01:00
Juergen Hoeller fc11321010 ServletRequestMethodArgumentResolver passes null references through (again)
Issue: SPR-15214
2017-02-20 23:00:07 +01:00
Juergen Hoeller 1ee0626c94 Polishing 2017-02-17 21:06:58 +01:00
Juergen Hoeller 199aa776c9 Support for Servlet 4.0 (PushBuilder argument, MockServletContext)
Issue: SPR-12674
2017-02-13 15:06:59 +01:00
Juergen Hoeller d44325ec91 Defensively ignore multipart parsing failure in case of error dispatch
Issue: SPR-15231
2017-02-13 15:06:52 +01:00
Brian Clozel 47ac3379ea Do not use ParsingPathMatcher by default in Spring MVC 2017-02-09 11:21:33 +01:00
Andy Clement f58ffad939 Introduce PathPatternParser for optimized path matching
This commit introduces a PathPatternParser which parses request pattern
strings into PathPattern objects which can then be used to fast
match incoming string paths. The parser and matching supports the syntax
as described in SPR-14544. The code is optimized around the common usages
of request patterns and is designed to create very little transient
garbage when matching.

Issue: SPR-14544
2017-02-09 11:09:38 +01:00
Sebastien Deleuze 02c4aff4ce Upgrade to Kotlin 1.1.0-beta-38 2017-02-03 00:33:04 +01:00
Juergen Hoeller acf511ac0e Polishing 2017-02-02 20:11:06 +01:00
Juergen Hoeller e44533f4c2 ServletRequestMethodArgumentResolver validates argument type match
Issue: SPR-15214
2017-02-02 19:59:30 +01:00
Juergen Hoeller f84907a1fc Polishing 2017-01-31 12:00:13 +01:00
Juergen Hoeller 1b2dc3638f Revisit Assert to avoid single-arg assert methods (with refined messages)
Issue: SPR-15196
2017-01-30 22:15:55 +01:00
Sebastien Deleuze 7ff257c0ea Prevent NPE in ScriptTemplateView when no view is found
Issue: SPR-15064
2017-01-26 15:29:55 +01:00
Sebastien Deleuze 2a5d1b086f Fix Spring MVC ScriptTemplateView locale support
The locale should be set in resolveViewName() instead of
createView() in order to be taken in account with cached
views.

Issue: SPR-15064
2017-01-26 14:33:21 +01:00
Sebastien Deleuze 2d95199466 Support i18n and nested templates in ScriptTemplateView
This commit changes the 3rd parameter passed to the rendering
function from String url to RenderingContext renderingContext.

RenderingContext contains 4 properties:
 - ApplicationContext applicationContext
 - Locale locale
 - Function<String, String> templateLoader
 - String url

Issue: SPR-15064
2017-01-25 17:23:20 +01:00
Juergen Hoeller e8776f80da Revised CookieLocaleResolver parse exception handling
Issue: SPR-15182
2017-01-24 17:48:54 +01:00
Juergen Hoeller ecc22f7179 DispatcherServet.checkMultipart considers MultipartException cause as well
Issue: SPR-15178
2017-01-23 21:22:38 +01:00
Sebastien Deleuze 35d5dca571 Upgrade to Kotlin 1.1-beta-17
Spring Framework 5.0 now requires Kotlin 1.1+. This commit
also re-enable Kotlin JSR 223 unit tests.

Issue: SPR-15100
2017-01-19 13:09:38 +01:00
Juergen Hoeller af7289d6e9 Clarify WebContentInterceptor path mappings and efficiently match them
Issue: SPR-15096
(cherry picked from commit 801b93a)
2017-01-17 21:28:10 +01:00
Juergen Hoeller ac6aa53031 Drop outdated BeanFactoryLocator / beanRefContext.xml mechanism
Issue: SPR-15154
2017-01-17 13:58:37 +01:00
Juergen Hoeller 743ce2cda6 Polishing 2017-01-12 23:30:38 +01:00
Mark Hobson 2ce2f7d9a5 Introduce mime/media types for application/rss+xml
Issue: SPR-15109
2017-01-07 17:13:32 +00:00
Sam Brannen 9ed66bf2eb Clean up warnings across code base 2017-01-07 01:54:38 +01:00
Philippe Marschall 19e77cd140 Remove use of Boolean constructors
Codacy warns us that there are several references to Boolean
constructors in the tests. Direct usage of the Boolean constructor is
discouraged and even deprecated in Java 9 [1]. Boolean constructor use
can easily be replaced with the constant instances.

This commit contains the following changes:

 - replace references to Boolean constructors with boolean constants in
   JSP tag tests
 - update the copyright year where necessary
 - BooleanComparatorTests is intentionally left unchanged as it should
   also work with the non-constant instances correctly

 [1] http://download.java.net/java/jdk9/docs/api/java/lang/Boolean.html#Boolean-boolean-

Issue: SPR-15076
2017-01-04 09:31:14 +01:00
Sebastien Deleuze e78ea34711 Temporary rollback to Kotlin 1.0.6
Kotlin 1.1-M04 has a bug that makes the generated bytecode
not compatible with Kotlin 1.0.x. This bug should be fixed in
Kotlin 1.1-M05.
2017-01-03 18:07:49 +01:00
Sebastien Deleuze badde3a479 Add Kotlin based ScriptTemplateView rendering test
Kotlin JSR 223 support currently requires kotlin-script-util
dependency (jcabi-aether, maven-core and aether-api can be
excluded since they are only used for live import of
dependencies and bring a lot of JARs in the classpath) and a
/META-INF/services/javax.script.ScriptEngineFactory
file specifying the ScriptEngineFactory to use, in that case
org.jetbrains.kotlin.script.jsr223.KotlinJsr223JvmLocalScriptEngineFactory.

Issue: SPR-15059
2017-01-01 14:17:39 +01:00
Juergen Hoeller 4c005e6336 ResolvableType-based matching respects generic factory method return type
Includes consistent use of ResolvableType.resolve() wherever applicable.

Issue: SPR-15011
2016-12-17 23:10:48 +01:00
Rossen Stoyanchev 6119415427 Support for "request parameters"
ServerWebExchange now provides access to "requestParams" as a
MulitValueMap with query parameters and form data combined.

The combined map is then used for the params condition of
@RequestMapping purposes () and also for @RequestParam arguments.

Issue: SPR-15000
2016-12-15 14:24:39 -05:00
Juergen Hoeller 8a7467020f Polishing 2016-12-15 15:44:16 +01:00
Juergen Hoeller 5169c51a6c Polishing 2016-12-13 13:02:23 +01:00
Juergen Hoeller eeb7ae537f @RequestBody supports java.util.Optional
Issue: SPR-15007
2016-12-13 13:00:03 +01:00
Brian Clozel 52f664139f Improve VersionResourceResolve javadoc
The `pathPatterns` args are relative to the patterns configured for the
resource handler.

Issue: SPR-14817
2016-12-13 10:43:27 +01:00
Brian Clozel 933f1501e8 Do not include URL hash in resource paths
When getting the lookup path of a resource, both query params and hashes
should be removed from the request path.

This commit fixes the public path resolution for paths like
`/resources/main.svg#icon-hamburgermenu`.

Issue: SPR-14928
2016-12-12 15:14:50 +01:00
Brian Clozel 17089d607f Allow RedirectAttributes on ExceptionHandlers
Prior to this commit, `@ExceptionHandler` methods could not be injected
with `RedirectAttributes` arguments. This would make it impossible to
handle an error by redirecting to another view and add flashmap
attributes, to be included in the model when the next view is called.

Here is an example:

```
@ExceptionHandler(MyException.class)
public String handleException(MyException ex, RedirectAttributes
    redirectAttributes) {

  redirectAttributes.addFlashAttribute("errorMessage",
      "This is an error message");
  return "redirect:/";
}
```

This commit adds a new `RedirectAttributesMethodArgumentResolver`
instance in the list of pre-configured `HandlerMethodArgumentResolver`
in `ExceptionHandlerExceptionResolver`.

Issue: SPR-14651
2016-12-09 23:41:22 +01:00
bedrin 8315a4033f Add consumes attribute to @GetMapping
Issue: SPR-14988
2016-12-07 17:45:43 -05:00
Nicklas Holm 9a7028ad0d Javadoc fix 2016-12-02 16:22:25 -05:00
Rossen Stoyanchev 93cfc791a7 Spring MVC supports ResponseStatusException
The ResponseStatusException is now also supported in Spring MVC
through the ResponseStatusExceptionResolver.

Issue: SPR-14895
2016-11-29 15:18:02 -05:00
Sebastien Deleuze a143b57d4b Polish Kotlin nullable support
This commit polishes Kotlin nullable support by reusing
MethodParameter#isOptional() instead of adding a new
MethodParameter#isNullable() method, adds
Kotlin tests and introduces Spring Web Reactive
support.

Issue: SPR-14165
2016-11-24 18:28:50 +01:00
Raman Gupta fada91e538 Treat Kotlin nullable as non-required
Where `isOptional` is used, also check for `isNullable` i.e.
values are not considered required if they are Kotlin nullables:
- spring-messaging: named value method arguments
- spring-web: named value method arguments
- spring-webmvc: request parts

This means that Kotlin client code no longer has to explicity specify
"required=false" for Kotlin nullables -- this information is inferred
automatically by the framework.

Issue: SPR-14165
2016-11-24 17:18:55 +01:00
Juergen Hoeller 0b71e3640b Avoid defensive check for Servlet 3.1 setContentLengthLong method
Issue: SPR-14467
2016-11-24 15:30:10 +01:00
Brian Clozel b10045dc0e Do not execute ResourceUrlEncodingFilter only once per request
In case the filter is also registered to the ERROR dispatcher, the
following happens:
* the filter is executed once for the regular execution
* the filter should be executed a second time when dispatched to error

Since the filter is a `OncePerRequestFilter`, the filter is only
executed once and won't be executed when handling the error.

This can lead to situations like spring-projects/spring-boot#7348

This commit makes this filter a simple `GenericFilterBean`.

Issue: SPR-14891
2016-11-24 09:56:33 +01:00
Rossen Stoyanchev 9bcc7c3b06 Remove ResourceServlet (deprecated in 4.3) 2016-11-23 21:24:07 -05:00
Juergen Hoeller 96bfc14dba No warn logging for propagated original exception
Issue: SPR-14907
2016-11-22 16:00:23 +01:00
Juergen Hoeller 85b0ce1ef7 Avoid defensive checks against java.time API
Issue: SPR-13188
2016-11-22 14:55:03 +01:00
Juergen Hoeller da63898d5f Polishing 2016-11-21 17:36:04 +01:00
Brian Clozel cb44f2746e Prevent resource transformation of gzipped CSS files
When resolved through the `GzipResourceResolver`, CSS files can be
resolved as their pre-gzipped variant, if a ".gz" file is present in the
configured resource locations.

Such resources are gzipped and thus should not be transformed by
`CssLinkResourceTransformer`s, since rewriting those would need to
uncompress/transform/recompress. This would lead to poorer performances
than resolving plain resources and delegating compression to the
container.

This commit checks for `GzippedResource` instances in
`CssLinkResourceTransformer` and avoids processing them.

Issue: SPR-14773
2016-11-16 10:26:09 +01:00
Juergen Hoeller 84d3808b3b Upgrade to Mockito 2.2
Issue: SPR-14880
2016-11-03 22:53:35 +01:00
Rossen Stoyanchev 6c098b3301 Polish 2016-11-02 09:53:27 +02:00
Juergen Hoeller ac80ac6f8b Consistent instanceof/casting of Class references 2016-10-30 21:40:27 +01:00
Juergen Hoeller 7627c38695 Exceptions thrown from @ExceptionHandler methods logged at warn level (instead of debug)
Issue: SPR-14861
2016-10-30 21:40:20 +01:00
Rossen Stoyanchev afcc120b97 Better handling for AsyncRequestTimeoutException
Avoid call to sendError when response is committed and log a short
error message instead.

Issue: SPR-14739
2016-10-28 17:45:30 +03:00
Juergen Hoeller b7d3a969a4 ResourceHttpRequestHandler initializes PathExtensionContentNegotiationStrategy in afterPropertiesSet
Issue: SPR-14851
2016-10-28 15:13:37 +02:00
Rossen Stoyanchev efe3996cf9 Respect ModelAndView.status in @ExceptionHandler
Issue: SPR-14006
2016-10-24 16:04:49 +01:00
Juergen Hoeller 3726c6f18d Polishing 2016-10-21 12:26:27 +02:00
Rossen Stoyanchev 72397e3505 Polish
Issue: SPR-14798
2016-10-19 16:30:52 -04:00
Sebastien Deleuze 50f2cda009 Better encapsulation for CORS default permit configuration
This commit also improves CorsRegistration Javadoc.

Issue: SPR-14798
2016-10-19 15:31:22 -04:00
Rossen Stoyanchev 71201e1a43 Relax generic type detection for ResponseEntity
Before this change the getHttpEntityType method in
HttpEntityMethodProcessor raised an ISE if the generic type cannot be
detected. That made sense for resolving a controller method argument
where the target body type is crucial. However for a return value
the generic type should not be required since we either have an
actual body or no body at all in which case it doesn't even matter.

This change relaxes the checks and defaults to Object.class for the
ResponseEntity generic type on the return value side.

Issue: SPR-14799
2016-10-13 13:31:47 -04:00
Rossen Stoyanchev bd69390c0f Fix failing test 2016-10-12 08:56:52 -04:00
Sam Brannen 580b8b92f8 Fix punctuation in Javadoc 2016-10-11 20:40:12 +02:00
Brian Clozel 679b661e19 Resolve absolute resource links in ResourceTransformers
Prior to this commit, `ResourceTransformer` implementations would
resolve internal links to other resources: both relative and absolute
request paths.
For relative request paths, those transformers would call
`ResourceTransformerSupport.resolveUrlPath` with the resource path,
as provided in the original file. This can cause problems when a
`CachingResourceResolver` is configured in the resolver chain, because
this resolver is caching resources, deriving the cache key from the
given resource path — this can cause collisions for cases like this:

    resources/
    |--foo/
    |  |--foo.css (imports style.css)
    |  |--style.css
    |--bar/
    |  |--bar.css (imports style.css)
    |  |--style.css

The first "style.css" resolved resource is then cached and will be given
to any request asking for "style.css".

To avoid those issues, this commit improves the `ResourceTransformer`
implementations to calculate the absolute request path before asking the
chain to resolve the resource URL, thus avoiding duplications.
The resource chain will be then asked to resolve "/foo/style/css" or
"/bar/style.css".

Issue: SPR-14597
2016-10-11 17:45:34 +02:00
Rossen Stoyanchev 33c48e7a17 Polish reactive CORS support 2016-10-10 18:00:11 -04:00
Brian Clozel ee17f56626 Fix missing ETag/LastModified headers in responses
Prior to this commit, the `HttpEntityMethodProcessor` would avoid
writing ETag/Last-Modified response headers before calling
`ServletWebRequest` to process conditional requests. This was done to
avoid duplicate response header values due to headers being already
written to the underlying servlet response.

This is still necessary for GET/HEAD requests, since this is properly
handled by `ServletWebRequest` for those cases. But
`HttpEntityMethodProcessor` should not make that decision for
PUT/PATCH/POST responses since developers are adding response headers on
purpose and should be in control of the situation — whereas
`ServletWebRequest` does not write those headers in those cases.

Issue: SPR-14767
2016-10-04 12:08:09 +02:00
Juergen Hoeller fb7ae010c8 Avoid unnecessary generics on emptyMap/Set/List 2016-09-26 18:04:49 +02:00
Brian Clozel e3da8b5e9c Polish ResourceHttpRequestHandler, ResourceEncoder 2016-09-20 16:49:14 +02:00
Juergen Hoeller f532de92aa Revised checkResource implementation
Issue: SPR-14729
(cherry picked from commit ca17edd)
2016-09-18 21:33:52 +02:00
Brian Clozel 9e5435e6f2 Check template availability in ScriptTemplateView
This commit overrides the `checkResource` implementation in
`ScriptTemplateView` in order to check if the template file resource is
available and if the resolver can then proceed with rendering the
template.

Issue: SPR-14729
Cherry-picked from: 66b370e10
2016-09-17 22:30:54 +02:00
Sam Brannen 8f62b63663 Introduce 'value' alias for @Bean's 'name' attribute
In order to simplify configuration for use cases involving @Bean where
only a bean name or aliases are supplied as an attribute, this commit
introduces a new 'value' attribute that is an @AliasFor 'name' in @Bean.

Issue: SPR-14728
2016-09-17 16:16:06 +02:00