Commit Graph

1996 Commits

Author SHA1 Message Date
Rossen Stoyanchev 4d7418841c AbstractHandlerMethodMapping refactoring
Remove convenience Map that is to avoid. The only downside is that
getHandlerMethods requires a transformation but that should not be used frequently.

See gh-22961
2020-07-09 12:11:15 +03:00
Rossen Stoyanchev 0584c289ab Support for direct path lookups in WebFlux
Closes gh-22961
2020-07-09 11:26:04 +03:00
Rossen Stoyanchev 0e4e25d227 Updates to CORS patterns contribution
Closes gh-25016
2020-07-08 13:18:46 +03:00
Rossen Stoyanchev 1181bb1852 Rename originsPattern to originPatterns
See gh-25016
2020-07-08 13:18:46 +03:00
Ruslan Akhundov 8632118e8d CorsConfiguration now supports pattern based origins.
Closes gh-24763
2020-07-08 13:18:46 +03:00
Rossen Stoyanchev 34607d96f1 PathPattern caching with HandlerMappingIntrospector
This commit evolves the solution from M1 by parsing and caching patterns with the
target HandlerMapping's PathPatternParser. This makes it unnecessary for callers to
be aware of pattern parsing.

Closes gh-25312
2020-07-06 15:31:35 +03:00
Arjen Poutsma 20254f02d2 Polishing 2020-06-30 11:33:12 +02:00
Arjen Poutsma e9d9de5f99 RouterFunction honors PathPatternParser in config
This commit introduces a way to change the PathPatternParser used in
PathPredicates, by way of a ChangePathPatternParserVisitor. This
visitor is used by both WebFluxConfigurationSupport and
WebMvcConfigurationSupport to make sure the configured parser is used.

Closes gh-23236
2020-06-30 11:33:12 +02:00
Sam Brannen b33d2fe683 Clean up warnings in Gradle build, polishing, etc. 2020-06-24 15:02:24 +02:00
May bc9b9bc477
Replace cascading if statements with switch statement
Closes gh-25308
2020-06-24 13:54:17 +02:00
Rossen Stoyanchev 57f868fcbd Direct matches by URL path work again
This commit fixes a recent regression as a result of 5225a57411
with the determination of non-pattern vs pattern URLs. That in turn affects the ability to perform
direct matches by URL path.

There is also a fix in PathPattern to recognize "catch-all" patterns as pattern syntax.

See gh-24945
2020-06-24 08:07:40 +01:00
Rossen Stoyanchev 22bf62def1 Replace remaining use of deprecated Processors in tests
See gh-25085
2020-06-23 20:29:35 +01:00
Juergen Hoeller d0209e5f1f Nullability refinements and related polishing 2020-06-23 16:55:09 +02:00
Rossen Stoyanchev 837dfe285a Set PathPatternParser in RouterFunctionMapping
See gh-24945
2020-06-23 15:18:25 +01:00
Sam Brannen 9d5881e0ad Suppress warnings, remove unused code, etc. 2020-06-20 17:15:35 +02:00
Rossen Stoyanchev b1da89344f MatchableHandlerMapping is backwards compatible 2020-06-19 22:01:51 +01:00
Sébastien Deleuze 1e501f2583 Provide a flag to disable XML support
This commit introduces a spring.xml.ignore system property
which when set to true avoid initializing XML infrastructure.

A typical use case is optimizing GraalVM native image footprint
for applications not using XML. In order to be effective, those
classes should be initialized at build time:

- org.springframework.util.DefaultPropertiesPersister
- org.springframework.core.io.support.PropertiesLoaderUtils
- org.springframework.web.servlet.function.support.RouterFunctionMapping
- org.springframework.web.client.RestTemplate
- org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver
- org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport
- org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter
- org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter
- org.springframework.http.codec.support.BaseDefaultCodecs
- org.springframework.beans.PropertyEditorRegistrySupport

Closes gh-25151
2020-06-19 09:42:12 +02:00
Marten Deinum bad81cef8a Align DispatcherServlet defaults for Java and XML
Prior to this commit some of the default strategies defined
for the DispatcherServlet weren't included in the default
configuration for both Java and XML configuration.

The following default beans have been added to the configuration
with the name as expected by the DispatcherServlet:

