Commit Graph

1813 Commits

Author SHA1 Message Date
Rossen Stoyanchev 37f9ce5cc9 Return 500 (not 406) if content-type was preset
If content-type is preset in the returned ResponseEntity, then any
failure to find a matching converter is a server error.

Closes gh-23205
2019-07-05 07:07:58 +01:00
Sam Brannen d0231cb29a Presort beans in ControllerAdviceBean.findAnnotatedBeans()
Prior to this commit, all clients of
ControllerAdviceBean.findAnnotatedBeans() sorted the returned list
manually. In addition, clients within the core Spring Framework
unnecessarily used AnnotationAwareOrderComparator instead of
OrderComparator to sort the list.

This commit presorts the ControllerAdviceBean list using OrderComparator
directly within ControllerAdviceBean.findAnnotatedBeans().

Closes gh-23188
2019-06-24 16:26:11 +03:00
Juergen Hoeller e2d01bb783 Merge branch '5.1.x' 2019-06-22 17:11:31 +02:00
Juergen Hoeller 29dcd19971 Upgrade to AspectJ 1.9.4, RxJava 2.2.10, Jetty 9.4.19, Undertow 2.0.22
Includes Hibernate Validator 6.0.17 and renames "withoutJclOverSlf4j".
2019-06-22 16:49:40 +02:00
Sebastien Deleuze e86b937f8c Leverage new Kotlin script templating support
As of 1.3.40, Kotlin now provides a kotlin-scripting-jsr223-embeddable
dependency which:
 - Fixes classloading related issues
 - Provides out of the box JSR 223 support
 - Is compatible with Spring Boot Fat Jar mechanism

This commit updates Spring Framework tests and documentation accordingly.

Closes gh-23165
2019-06-20 10:17:02 +02:00
Sebastien Deleuze 341385acfc Merge branch '5.1.x' 2019-06-19 13:59:59 +02:00
Sebastien Deleuze bcad276adb Fix Jackson documentation broken links
Closes gh-23153
2019-06-19 13:59:36 +02:00
Sam Brannen 451cce4fe8 Do not override requestContextAttribute with null in UrlBasedViewResolvers
Prior to this commit, if a subclass of
org.springframework.web.servlet.view.AbstractView or
org.springframework.web.reactive.result.view.AbstractUrlBasedView
configured a custom value for the requestContextAttribute, that value
was overwritten with null whenever the View was dynamically
instantiated by a UrlBasedViewResolver, and this could lead to
confusing behavior for users of the View.

This commit addresses this issue by ensuring that the
UrlBasedViewResolvers in spring-webmvc and spring-webflux do not
override the requestContextAttribute in a View if the
UrlBasedViewResolver has not been explicitly configured with a custom
requestContextAttribute value.

Closes gh-23129
2019-06-13 17:42:14 +03:00
Juergen Hoeller 0a77477d32 Merge branch '5.1.x' 2019-06-12 18:16:30 +02:00
Juergen Hoeller fc46abf0b7 Polishing 2019-06-12 18:04:06 +02:00
Sam Brannen c99b7c1c90 Polishing 2019-06-12 16:33:39 +03:00
Juergen Hoeller 707c720441 Polishing 2019-06-12 00:05:37 +02:00
Juergen Hoeller 7e02358166 Merge branch '5.1.x' 2019-06-12 00:05:01 +02:00
Juergen Hoeller 22aba8bf60 Upgrade to Apache HttpClient 4.5.9 2019-06-11 23:49:57 +02:00
Juergen Hoeller 7dc92aa05d Polishing 2019-06-11 20:57:27 +02:00
Rossen Stoyanchev 0757eaee9d Clear ProducesRequestCondition attribute
Closes gh-23091
2019-06-11 13:55:20 -04:00
Sam Brannen 2f640fe205 Polish FreeMarker macro support in spring-webflux
See gh-23002
2019-06-10 16:13:20 +03:00
Sam Brannen ac28de0dc1 Polish Javadoc for FreeMarker support 2019-06-10 16:03:16 +03:00
Sam Brannen 9b084bb3ea Polish contribution
See gh-23073
2019-06-08 22:22:27 +03:00
Issam El-atif ab36a0a82f Improve FreeMarker tests in spring-webmvc and spring-context-support
This commit improves FreeMarkerConfigurerTests in spring-webmvc by
testing against FreeMarkerConfigurer instead of
FreeMarkerConfigurationFactoryBean and moves the original
FreeMarkerConfigurationFactoryBeanTests to spring-context-support in
the org.springframework.ui.freemarker package.