- org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver
- org.springframework.web.servlet.theme.FixedThemeResolver
- org.springframework.web.servlet.support.SessionFlashMapManager
- org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator

Closes gh-25209
2020-06-18 12:30:49 +02:00
Juergen Hoeller d36407d585 Deprecate rarely used bean definition variants
Closes gh-24875
2020-06-17 10:59:55 +02:00
Сергей Цыпанов 7949937655 Remove redundant assignment of default values to volatile fields 2020-06-17 10:50:51 +02:00
Sébastien Deleuze e2944c37e4 Make DispatcherServlet.properties loading lazy
With #25209, DispatcherServlet.properties loading and parsing
will be useless for most of use cases, and it requires
configuration on GraalVM native images.

The purpose of this issue to make such loading and parsing lazy,
only invoked in getDefaultStrategies() if needed.

Closes gh-25257
2020-06-16 17:25:05 +02:00
Rossen Stoyanchev b572f7618f HandlerMappings expose usesPathPatterns() method
See gh-24945
2020-06-15 15:53:40 +01:00
Rossen Stoyanchev 5225a57411 Support for parsed PathPatterns in Spring MVC
See gh-24945
2020-06-15 11:25:35 +01:00
Juergen Hoeller 1279b3b822 Merge branch '5.2.x'
# Conflicts:
#	spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java
#	spring-context-support/src/main/java/org/springframework/cache/jcache/config/AbstractJCacheConfiguration.java
2020-06-11 23:53:27 +02:00
Juergen Hoeller e46ccd74b1 Consistent abstract declaration of "Abstract" base classes
Closes gh-25240
2020-06-11 23:43:41 +02:00
Sam Brannen b0e07cc7e3 Delete dead code in spring-webmvc 2020-06-10 18:35:03 +02:00
liym@home 8fb7399a0c Upgrade to Dom4j 2.1.3 and Jaxen 1.2.0
Closes gh-25078
2020-06-10 16:38:43 +02:00
Rossen Stoyanchev 1984cfe9d7 Merge branch '5.2.x' 2020-06-08 21:20:44 +01:00
Rossen Stoyanchev a2d516d526 Replace "whitelist" with alternative words 2020-06-08 21:19:28 +01:00
Rossen Stoyanchev a7f8120164 Merge branch '5.2.x' 2020-06-03 06:14:20 +01:00
Rossen Stoyanchev 8dc8d88f88 Pre-calculated RequestMappingInfo hashcode
See gh-25143
2020-06-03 06:11:35 +01:00
Rossen Stoyanchev 1e25556049 Shared PathPatternParser instance
See gh-25143
2020-06-03 05:58:10 +01:00
Juergen Hoeller e955e52f2f Refactor method name dispatching to switch statements
Closes gh-25163
2020-05-29 23:07:25 +02:00
Rossen Stoyanchev 1175b7eb52 Deprecate HandlerInterceptorAdapter
Closes gh-25147
2020-05-29 18:09:24 +01:00
Rossen Stoyanchev d706899b7e Merge branch '5.2.x' 2020-05-28 06:52:23 +01:00
Rossen Stoyanchev a92f425529 Also use constant for custom mapping condition
See gh-25143
2020-05-28 06:51:57 +01:00
Rossen Stoyanchev 90ccabd60b Merge branch '5.2.x' 2020-05-27 19:12:57 +01:00
Rossen Stoyanchev e9a9883aa9 Optimal initialization of empty request mapping conditions
Closes gh-25143
2020-05-27 18:57:02 +01:00
Brian Clozel 7c2471e3cc Polish
Closes gh-24204
2020-05-19 16:45:23 +02:00
Rohit Pandey 8da5627c6c Fix ExceptionHandlerExceptionResolver.setResponseBodyAdvice behaviour
Prior to this commit, calling the `setResponseBodyAdvice` method would
clear all existing `ResponseBodyAdvice` instances present in the list
before adding provided one.
This behavior is inconsistent with the Javadoc and other
implementations.

This brings the method in line with the existing documentation.

See gh-24204
2020-05-19 16:28:57 +02:00
Rossen Stoyanchev 23233c3041 Shared read-only instance of UrlPathHelper
In many places UrlPathHelper is created and used without any
customizations, in some cases repeatedly. This commit adds a
shared read-only UrlPathHelper instance with default settings.

See gh-25100
2020-05-19 10:34:15 +01:00
Сергей Цыпанов 703d54677e Avoid unnecessary boxing/unboxing of primitives
Closes gh-25080
2020-05-15 18:01:59 +02:00
Rossen Stoyanchev 14e249aee3 Merge branch '5.2.x' 2020-05-12 09:01:36 +01:00
Rossen Stoyanchev 7c9ad6dd08 Add deprecation notes to the WebMvc config schema
Closes gh-23915
2020-05-12 06:50:09 +01:00
Brian Clozel b883aad1f1 Use weak ETags in VersionResourceResolver
Prior to this commit, the `VersionResourceResolver` implementations
would write a strong ETag HTTP response header with the resolved version
of the resource (the actual value depending on the chosen strategy).

This approach doesn't work well when combined with HTTP compression.
Web servers disable HTTP response copression in the presence of strong
ETags since mutating the response body would break the contract.

This commit changes this semantic and ensures that weak ETags are used
instead.

Closes gh-24898
2020-05-11 21:25:54 +02:00
Rossen Stoyanchev df99889aa6 Avoided repeated creation of ReadOnlyHttpHeaders wrapper
See gh-24680
2020-05-11 08:49:28 +01:00
Rossen Stoyanchev 7f59381c7d Add support for RxJava 3
Closes gh-24170
2020-05-11 08:48:48 +01:00
Sam Brannen 12e05280ad Upgrade to AssertJ 3.16 2020-05-06 15:22:23 +02:00
Rossen Stoyanchev 66bb145247 Fix typo
See gh-23915, gh-25018
2020-05-06 06:35:43 +01:00
Rossen Stoyanchev 147b8fb755 Turn off use of path extensions by default
Closes gh-23915
2020-05-05 08:04:40 +01:00
Arjen Poutsma 8e81360eba Use pre-parsed PathContainer in WebMvc.fn
This commit makes the default ServerRequest implementation use a pre-
parsed path container, instead of parsing the path for each invocation
of pathContainer().
2020-04-29 17:17:05 +02:00
Sam Brannen c3f439417e Disable remaining JavaScript-based tests on Java 15+
This commit disables all remaining JavaScript-based tests on Java 15 or
higher since the Nashorn JavaScript engine is no longer part of the JDK.
2020-04-28 17:22:22 +02:00
Arjen Poutsma 54e6103def Add ServerRequest::multipartData in WebMvc.fn
This commit adds the multipartData method to ServerRequest in WebMvc.fn,
returning a MultiValueMap<String, Part>.

Closes gh-24909
2020-04-28 15:43:59 +02:00
Juergen Hoeller e7e230608e Upgrade to Groovy 3.0.3 (with FindBugs workaround for groovy-templates)
Closes gh-24215
2020-04-28 14:00:24 +02:00
Rossen Stoyanchev 583435d068 Consistent ordering in MethodNotAllowedException
This caused random failures in a newly added test. Also remove defensive
check in ResponseStatusExceptionResolver.

See gh-24944
2020-04-25 07:33:30 +01:00
Rossen Stoyanchev e18901d6b1 Headers support in ResponseStatusExceptionResolver
Closes gh-24944
2020-04-24 12:53:00 +01:00
Rossen Stoyanchev 8d31dcaa29 Clarification on path extension deprecations
Closes gh-24642
2020-04-20 14:43:07 +01:00
Sébastien Deleuze 884c7696ce Make it possible to run Spring MVC without kotlin-reflect
Closes gh-24828
2020-04-14 14:56:47 +02:00
Juergen Hoeller de0d06fab5 Polishing 2020-04-09 11:49:35 +02:00
Qimiao Chen fd8d11c7e3
Use single String instead of String[] for varargs argument
Closes gh-24864
2020-04-04 20:05:19 +02:00
陈其苗 13970ae528 Use autoboxing instead of explicit wrapping in tests
Closes gh-24801
2020-04-01 14:34:20 +02:00
Sam Brannen e26764d249 Remove duplicate words in documentation and polish Javadoc 2020-03-31 12:17:58 +02:00
Juergen Hoeller 910d2788e9 Polishing 2020-03-23 18:02:55 +01:00
Juergen Hoeller 1800b10717 Expose parameter annotations from interfaces across entire class hierarchy
Closes gh-24127
2020-03-23 17:57:44 +01:00
Sam Brannen 35d0b3dba9 Fix Javadoc links accidentally broken in 7b6d83a106 2020-03-16 15:43:04 +01:00
Qimiao Chen 193a76fe2a
Avoid unnecessary sorting in AbstractHandlerMethodMapping
Closes gh-24704
2020-03-16 12:38:43 +01:00
Arjen Poutsma 7c4f0318bb Improve efficiency of built RouterFunction
This commit changes the way RouterFunctions registered to the builder
are composed in both WebFlux.fn and WebMvc.fn.
Prior to this commit, all routes added to the build were composed with
`reduce`.
After this commit, all routes are stored in a special router function,
allowing for more efficient execution and smaller stack traces.