Closes gh-23073
2019-06-08 22:21:09 +03:00
Sebastien Deleuze 098ac0bbb8 Annotate Object#equals parameter with @Nullable
Closes gh-23093
2019-06-06 14:18:30 +02:00
Sam Brannen 2074afc87f Polish Javadoc
See gh-23075
2019-06-04 16:55:51 +03:00
Arjen Poutsma 145610129b Javadoc
Closes gh-23075
2019-06-04 15:31:27 +02:00
Brian Clozel 4b8ce04bdc Mark Spring web config classes as proxyBeanMethods=false
Closes gh-23004
2019-05-28 19:11:35 +02:00
Johnny Lim 83078eb6fd Add constants for application/cbor to MediaType
Closes gh-23042
2019-05-28 18:51:25 +02:00
Sam Brannen 141ef9082f Clean up Mockito usage
This commit migrates to the MockitoJUnitRunner where sensible, which
will later allow for an easier migration to Mockito's extension for
JUnit Jupiter.

In addition, this commit deletes unnecessary stubbing for various mocks
and polishes test fixture setup in various test classes.
2019-05-28 13:59:43 +02:00
Sebastien Deleuze bc205e0dbf Remove charset parameter from Spring MVC JSON content type
This change is a follow-up to the ones done as part of gh-22788.

Closes gh-22954
2019-05-27 18:14:19 +02:00
Sam Brannen 09db8881bb Fix Checkstyle violation 2019-05-26 14:28:09 +02:00
stsypanov 4cc7b9b9fc tiny simplifications regarding usage of Iterator 2019-05-25 20:32:43 +02:00
Phillip Webb 9d74da006c Migrate JUnit 4 assertions to AssertJ
Migrate all existing JUnit 4 `assert...` based assertions to AssertJ
and add a checkstyle rule to ensure they don't return.

See gh-23022
2019-05-23 15:52:49 -07:00
Phillip Webb 95a9d46a87 Migrate Hamcrest assertions to AssertJ
Migrate all existing `assertThat(..., Matcher)` assertions to AssertJ
and add checkstyle rules to ensure they don't return.

See gh-23022
2019-05-23 15:49:59 -07:00
Juergen Hoeller 8a33ef2d14 Merge branch '5.1.x' 2019-05-21 21:06:38 +02:00
Juergen Hoeller 5aa0de7ac8 Upgrade to OkHttp 3.14.2, Joda-Time 2.10.2, OpenPDF 1.2.17, JRuby 9.2.7 2019-05-21 20:47:06 +02:00
Arjen Poutsma 9b3c92e8d2 Add leading slash for path predicate if not present
This commit adds a leading slash for path predicates in both
WebFlux.fn and WebMvc.fn.

Closes gh-22795
2019-05-21 12:09:36 +02:00
Phillip Webb 02850f357f Migrate exception checking tests to use AssertJ
Migrate tests that use `@Test(expectedException=...)` or
`try...fail...catch` to use AssertJ's `assertThatException`
instead.
2019-05-20 10:47:53 -07:00
Juergen Hoeller a363fed209 Merge branch '5.1.x' 2019-05-20 17:21:07 +02:00
Juergen Hoeller c5d6b74321 Fix stale-if-error xsd documentation
Closes gh-22983
2019-05-20 17:18:11 +02:00
stsypanov 9ca8681f79 Iteration over a map using EntrySet 2019-05-13 15:38:13 +02:00
Juergen Hoeller cfc4a59135 Merge branch '5.1.x' 2019-05-13 13:40:07 +02:00
Juergen Hoeller daee6f5bd9 Avoid expensive assertions in web resource resolution
Closes gh-22955
2019-05-13 13:28:07 +02:00
Johnny Lim 9a6ce66bd9 Add a missing single quote in assertion message 2019-05-13 12:04:22 +02:00
Sam Brannen 73dbd06361 Enforces static imports for JUnit 4 assertions and assumptions
This commit configures Checkstyle to enforces static imports for JUnit 4
assertions and assumptions.