Closes gh-24652
2020-03-13 16:09:41 +01:00
Rossen Stoyanchev 7b7dfcaaed Polishing contribution
See gh-24691
2020-03-13 14:58:01 +00:00
mdindoffer c11dd4a839
Do not mention credentials as enabled by default in CorsRegistry
Credentials are not enabled by default contrary to the javadocs. 
The credentials support must be enabled via #allowCredentials.

Closes gh-24691

Co-authored-by: Martin Dindoffer <martin.dindoffer@sigp.eu>
2020-03-13 15:21:53 +01:00
Arjen Poutsma 0dc1c7eb8b Add ServerRequest::checkNotModified
This commit adds the checkNotModified method to ServerRequest in both
WebFlux.fn and WebMvc.fn. Unlike other checkNotModified methods found
in the framework, this method does not return a boolean, but rather
a response wrapped in a Mono/Optional. If the resource has
not been changed, the not-modified response can be returned directly;
if the resource has changed, the user can create a corresponding
response using switchIfEmpty/orElse(Get).

Closes gh-24173
2020-03-11 16:45:00 +01:00
Arjen Poutsma 61569003b5 CORS support in HTTP header predicate
This commit introduces CORS support for the HeadersPredicate in
WebMvc.fn and WebFlux.fn.

Closes gh-24564
2020-03-10 17:22:26 +01:00
Arjen Poutsma c03cdbac21 CORS support in HTTP method predicate
This commit introduces CORS support for the HttpMethodPredicate in
WebMvc.fn and WebFlux.fn.

Closes gh-24564
2020-03-10 15:45:11 +01:00
Arjen Poutsma fc12891006 Add ServerRequest::firstHeader
This commit introduces the method firstHeaderiin both WebMvc.fn and
WebFlux.fn, which return the first header value of a given header name,
if any.
2020-03-10 15:45:11 +01:00
Arjen Poutsma 2fb90cb16b Support for byte-range requests in WebMvc.fn
This commit introduces support for byte-range requests in Servlet
Functional endpoints.

Closes gh-24562
2020-03-05 15:32:31 +01:00
Rossen Stoyanchev 7e03728b2c Polishing contribution
See gh-24632
2020-03-04 19:27:37 +00:00
sada-sigsci cc1f57823b Remove charset from content-type in SseEmitter
See gh-24632
2020-03-04 19:27:37 +00:00
Rossen Stoyanchev a98bf30ee6 ShallowEtagHeaderFilter checks for pre-existing eTag
The filter now checks for an explicitly set eTag and uses it instead of
generating one, and also suppresses caching.

Closes gh-24635
2020-03-04 19:17:56 +00:00
Rossen Stoyanchev c7e037da39 Remove unnecessary calls to disableContentCaching
These calls were added in error when trying to fix #22797 and #23775.
They are not needed in 304 scenarios. Those have no response content and
are skipped by ShallowETagHeaderFilter based on the status.

This leaves disableContentCaching invoked only in streaming scenarios,
which was the original intent and should be the only reason for that
method.

See gh-24635
2020-03-04 19:17:56 +00:00
Rossen Stoyanchev d3da7a50ec Polishing and minor refactoring
See gh-24635
2020-03-04 19:17:56 +00:00
Christoph Dreis 2093e35f27 Avoid unnecessary sorting 2020-03-04 19:10:14 +00:00
ZhangT c5fb7b9fb7
Simplify some redundant code
Closes gh-24586

Co-authored-by: Sam Brannen <sbrannen@pivotal.io>
2020-02-26 12:29:09 +01:00
Juergen Hoeller 6db20eb773 Avoid package import cycles 2020-02-25 14:55:53 +01:00
Rossen Stoyanchev 68b980f849 Remove producible request attribute before mapping
The attribute was previously removed only before exception resolution
in the DispatcherServlet in order to allow error rendering to make an
independent choice on content negotation.

However, Boot rendering happens later in an ERROR dispatch which could
also be a nested dispatch on some servers. So the attribute must also
generally be removed prior to mapping.

We also move the methods where this is done to the base
RequestMappingInfoHandlerMapping class which also deals with the
produces condition and where the producible attribute is added in the
first place.

Closes gh-24466
2020-02-18 21:50:38 +00:00
Rossen Stoyanchev 9aea10179b Insert StringMessageConverter for SSE
Closes gh-24465
2020-02-05 20:49:07 +00:00
Rossen Stoyanchev e7d40f930f Remove synchronized block
As per the Javadoc of ConcurrentHashMap its computeIfAbsent
implementation is atomic and hence already synchronized internally,
so we can remove the surrounding synchronization block.

See gh-24470
2020-02-03 20:59:30 +00:00
Hyunjin Choi bac5cd866e Simplify getSessionAttributesHandler() method 2020-02-03 20:43:45 +00:00
Hyunjin Choi a2af5a90dc Simplify UrlFileNameViewController#getViewNameForUrlPath()
Closes gh-24419
2020-01-24 11:39:05 +01:00
Rossen Stoyanchev c69703ffdb Deprecate path extension strategies
This commit deprecates PathExtensionContentNegotiationStrategy and
ServletPathExtensionContentNegotiationStrategy and also updates code
that depends on them internally to remove that dependence.

See gh-24179
2020-01-22 13:35:09 +00:00
Rossen Stoyanchev 214ba63127 Deprecate config options for content negotiation by path extension
See gh-24179
2020-01-22 13:35:09 +00:00
Rossen Stoyanchev 7453c0d0cb Deprecate config options to match by path extension
See gh-24179
2020-01-22 13:35:09 +00:00
Rossen Stoyanchev 8740c2dc18 Warning against split URL handling in docs
Closes gh-24304
2020-01-13 21:33:11 +00:00
Sébastien Deleuze bc7d010485 Update CORS support
This commit updates CORS support in order to check Origin header
in CorsUtils#isPreFlightRequest which does not change how Spring
MVC or WebFlux process CORS request but is more correct in term
of behavior since it is a public API potentially used in another
contexts.

It also removes an unnecessary check in
AbstractHandlerMethodMapping#hasCorsConfigurationSource and processes
every preflight request with PreFlightHandler.

Closes gh-24327
2020-01-13 08:33:14 +01:00
Rossen Stoyanchev 34d32402d3 Return 500 if producible attribute present
When a request is mapped through a producible condition on an
@RequestMapping, then a failure to find a converter/decoder should be
a 500 because the return type + media type pair were declared by the
controller and that should be possible to render.

Closes gh-23287
2020-01-09 11:10:44 +00:00
Rossen Stoyanchev d509d5ae6f Polishing contribution
See gh-24143
2020-01-08 16:47:33 +00:00
Astushi Yoshikawa 53b39eb753 MvcUriComponentsBuilder prepends slash
See gh-24143
2020-01-08 16:47:33 +00:00
Sam Brannen ef6b1ba034 Update copyright date 2020-01-07 17:15:23 +01:00
stsypanov c480a99a77 Trim line from LineInfo only once 2020-01-07 14:44:09 +01:00
Sam Brannen 12a78d1af2 Update copyright date
See gh-24305
2020-01-07 11:36:53 +01:00
GungnirLaevatain 4692f20aac Remove code duplication in AnnotationDrivenBeanDefinitionParser
This commit merges the implementations of getCallableInterceptors()
and getDeferredResultInterceptors() in order to remove code duplication.

Closes gh-24305
2020-01-07 11:35:38 +01:00
Sam Brannen 7b6d83a106 Use Gradle test fixture support for spring-web
See gh-23550
2020-01-02 16:01:35 +01:00