See gh-22932
2019-05-12 15:13:07 +02:00
Sam Brannen deecab6311 Use assertThat from Hamcrest instead of JUnit 4
org.junit.Assert.assertThat() is deprecated as of JUnit 4.13.

See gh-22894
2019-05-12 14:46:55 +02:00
Sam Brannen 724c805211 Discontinue use of JUnit 3 APIs
This commit also ensures that the JSR-330 TCK is executed with the
normal build by adhering to naming conventions for test classes.

See gh-22894
2019-05-12 14:46:55 +02:00
Sam Brannen 64819bbc1d Clean up warnings 2019-05-10 18:00:29 +02:00
Sam Brannen e465f51d56 Suppress deprecation warnings 2019-05-09 13:21:42 +02:00
Phillip Webb 798b51f4a3 Migrate to BDD Mockito
Migrate all tests to consistently use BDD Mockito. Also add
checksyle rule to enforce going forwards.
2019-05-08 13:46:13 -07:00
Phillip Webb 816bbee8de Remove '.*' imports from tests
Organize test imports to expand all '.*' static imports into
fully qualified imports.

This update will allow us to use additional checkstyle rules in
the future, and will also help if we migrate fully to AssertJ.
2019-05-08 09:55:09 -07:00
Sam Brannen 4038d590a1 Suppress deprecation warning in Gradle build 2019-05-08 17:18:41 +02:00
Sam Brannen 4d1637a9b7 Avoid warnings in RequestMappingHandlerMappingTests 2019-05-08 16:29:31 +02:00
Phil Webb d7320de871 Migrate away from ExpectedException (#22922)
* Add limited checkstyles to test code

Add a limited set of checkstyle rules to the test codebase to improve
code consistency.

* Fix checksyle violations in test code

* Organize imports to fix checkstyle for test code

* Migrate to assertThatExceptionOfType

Migrate aware from ExpectedException rules to AssertJ exception
assertions. Also include a checkstyle rules to ensure that the
the ExpectedException is not accidentally used in the future.

See gh-22894
2019-05-08 16:25:52 +02:00
Rossen Stoyanchev 7e6e3d7027 Switch writeAcceptCharset to false by default
Closes gh-22506
2019-05-08 09:56:52 -04:00
Rossen Stoyanchev 45147c23c1 Empty body checks in ConsumesRequestCondition
Normally consumes matches the "Content-Type" header but what should be done if
there is no content? This commit adds checks for method parameters with
@RequestBody(required=false) and if "false" then also match requests with no content.

Closes gh-22010
2019-05-07 22:03:36 -04:00
Arjen Poutsma 00a5106bfa Add route(RequestPredicate, HandlerFunction) to RouterFunctions builder
Closes gh-22701
2019-05-07 16:49:02 +02:00
Arjen Poutsma 55b56b8c5c Javadoc
Closes gh-22893
2019-05-07 15:24:33 +02:00
Sam Brannen ccb01e663a Merge branch '5.1.x' 2019-05-07 13:03:45 +02:00
Sam Brannen 4aaec942c4 Introduce HTTPS mappings in spring.schemas files
Closes gh-22903
2019-05-07 12:56:42 +02:00
Rossen Stoyanchev 53cadf15e7 Deferred handling of Flux error in Spring MVC
This commit defers flushing of the response until the first item is
emitted that needs to be written (and flushed) to the response.

This makes Spring MVC consistent with WebFlux in this regard.

Closes gh-21972
2019-05-06 12:26:25 -04:00
Sam Brannen d616e10dca Use assertThat from Hamcrest instead of JUnit 4
org.junit.Assert.assertThat() is deprecated as of JUnit 4.13.

See gh-22894
2019-05-05 19:26:04 +02:00
Johnny Lim d489227874 Use HttpHeaders constants where possible 2019-05-04 11:14:08 +02:00
Juergen Hoeller f0f6af2926 Merge branch '5.1.x' 2019-05-03 18:13:12 +02:00
Juergen Hoeller a7949ac84a Consistent use of StringUtils.hasLength(String) vs isEmpty(Object) 2019-05-03 17:29:14 +02:00
Juergen Hoeller eaa9a78d5d Merge branch '5.1.x' 2019-05-03 00:23:57 +02:00
Juergen Hoeller 31c3b8a291 Avoid unguarded String concatenation for debug/trace logging
Closes gh-22874
2019-05-03 00:10:56 +02:00
Juergen Hoeller 8a57997d21 Avoid use of Objects.requireNonNull plus related polishing 2019-05-02 16:32:47 +02:00
Rossen Stoyanchev 07c9a0e1f5 Merge branch '5.1.x' 2019-05-01 04:03:21 -04:00
Rossen Stoyanchev b398216191 Fail proactively if lookupPath not in requestUri
Closes gh-22851
2019-05-01 03:57:44 -04:00
Rossen Stoyanchev b5327ef60f Fix regression in ProducesRequestCondition
Closes gh-22853
2019-05-01 02:59:19 -04:00
Juergen Hoeller 52657b68ea Merge branch '5.1.x' 2019-04-30 18:55:34 +02:00
Juergen Hoeller e0423fbdc2 Revise inline comment for logException call
Closes gh-22794
2019-04-30 18:42:53 +02:00
Juergen Hoeller 359c4f091e Add rejectInvalidCookies flag to CookieLocaleResolver
Closes gh-22861
2019-04-30 18:39:58 +02:00
Sebastien Deleuze 89454e69c3 Deprecate MediaType.APPLICATION_JSON_UTF8
This commit deprecates MediaType.APPLICATION_JSON_UTF8 and
MediaType.APPLICATION_PROBLEM_JSON_UTF8 in favor of
MediaType.APPLICATION_JSON and MediaType.APPLICATION_PROBLEM_JSON since
UTF-8 encoding is now handled correctly by most browsers
(related bug has been fixed in Chrome since September 2017).

MediaType.APPLICATION_JSON is now used as the default JSON content type.

Closes gh-22788
2019-04-30 16:11:50 +02:00
Juergen Hoeller 55418b256d Merge branch '5.1.x' 2019-04-26 16:56:04 +02:00
Juergen Hoeller e5e2d2d661 Polishing (includes minor performance refinements from master) 2019-04-26 16:51:18 +02:00
Juergen Hoeller bdd9a557a5 Streamline ReactiveAdapterRegistry.getAdapter usage
Closes gh-22842
2019-04-26 16:49:16 +02:00
Juergen Hoeller ad497c259a Merge branch '5.1.x' 2019-04-25 14:55:04 +02:00
Juergen Hoeller 0cfab87b1f Revise isEligibleValue javadoc towards BeanUtils.isSimpleValueType
See gh-22816
2019-04-25 14:31:09 +02:00
Rossen Stoyanchev 87dd62a4a3 Merge branch '5.1.x' 2019-04-18 22:49:35 -04:00
Rossen Stoyanchev 42fc4a35d5 Ensure flush after StreamingResponseBody
Closes gh-22813
2019-04-18 22:49:23 -04:00
Rossen Stoyanchev c09e711eb2 Unwrap Optional for @RequestParam reverse resolution
Closes gh-22656
2019-04-18 22:40:12 -04:00
Rossen Stoyanchev dbc45319b3 Merge branch '5.1.x' 2019-04-18 11:51:34 -04:00
Rossen Stoyanchev 1a97a26eb7 Disable response caching when controller resolves ETag
See gh-22797
2019-04-18 11:50:43 -04:00
Juergen Hoeller 44df98c82d Merge branch '5.1.x' 2019-04-12 11:37:07 +02:00
Sebastien Deleuze e84347554e Ignore Kotlin script templating tests
Ignore these tests for the time being since they trigger
a NoClassDefFoundError exception with Kotlin 1.3.30.
2019-04-12 11:17:19 +02:00
Juergen Hoeller 722cd179cf Clean up property values registration in SimpleWebApplicationContext
Closes gh-22787
2019-04-12 11:10:11 +02:00
Juergen Hoeller 49557471a9 Upgrade to AspectJ 1.9.3, Mockito 2.27, OpenPDF 1.2.16, POI 4.1 2019-04-12 11:03:43 +02:00
Rossen Stoyanchev a0826a20c3 CorsInterceptor at the front of the chain
Closes gh-22459
2019-04-09 15:43:43 -04:00
Rossen Stoyanchev d1f888a7a9 Empty path mapping behaves consistently
An empty path mapping in an @RequestMapping now consistently matches to
empty paths regardless of whether there are both type and method level,
annotations, or method-level only.

Closes gh-22543
2019-04-09 15:03:43 -04:00
Rossen Stoyanchev f839c1f9cd Remove warning about empty @RequestMapping path
See gh-22543
2019-04-09 15:03:43 -04:00
Sebastien Deleuze cd0b517abf Improve Kotlin documentation 2019-04-09 12:28:00 +02:00
Sam Brannen 72027b1746 Log warning if @RequestMapping method has no explicit mapping
Commit c0b52d09f5 introduced support for
throwing an exception if a @RequestMapping handler method in a Spring
MVC controller was mapped to an empty path. This had negative side
effects for applications that intentionally mapped to an empty path,
potentially alongside a mapping to an explicit path for the same
handler method.

This commit addresses this by logging a warning (instead of throwing an
exception) if a @RequestMapping method is mapped only to empty paths.

This commit also introduces the same support for WebFlux-based
@RequestMapping handler methods.

Closes gh-22543
2019-04-05 19:55:22 +02:00
Sam Brannen 898494a538 Polish AbstractHandlerMethodMapping
See gh-22543
2019-04-05 14:03:10 +02:00
Sam Brannen 3a9262ca1e Fix Javadoc warnings in Gradle build 2019-04-04 17:49:33 +02:00
Sam Brannen c0b52d09f5 Require explicit path mappings for @RequestMapping methods
Prior to this commit, handler methods in Spring MVC controllers were
not required to provide explicit path mappings via @RequestMapping (or
any of its specializations such as @GetMapping). Such handler methods
were effectively mapped to all paths. Consequently, developers may have
unwittingly mapped all requests to a single handler method.

This commit addresses this by enforcing that @RequestMapping methods
are mapped to an explicit path. Note, however, that this is enforced
after type-level and method-level @RequestMapping information has been
merged.

Developers wishing to map to all paths should now add an explicit path
mapping to "/**" or "**".

Closes gh-22543
2019-04-04 17:33:59 +02:00
Juergen Hoeller 1741b6dcd9 Merge branch '5.1.x' 2019-04-04 16:12:07 +02:00
Juergen Hoeller 95232d5bf8 Upgrade to Apache HttpClient 4.5.8 and Jetty Reactive HttpClient 1.0.3 2019-04-04 16:10:16 +02:00
Sebastien Deleuze 40e4c8068d Polishing 2019-04-04 12:16:18 +02:00
Sebastien Deleuze e6171fb47d Add Kotlin router DSL and extensions for WebMvc.fn
Closes gh-22697
2019-04-04 12:14:27 +02:00
Rossen Stoyanchev 5616eb2e8e Merge branch '5.1.x' 2019-04-03 19:38:21 -04:00
Rossen Stoyanchev 325fb5d97e Unwrap CompletionException in return value handler
See gh-22476
2019-04-03 19:37:13 -04:00