Commit Graph

958 Commits

Author SHA1 Message Date
Rossen Stoyanchev 0e7eecfe34 Add copyToUriComponentsBuilder method
After this change UriComponentsBuilder#uriComponents method no longer
no longer copies from the given UriComponents but rather lets the
UriComponents instance copy itself to the UriComponentsBuilder.

This avoids the need for instanceof checks and also makes it possible
to distinguish between path and path segments, which otherwise is
internal knowledge of UriComponentsBuilder.

Issue: SPR-12742
2015-03-20 15:35:43 -04:00
Juergen Hoeller 898c24fcdd Optimized access to resolved bean type (avoiding BeanFactory locks)
Revised HandlerMethod.getBeanType() impl for both web and messaging.
In addition, HandlerMethods get created with the internal BeanFactory now.

Issue: SPR-12832
2015-03-20 17:35:44 +01:00
Juergen Hoeller 370e3a52bf HttpComponentsClientHttpRequestFactory supports plain HttpClient (i.e. non-CloseableHttpClient implementations) as well
Issue: SPR-12826
2015-03-17 21:24:51 +01:00
Rossen Stoyanchev febcd0c46d Add baseUrl overloaded MvcUriComponentsBuilder methods
Issue: SPR-12800
2015-03-16 20:45:01 -04:00
Juergen Hoeller 162ee36700 Polishing 2015-03-16 21:01:28 +01:00
Juergen Hoeller abd7052b16 ContentCachingRequestWrapper converts IOException to IllegalStateException
Issue: SPR-12810
(cherry picked from commit ce84faf)
2015-03-13 20:20:51 +01:00
Juergen Hoeller bc6a98c144 Polishing (in particular updating javadoc references to Apache Commons) 2015-03-13 18:19:10 +01:00
Rossen Stoyanchev 69b3e00215 Support comma-separated X-Forwarded-Proto
Issue: SPR-12816
2015-03-13 13:02:52 -04:00
Brian Clozel c6250f5164 Fix InputStream caching in ContentCachingReqWrapper
Prior to this commit, the ContentCachingRequestWrapper would immediately
consume the wrapped request's InputStream when asked for the cached
content; that caused several issues:

* the request body was read in memory even if it wasn't yet consumed by
the application, leading to inefficiencies.
* when requesting the InputStream, an empty InputStream was returned
since the original was already read.

This case only happened for form POSTs requests.

This commit makes sure that the wrapper does not alter the request
expected behavior:

* when getting the inputstream, it is wrapped in order to cache its
content
* when getting request parameters, the request body is cached and its
inputstream is consumed, as expected

Issue: SPR-12810
2015-03-13 16:07:20 +01:00
Rossen Stoyanchev 88a14488a1 Support comma-separated X-Forwarded-Port
Issue: SPR-12813
2015-03-13 09:56:43 -04:00
Rossen Stoyanchev 624790a520 Move X-Forwarded-* tests to UriComponentsBuilderTests 2015-03-13 09:33:21 -04:00
Juergen Hoeller 73e8021e59 ResponseEntity's headers(HttpHeaders) accepts null value
Issue: SPR-12792
2015-03-10 15:11:58 +01:00
Juergen Hoeller 5ba7b89e29 StandardMultipartFile declares itself as Serializable now
Issue: SPR-12795
2015-03-10 15:10:15 +01:00
Sam Brannen d90cee78ef Remove trailing whitespace in source code 2015-03-07 21:16:18 +01:00
Rossen Stoyanchev b7dd520784 Fix formatting 2015-03-05 22:50:48 -05:00
Arjen Poutsma 8ab2e47556 HttpMessageConverters should support streaming
All HttpMessageConverters should support StreamingHttpOutputMessage.
Specifically, the BufferedImageHttpMessageConverter and
FormHttpMessageConverter should do so.

Issue: SPR-12715
2015-03-05 22:50:48 -05:00
Rossen Stoyanchev d64c48ff5f UriComponentsBuilder.fromHttpRequest sets port correctly
Issue: SPR-12771
2015-03-05 21:52:27 -05:00
Juergen Hoeller b541fc9366 Polishing 2015-03-05 18:56:57 +01:00
Juergen Hoeller ee74fe6c27 Latest dependency updates (HttpClient 4.4, TestNG 6.8.21, SnakeYAML 1.15, FreeMarker 2.3.22, JRuby 1.7.19, JAMon 2.81, JiBX 1.2.6, XMLUnit 1.6, JsonPath 1.2) 2015-03-02 20:00:17 +01:00
Stephane Nicoll babbf6e871 Harmonize resources location
Issue: SPR-12766
2015-02-28 10:32:40 +01:00
Juergen Hoeller 594a14ab25 RestTemplate avoids use of warn level for response errors
Protected handleResponse method replaces former private logResponseStatus/handleResponseError methods.

Issue: SPR-12760
2015-02-27 22:28:07 +01:00
Arjen Poutsma e24ebd6dbb Add connect/read timeout to Netty RequestFactory
Added connectTimeout and readTimeout properties to the
Netty4ClientHttpRequestFactory.

Issue: SPR-12612
2015-02-27 11:44:27 -05:00
Juergen Hoeller cc33d3fac8 Polishing 2015-02-25 19:05:06 +01:00
Brian Clozel 1705930c8e Merge pull request #735 from rjozwik/fix-huc-is-reserved
Fix reserved set definition according to appendix A of RFC 3986
2015-02-23 10:09:23 +01:00
Juergen Hoeller 7191050e26 Revised common validation methods in AbstractMessageConverterMethodArgumentResolver
The protected validation methods are analogous to ModelAttributeMethodProcessor now.

Issue: SPR-12655
2015-02-19 23:37:07 +01:00
Sebastien Deleuze 90e6304b49 Adjust log level for invalid SockJS or Websocket requests 2015-02-19 16:52:19 +01:00
Sebastien Deleuze 40cbede7f3 Improve error handling in WebUtils.isValidOrigin()
With this commit, WebUtils.isValidOrigin() logs an error message instead
of throwing an IllegalArgumentException when Origin header value is
invalid (for example when it does not contain the scheme).

Issue: SPR-12697
2015-02-19 16:51:58 +01:00
Juergen Hoeller 2135e70f36 Polishing 2015-02-18 17:59:32 +01:00
Juergen Hoeller 0c15a54007 Polishing 2015-02-18 16:45:16 +01:00
Sebastien Deleuze 6062e15572 Change SockJS and Websocket default allowedOrigins to same origin
This commit adds support for a same origin check that compares
Origin header to Host header. It also changes the default setting
from all origins allowed to only same origin allowed.

Issues: SPR-12697, SPR-12685
2015-02-18 09:30:15 +01:00
Juergen Hoeller 77fcf21401 Refined Jackson configuration enhancements
Issue: SPR-12594
Issue: SPR-12634
2015-02-11 20:37:04 +01:00
Radosław Józwik 6d734f2340 Fix reserved set definition according to appendix A of RFC 3986
I have signed and agree to the terms of the SpringSource Individual
Contributor License Agreement.
2015-02-10 23:17:59 +01:00
Juergen Hoeller f58abd3d9a Polishing (forward-ported from 4.1.x) 2015-02-10 23:04:12 +01:00
Juergen Hoeller 058714b03a Polishing 2015-02-10 19:30:59 +01:00
Juergen Hoeller 7585be85f3 Revised validation javadoc, plus protected validate/isBindingErrorFatal template methods
Issue: SPR-12655
2015-02-10 19:28:30 +01:00
Rossen Stoyanchev f84c458aba Add fromHttpRequest to UriComponentsBuilder
Before this change, detection of X-Forwarded-* headers was only built
into ServletUriComponentsBuilder.

This change adds a new method for creating a UriComponentsBuilder from
an existing HttpRequest. This is equivalent to the fromUri method +
X-Forwarded-* header values.
2015-02-10 06:53:14 +01:00
Sebastien Deleuze b215d4c29e Add modulesToInstall(Modules...) to Jackson builder
This commit also adds a modules(Module...) method in addition to
modules(List<Module> modules) in order to be consistent with other
parts of the API.

Issue: SPR-12634
2015-02-03 11:58:21 +01:00
Rossen Stoyanchev 78f3a3cb11 Update javadoc for MultipartFile.transferTo
Issue: SPR-12650
2015-02-02 17:29:39 -05:00
Rossen Stoyanchev fd426aaa4d Update Netty4ClientHttpRequestFactory buffer size
Before this change, the maxRequestSize property was used (incorrectly)
to limit both the size of the request and response. The change:

- removes maxRequestSize and therefore no longer places limits on the
size of the request thus matching to AbstractBufferingClientHttpRequest
which is the base class for other buffering client implementations.

- adds maxResponseSize property required to create Netty's
HttpObjectAggregator for aggregating responses.

Issue: SPR-12623
2015-02-02 15:50:22 -05:00
Rossen Stoyanchev a32b5e61d0 Add support for Server-Sent Events
This commit adds ResponseBodyEmitter and SseEmitter (and also
ResponseEntity<ResponseBodyEmitter> and ResponseEntity<SseEmitter>) as
new return value types supported on @RequestMapping controller methods.

See Javadoc on respective types for more details.

Issue: SPR-12212
2015-01-29 17:55:09 -05:00
Sebastien Deleuze ccb1c13951 Use UTC timezone in Jackson builder and factory tests
Issue: SPR-12634
2015-01-26 15:59:15 +01:00
Brian Clozel cf86ecddb5 Avoid loss of body content in AbstractRequestLoggingFilter
Prior to this commit, the `ContentCachingRequestWrapper` class would
cache the response content only if the reponse would be consumed using
its InputStream. In case of a Form request, Spring MVC consumes the
response using the `getParameter*` Servlet API methods. This causes the
cached content to never be written.

This commit makes the `ContentCachingResponseWrapper` write the request
body to the cache buffer by using the `getParameter*` API, thus avoiding
those issues.

Issue: SPR-7913
2015-01-26 11:41:34 +01:00
Sebastien Deleuze 5fb6d6d89c Allow Jackson builder modules configuration to be customized
Modules (well-known or user provided) registration is now performed
first in order to allow their configuration to be customized by more
specific ones like custom serializers or deserializers.

Issue: SPR-12634
2015-01-26 11:08:08 +01:00
Juergen Hoeller d4dac250a8 AbstractRequestLoggingFilter allows for dedicated shouldLog check in CommonsRequestLoggingFilter
Issue: SPR-12609
2015-01-20 16:01:53 +01:00
Sebastien Deleuze bf7a9754d5 Avoid using Java 8 ZoneId class
Issue: SPR-12594
2015-01-20 15:24:55 +01:00
Sebastien Deleuze b89e62e5f6 Support specifying Jackson TimeZone and Locale
Issue: SPR-12594
2015-01-20 14:57:14 +01:00
Sam Brannen c50df0c420 Polish MessageBodyClientHttpResponseWrapper
Added missing copyright clause and fixed @since version.
2015-01-08 18:02:00 +01:00
Brian Clozel b6675b6167 Revisit empty body response support in HTTP client
Prior to this commit, HTTP responses without body (response status 204
or 304, Content-Length: 0) were handled properly by RestTemplates. But
some other cases were not properly managed, throwing exceptions for
valid HTTP responses.

This commit better handles HTTP responses, using a response wrapper that
can tell if a response:

* has no message body (HTTP status 1XX, 204, 304 or Content-Length:0)
* has an empty message body

This covers rfc7230 Section 3.3.3.

Issue: SPR-8016
2015-01-08 17:34:39 +01:00
Craig Andrews 213a3fd779 Performance improvements in ShallowEtagHeaderFilter
Prior to this change, the ShallowEtagHeaderFilter would use a
ResizableByteArrayOutputStream to internally write data and calculate
the ETag. While that implementation is faster than the regular
ByteArrayOutputStream (since it has a better strategy for growing the
internal buffer), a lot of buffer copying/writing still happens.

This change adds a new FastByteArrayOutputStream implementation that
internally uses a LinkedList<Byte[]> to store the content. So when
writing bytes to that OutputStream implementation, new byte[] are
added to the list when the previous ones are full. This saves most
of the instantiating/copying operations.

Note that new methods were added in DigestUtils to allow usage of
Streams instead of byte[], which is more efficient in our case.

Fixes #653

Issue: SPR-12081
2015-01-08 16:08:09 +01:00
Stephane Nicoll bce145c06e Merged HttpClient defaults with local customizations
Update HttpComponents wrapper to merge local customizations with the
default of the current HttpClient instead of overriding everything.

This is available as from HttpComponents 4.4. that exposes the default
request config from the  client via the Configurable interface. If the
client does not implement such interface, the previous behaviour is
applied

Issue: SPR-12583
2015-01-05 14:28:47 +01:00
Brian Clozel e02719e5e3 Fix path mapping issue in default servlet mode
Prior to this commit, some requests would be wrongly mapped to "/" when:

* requests ends with "//" such as "/foo/bar//"
* the DispatcherServlet is mapped as the default ("/")
* the app container sanitizes the servletPath

In those cases, the path extraction algorithm was wrongly guessing the
path of the current request.

This commit detects if the app container sanitized the servletPath for
the current request. If so, it uses a sanitized version of the
requestUri to extract the path information.

Issue: SPR-12372
2014-12-31 14:08:49 +01:00
Sam Brannen 40449e2741 Suppress warnings in tests
This commit suppresses warnings in test classes that were polluting the
Gradle build output.
2014-12-31 02:10:30 +01:00
Juergen Hoeller 9ac02b319d Remove pre-3.2 deprecated classes and methods
Issue: SPR-12578
2014-12-30 20:05:15 +01:00
Juergen Hoeller fad76336f6 Polishing 2014-12-30 15:26:43 +01:00
Juergen Hoeller 730bd02da7 Polishing 2014-12-30 15:01:51 +01:00
Juergen Hoeller 86b8112c90 Polishing 2014-12-29 15:13:40 +01:00
Stephane Nicoll 71783c5d86 Allow default settings of a custom HttpClient to apply
Previously the default settings of a custom HttpClient were always
ignored since a RequestConfig instance was always set no matter if
some customizations were applied or not.

This commit keeps an internal RequestConfig object instance that is
only initialized if the user applies a customization. If he does not, the
default settings of the HttpClient are used as it should.

Note that if the HttpComponents API exposed the default RequestConfig
of a given HttpClient, we would be able to merge our customizations with
the one specified by the client. Unfortunately, such API does not exist
and the "defaultSettingsOfHttpClientLostOnExecutorCustomization" test
illustrates that limitation.

Issue: SPR-12540
2014-12-29 09:36:54 +01:00
Rossen Stoyanchev ea05e0b1ad Improve @SessionAttributes support during redirect
Before this change attributes listed with @SessionAttributes would not
be saved in the session when there was a redirect and the controller
method declared a parameter of type RedirectAttributes.

This change ensures it's the "default" model that is always the one
checked for @SessionAttributes under all circumstances since
RedirectAttributes is really only meant to provide String values to
insert into or append to the the redirect URL.

Issue: SPR-12542
2014-12-23 14:24:44 -05:00
Rossen Stoyanchev ea2943feca Polish ModelAndViewContainer and update tests 2014-12-23 14:24:43 -05:00
Juergen Hoeller c114c08922 Preparations for Jackson 2.5
Issue: SPR-12565
2014-12-22 18:46:57 +01:00
Stephane Nicoll aafdcecf53 Customize connection request timeout
Prior to this commit it was not possible to easily customize the
connection request timeout used by the HttpClient. Both
`HttpComponentsClientHttpRequestFactory` and
`HttpComponentsClientHttpRequestFactoryTests` have been updated to
support a `connectionRequestTimeout` property.

Issue: SPR-12166
2014-12-22 16:31:07 +01:00
Stephane Nicoll 24b82746b5 Polish upgrade to HttpComponents 4.3
Polish fbe605123 to make explicit the fact that a null RequestConfig
can be used to force the defaults of the current HttpClient.

Issue: SPR-11113
2014-12-22 14:31:24 +01:00
Stephane Nicoll fbe6051233 Upgrade HttpComponentsHIRE to HttpComponents 4.3
Previously, HttpComponentsHttpInvokerRequestExecutor was not compatible
with the new API of HttpComponents 4.3. Specifically, it is not possible
to update the socket and read timeouts on the HttpClient itself anymore.

We actually already updated HttpComponentsClientHttpRequestFactory for a
similar problem in SPR-11442: if we detect an older HttpClient
implementation, we update the timeout directly on the client. If that's
not the case, we keep the value in the factory itself and use it when a
new HttpRequest needs to be created.

This commit also uses the new API to create a default HttpClient and
therefore requires HttpComponents 4.3. As mentioned above, it is still
possible to use deprecated HttpClient instances against this executor.

Issue: SPR-11113
2014-12-22 11:02:32 +01:00
Rossen Stoyanchev 0524a82c09 Update unprocessableEntity to allow body
Issue: SPR-12515
2014-12-08 16:19:52 -05:00
Juergen Hoeller 1daa5eb383 ResponseEntity provides static "unprocessableEntity()" convenience method as well
Issue: SPR-12515
2014-12-07 15:34:39 +01:00
Rossen Stoyanchev 189ec75789 Add ability to clone to UriComponentsBuilder hierarchy
Issue: SPR-12494
2014-12-05 12:16:15 -05:00
Sebastien Deleuze 2fccf3ff44 Add support for autowiring Jackson handlers
This commit introduces the SpringHandlerInstantiator
class, a Jackson HandlerInstantiator that allows to autowire
Jackson handlers (JsonSerializer, JsonDeserializer, KeyDeserializer,
TypeResolverBuilder and TypeIdResolver) if needed.

SpringHandlerInstantiator is automatically used with
@EnableWebMvc and <mvc:annotation-driven />.

Issue: SPR-10768
2014-12-05 17:37:28 +01:00
Juergen Hoeller d1f8968595 ControllerAdvice basePackages specifically refer to actual packages (avoiding accidental prefix matches with other packages)
Issue: SPR-12509
2014-12-05 13:25:48 +01:00
Brian Clozel 98870251f9 Better empty response body support in RestTemplate
Prior to this change, RestTemplate returned an empty response body if:

* HTTP return status 204 or 304
* Content-length header equals 0

This change adds a new condition for this, better supporting RFC7230
section 3.4, for connections that are closed without response body:

* No Content-length header
* No Transfer-encoding: chunked header value
* a Connection: close header value

See SPR-7911 for previous efforts in that space.

Issue: SPR-8016
2014-12-05 09:57:41 +01:00
Brian Clozel b2878a4f60 Merge pull request #704 from aantono/master
Fixed the output stream incomplete data by explicitly flushing the OutputStreamWriter
2014-12-05 09:51:55 +01:00
Alex Antonov bf8d99d7e4 Fixed the output stream incomplete data by explicitly flushing the OutputStreamWriter 2014-12-04 16:46:15 -06:00
Juergen Hoeller 4013fe03a5 Revised ControllerAdvice basePackages handling (based on package names instead of java.lang.Package)
Issue: SPR-12506
2014-12-04 17:56:01 +01:00
Alex Antonov b041cffe5d Fix for NPE when creating ProtobufHttpMessageConverter without ExtensionRegistryInitializer 2014-12-03 12:26:18 -06:00
Sebastien Deleuze fbd85925de Use Jackson improved default configuration everywhere
With this commit, Jackson builder is now used in spring-websocket
to create the ObjectMapper instance.

It is not possible to use the builder for spring-messaging
and spring-jms since these modules don't have a dependency on
spring-web, thus they now just customize the same features:
 - MapperFeature#DEFAULT_VIEW_INCLUSION is disabled
 - DeserializationFeature#FAIL_ON_UNKNOWN_PROPERTIES is disabled

Issue: SPR-12293
2014-12-03 09:49:41 +01:00
Roy Clarkson 83ecf5ca1d Fix issue where FormHttpMessageConverter fails to write multipart data
FormHttpMessageConverter incorrectly determines that the media type
"multipart/form-data; charset=utf-8" is not multipart. This commit
allows the media type to contain a charset parameter.
2014-12-02 16:06:49 -05:00
Juergen Hoeller 2496d68e9f Relaxed final declarations and protected doInvoke methods
Issue: SPR-12484
2014-12-01 15:07:24 +01:00
Juergen Hoeller decc5cd1ae Extracted ContentCachingRequestWrapper and ContentCachingResponseWrapper
Issue: SPR-12477
2014-11-28 17:17:02 +01:00
Juergen Hoeller a6e7044523 Correct since declarations in Netty 4 client support 2014-11-26 11:29:58 +01:00
Juergen Hoeller 929cda6790 Allow custom @Validated annotations for handler method parameters
Issue: SPR-12406
2014-11-24 23:34:24 +01:00
Juergen Hoeller aadb93f30c Rearranged WebAsyncTask constructor interdependencies and assertions
Issue: SPR-12457
2014-11-22 18:02:12 +01:00
Juergen Hoeller 05bdc2cf77 Consistent declaration and use of UTF-8 Charset constants, plus related polishing 2014-11-11 02:38:30 +01:00
Rossen Stoyanchev 53eec48ffd Fix HttpUrlConnection DELETE without body
The following commit allowed HTTP DELETE with body:
584b831bb9

However it broke buffered requests even without a body since JDK 1.6
and 1.7 do not support calls to getOutputStream with HTTP DELETE.

This commit set the doOutput flag back to false if the actual buffered
body is 0 length.

Issue: SPR-12361
2014-11-10 14:20:59 -05:00
Juergen Hoeller bf9295bec3 ShallowEtagHeaderFilter skips "Cache-Control" header check on Servlet 2.5
Issue: SPR-12414
2014-11-06 22:48:08 +01:00
Rossen Stoyanchev d8941ca098 Normalize 2+ '/' in path in UriComponentsBuilder
Issue: SPR-12398
2014-10-30 14:51:04 -04:00
Juergen Hoeller 1146d5ba1d Polishing 2014-10-29 22:44:59 +01:00
Rossen Stoyanchev 584b831bb9 Allow HTTP delete with request entity
Issue: SPR-12361
2014-10-27 16:48:59 -04:00
Rossen Stoyanchev 083dece106 Polish netty client support
Mostly updates based on:
https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-Code-Style
2014-10-27 14:12:53 -04:00
Arjen Poutsma 7de0a70f0c Netty support for (Async)RestTemplate
This commit introduces an AsyncClientHttpRequestFactory based on Netty
4, for use with the (Async)RestTemplate.
2014-10-27 13:57:37 -04:00
Sam Brannen 6463878f2d Polish Javadoc for @RequestMapping 2014-10-24 14:59:58 +02:00
Brian Clozel a0c210457b Use response encoding when escaping HTML
With SPR-9293, it is now possible to HTML escape text while taking into
account the current response encoding. When using UTF-* encodings, only
XML markup significant characters are escaped, since UTF-* natively
support those characters.

This commit adds a new servlet context parameter to enable this fix by
default in a Spring MVC application:

    <context-param>
      <param-name>responseEncodedHtmlEscape</param-name>
      <param-value>true</param-value>
    </context-param>

Issue: SPR-12350, SPR-12132
2014-10-24 11:53:47 +02:00
Rossen Stoyanchev d5eb669416 Add mention of java.util.Optional in @MVC
Issue: SPR-12370
2014-10-23 16:53:00 -04:00
Craig Andrews d5bf6713ed Add author attribution for htmlEscape methods
Issue: SPR-9293
2014-10-23 11:29:32 -07:00
Juergen Hoeller 2035b17925 Polishing 2014-10-23 17:24:00 +02:00
Sebastien Deleuze 1c217aae40 Support text/xml and application/*+xml in Jackson XML message converter
Issue: SPR-12366
2014-10-23 16:48:11 +02:00
Rossen Stoyanchev 051c5fb66a Update javadoc 2014-10-22 22:28:21 -04:00
Rossen Stoyanchev df090235bb Update documentation for Map arguments
Issue: SPR-12347
2014-10-22 22:17:51 -04:00
Brian Clozel a011b360d1 Polish SPR-12286
Issue: SPR-12286
2014-10-22 21:15:34 +02:00
Brian Clozel 86d97baf65 Allow defining default content negotiation strategy
During the HTTP Content Negotiation phase, the ContentNegotiationManager
uses configured ContentNegotiationStrategy(ies) to define the list of
content types accepted by the client.

When HTTP clients don't send Accept headers, nor use a configured
file extension in the request, nor a request param, developers can
define a default content type using the
ContentNegotiationConfigurer.defaultContentType() method.

This change adds a new overloaded defaultContentType method that takes a
ContentNegotiationStrategy as an argument. This strategy will take the
current request as an argument and return a default content type.

Issue: SPR-12286
2014-10-22 16:32:12 +02:00
Juergen Hoeller 3106905877 Polishing 2014-10-22 01:19:14 +02:00
Brian Clozel 369cabf064 Conditionally htmlEscape chars based on encoding
This commit adds new htmlEscape methods that take the character encoding
as a parameter. According to specs and recommendations, the list of
chars to be html escaped depends on the encoding used in the response.
If the current char encoding supports chars natively, we shouldn't
escape those; of course, reserved chars (<,>,',",&) should always be
escaped.

See: http://www.w3.org/TR/html4/sgml/entities.html#h-24.3
See: spring-projects/spring-framework#385 by @candrews

Issue: SPR-9293
2014-10-21 17:49:37 +02:00
Sam Brannen 66069333f1 Fix JUnit imports in SourceHttpMessageConverterTests
When org.junit.Assert.* is statically imported, the class does not
compile in Eclipse/STS since XMLAssert extends junit.framework.Assert.
2014-10-21 16:18:23 +02:00
Juergen Hoeller 8325b10080 Consistent formatting of license headers, package javadocs, and import declarations 2014-10-21 01:44:07 +02:00
Rossen Stoyanchev 956b66bbd4 Fix issue with async return value type determination
Before this change, the type of asynchronously produced return values
(e.g. Callable, DeferredResult, ListenableFuture) could not be
properly determined with an actual resulting value of null. Or even
with an actual value returned, the generic type could not be properly
determined. This change fixes both of those issues.

Issue: SPR-12287
2014-10-15 16:39:03 -04:00
Juergen Hoeller c7e7d11156 Polishing 2014-10-14 14:27:03 +02:00
Juergen Hoeller d501137f4e Consistently accept empty Content-Type header and empty character encoding
Issue: SPR-12173
2014-10-14 14:26:07 +02:00
Juergen Hoeller 0fb8f0b469 Polishing 2014-10-13 17:58:15 +02:00
Juergen Hoeller 8760be7d64 ResponseEntity's HeadersBuilder allows for specifying existing HttpHeaders
Issue: SPR-12324
2014-10-13 17:22:27 +02:00
Brian Clozel 0a68d265fb Polish indentation 2014-10-08 17:02:26 +02:00
Sebastien Deleuze f518ad9009 Add (de)serializerByType() and mixIn() to Jackson2ObjectMapperBuilder
Issue: SPR-12313
2014-10-08 10:57:29 +02:00
Tadaya Tsuyukubo 25bb58a1e8 Add shortcuts for Jackson mix-in annotations registration
This commit adds support for direct Jackson mix-in annotations registration in
Jackson2ObjectMapperFactoryBean and Jackson2ObjectMapperBuilder.

Issue: SPR-12144
2014-10-07 18:07:00 +02:00
Juergen Hoeller 20a8416c2e Jackson2ObjectMapperBuilder allows for regular constructor usage as well
Issue: SPR-12243
2014-10-01 02:29:46 +02:00
Juergen Hoeller 3a3c52dbdd Polishing 2014-10-01 01:10:25 +02:00
Juergen Hoeller d778037f40 Jackson2ObjectMapperFactoryBean builds on revised Jackson2ObjectMapperBuilder now
Issue: SPR-12243
2014-10-01 01:04:16 +02:00
Juergen Hoeller 69998e3d50 Remove outdated references to ContextLoaderServlet
Issue: SPR-7725
(cherry picked from commit b45d08f)
2014-10-01 01:02:56 +02:00
Sam Brannen 62fc39cca1 Suppress warnings in MappingJackson2XmlHttpMessageConverterTests 2014-09-30 16:58:47 +02:00
Sebastien Deleuze 77abe07807 Set Jackson DEFAULT_VIEW_INCLUSION property to false by default
Issue: SPR-12179
2014-09-30 05:18:15 +02:00
Sebastien Deleuze 42aef5f5dc Set Jackson FAIL_ON_UNKNOWN_PROPERTIES property to false by default
Issue: SPR-11891
2014-09-30 05:18:15 +02:00
Sebastien Deleuze 4e24d66ff7 Create a builder for Jackson ObjectMapper
Jackson2ObjectMapperBuilder now allows to create ObjectMapper and XmlMapper
instances easily thanks to its fluent API.

This builder is used in Jackson message converters and views to instantiate default
ObjectMapper and XmlMapper.

This commit also add a createXmlMapper property to
Jackson2ObjectMapperFactoryBean in order to allow to create easily a XmlMapper
instance.

Issue: SPR-12243
2014-09-30 05:18:15 +02:00
Juergen Hoeller 7bc8e5199e Polishing 2014-09-29 23:50:23 +02:00
Juergen Hoeller 7f43f02a13 FormHttpMessageConverter uses a delegate class for JavaMail-based MIME encoding (isolating the JavaMail API dependency)
Issue: SPR-12108
2014-09-29 22:35:13 +02:00
Juergen Hoeller bf99d6a3b5 WebAsyncManager avoids concurrentResult.toString() and builds correct DeferredResultProcessingInterceptor keys
Issue: SPR-12253
2014-09-26 14:15:21 +02:00
Sam Brannen 24d09a3b8d Fix Javadoc link to DEFAULT_NONE in @RequestMapping 2014-09-26 12:56:25 +02:00
Rossen Stoyanchev 2a64834a44 Fix test dependency 2014-09-26 00:03:46 -04:00
Rossen Stoyanchev 9be0cf21e5 Support writing multipart non-ASCII file names
Issue: SPR-12108
2014-09-25 18:00:55 -04:00
Rossen Stoyanchev 6cbe1433e2 Polish FormHttpMessageConverter 2014-09-25 16:32:01 -04:00
Juergen Hoeller 1f3e195dac Polishing 2014-09-25 17:00:45 +02:00
Juergen Hoeller cfc821d179 DataBinder unwraps Optional objects and allows for proper handling of Optional.empty()
Issue: SPR-12241
2014-09-25 17:00:36 +02:00
Brian Clozel 26326fb40b Mention DEFAULT_NONE in @RequestMapping's Javadoc
This change mentions `ValueConstants.DEFAULT_NONE` in @RequestMapping's
Javadoc, in order to explain the default value.

Issue: SPR-9967
2014-09-22 18:38:19 +02:00
Brian Clozel b9348bb89c Fix Protobuf support - HTTP headers already written
Prior to this commit, the `ProtobufHttpMessageConverter` would call
`outputMessage.getBody()` at the beginning of the `writeInternal`
method, thus writing HTTP headers. Since this method is trying to write
"x-protobuf" headers after that, protobuf support wasn't working
properly for the default "x-protobuf" media type.

Thanks Toshiaki Maki for the repro project!

Also fixed:
* improve `MockHttpOutputMessage` behavior to reproduce the read-only
state of HTTP headers once they've been written.

Issue: SPR-12229
2014-09-22 14:02:35 +02:00
Sebastien Deleuze 2989fe4203 Support Jackson based XML serialization in RestTemplate
Issue: SPR-12225
2014-09-22 01:10:21 +02:00
Sam Brannen 4aa97f8945 Remove references to CommonsHttpInvokerRequestExecutor 2014-09-21 19:53:54 +02:00
Phillip Webb 2667956a30 Initialize JNDI to fix failing Environment test
Issue: SPR-12223
2014-09-20 09:01:16 -07:00
Juergen Hoeller a833889c2a Polishing 2014-09-17 21:55:46 +02:00
Juergen Hoeller 15320db414 Polishing 2014-09-17 02:35:41 +02:00
Juergen Hoeller f394c8aa2a Polishing
Issue: SPR-12196
2014-09-16 15:03:21 +02:00
Juergen Hoeller 26a93b6a33 Client request implementations enforce RFC 6265 (cookies in a single header)
Issue: SPR-12196
2014-09-16 15:02:21 +02:00
Juergen Hoeller 70412a9d0a Accept empty Content-Type header
Issue: SPR-12173
2014-09-12 16:44:56 +02:00
Juergen Hoeller 1e7bfd91a7 Polishing 2014-09-10 01:28:54 +02:00
Juergen Hoeller 5790fc904a Consistent support for java.util.Optional for all applicable handler method arguments
Issue: SPR-12171
2014-09-10 01:27:46 +02:00
Juergen Hoeller c8bbd0bae4 Polishing 2014-09-07 22:51:21 +02:00
Juergen Hoeller a5a56d5052 Polishing 2014-09-04 11:20:11 +02:00
Juergen Hoeller 81ba3b33f6 Dropped RequestEntity's template variable methods in order to remove dependencies on org.springframework.web
Instead, as outlined in the revised javadoc, let's recommend manual UriTemplate usage for RequestEntity URI input.

Issue: SPR-11752
2014-09-04 11:19:59 +02:00
Juergen Hoeller d75f128752 Polishing 2014-09-04 03:03:12 +02:00
Juergen Hoeller 86b7118da8 Polishing 2014-09-04 02:30:25 +02:00
Juergen Hoeller 20c2ba35dc Polishing 2014-09-04 00:55:38 +02:00
Juergen Hoeller f4f7f40f18 Test for actual HttpInvokerProxyFactoryBean usage with plain FactoryBean return type
Issue: SPR-12141
2014-09-04 00:33:36 +02:00
Sebastien Deleuze 36542549fa Add HTTP status to ServletRequestHandledEvent
Issue: SPR-12119
2014-08-29 21:47:03 -04:00
Rossen Stoyanchev a0b231d36d Update port related code in UriComponentsBuilder
Use null to indicate no port has been provided.
Raise exception when port has not been expanded.

Issue: SPR-12123
2014-08-29 09:21:15 -04:00
Sebastien Deleuze 8fbd310b07 Support port URI template variables
This commit makes it possible to specify port with an URI template variable.

For example :
RestTemplate restTemplate = new RestTemplate();
restTemplate.getForObject("http://localhost:{port}/resource", String.class, 8080);

Issue: SPR-12123
2014-08-29 08:59:11 -04:00
Juergen Hoeller b93dd95475 Polishing 2014-08-22 22:55:57 +02:00
Juergen Hoeller 439ce4a1a5 Polishing
Issue: SPR-12112
2014-08-22 14:00:28 +02:00
Arjen Poutsma dbe337f932 ResponseEntity provides static "badRequest()" convenience method as well
Issue: SPR-12112
2014-08-22 13:36:45 +02:00
Juergen Hoeller b73c531527 PropertySource implementations perform conversion to String arrays via StringUtils (getting rid of EMPTY_NAMES_ARRAY) 2014-08-21 22:46:33 +02:00
Juergen Hoeller 0c32d66cbd ShallowEtagHeaderFilter supports Servlet 3.1's setContentLengthLong as well
Issue: SPR-12097
2014-08-19 20:17:42 +02:00
Juergen Hoeller 2ef3d66c89 Polishing 2014-08-18 19:27:08 +02:00
Sebastien Deleuze ebc726a915 Allow null ObjectMapper in Jackson2ObjectMapperFactoryBean.getObjectType()
Issue: SPR-11785
2014-08-14 13:40:47 +02:00
Sebastien Deleuze 6665634675 Support Jackson based XML serialization/deserialization
This commit adds support for XML serialization/deserialization based on
the jackson-dataformat-xml extension. When using @EnableWebMvc or
<mvc:annotation-driven/>, Jackson will be used  by default instead of JAXB2
if jackson-dataformat-xml classes are found in the classpath.

This commit introduces MappingJackson2XmlHttpMessageConverter and
MappingJackson2XmlView classes, and common parts between JSON
and XML processing have been moved to AbstractJackson2HttpMessageConverter
and AbstractJackson2View classes.

MappingJackson2XmlView supports serialization of a single object. If the model
contains multiple entries, MappingJackson2XmlView.setModelKey() should be
used to specify the entry to serialize.

Pretty print works in XML, but tests are not included since a Woodstox dependency
is needed, and it is better to continue testing spring-web and spring-webmvc
against JAXB2.

Issue: SPR-11785
2014-08-13 16:22:58 +02:00
Juergen Hoeller 92bd240474 Polishing
Issue: SPR-12079
2014-08-13 15:04:58 +02:00
Roy Clarkson d6fd40d6dc Upgrade to Gson 2.3
This release contains the following new features:

- The new @JsonAdapter annotation to specify a Json TypeAdapter for a
  class field
- JsonPath support: JsonParser.getPath() method returns the JsonPath
  expression
- New public methods in JsonArray (similar to the java.util.List):
  contains(JsonElement), remove(JsonElement), remove(int index),
  set(int index, JsonElement element)
- Many other smaller bug fixes

See: https://groups.google.com/forum/#!topic/google-gson/MOqf5RGtIzk
2014-08-12 11:47:40 +03:00
Phillip Webb ac8326d2df Polish mockito usage
Consistent use of BDDMockito rather than standard Mockito.
2014-08-11 16:23:11 -07:00
Juergen Hoeller ad475ffadf Consistent vararg declarations for String array setters 2014-08-08 17:17:09 +02:00
Juergen Hoeller 5862ddc869 ResponseEntity provides static "notFound()" convenience method as well
Issue: SPR-12070
2014-08-07 22:28:35 +02:00
Sebastien Deleuze 3922f6fc53 Update references to RFC 2616
Replace references to the old RFC 2616 (HTTP 1.1) with references
to the new RFCs 7230 to 7235.

This commit also deprecates:
 - HttpStatus.USE_PROXY
 - HttpStatus.REQUEST_ENTITY_TOO_LARGE in favor of HttpStatus.PAYLOAD_TOO_LARGE
 - HttpStatus.REQUEST_URI_TOO_LONG in favor of HttpStatus.URI_TOO_LONG

Issue: SPR-12067
2014-08-07 14:50:45 +02:00
Sebastien Deleuze ebc5fea77b Add more HttpHeaders constants for standard HTTP headers
Issue: SPR-12063
2014-08-05 11:11:09 +02:00
Stephane Nicoll 3da68cfe21 Remove unused imports 2014-08-04 14:13:40 +02:00
Rossen Stoyanchev 5859649af7 Update UriTemplate Javadoc
Issue: SPR-10497
2014-07-31 17:08:08 -04:00
Rossen Stoyanchev c4d7976c37 Update RestTemplate Javadoc
Issue: SPR-10497
2014-07-31 17:02:30 -04:00
Rossen Stoyanchev 135a3ff3d8 Use raw status code in RestTemplate logResponseStatus
Issue: SPR-12022
2014-07-30 15:43:43 -04:00
Juergen Hoeller 8f484d382e Polishing 2014-07-29 11:42:37 +02:00
Juergen Hoeller 8cc0fa5ae1 Polishing 2014-07-28 22:05:40 +02:00
Rossen Stoyanchev 5be1ff281c Polish 2014-07-22 16:56:59 -04:00
Brian Clozel b56703eadc Add Google Protobuf support with a MessageConverter
This change adds a new HttpMessageConverter supporting
Google protocol buffers (aka Protobuf).
This message converter supports the following media types:
* application/json
* application/xml
* text/plain
* text/html (output only)
* and by default application/x-protobuf

Note, in order to generate Proto Message classes, the protoc binary
must be available on your system.

Issue: SPR-5807/SPR-6259
2014-07-22 16:56:59 -04:00
Juergen Hoeller f0bcb773f9 ResourceHttpMessageConverter does not call contentLength() on InputStreamResource
Issue: SPR-12017
2014-07-22 17:00:57 +02:00
Juergen Hoeller 9d6c38bd54 Consistent bracket alignment 2014-07-18 17:21:58 +02:00
Juergen Hoeller 188e58c46a Fixed javadoc links 2014-07-18 17:21:44 +02:00
Sebastien Deleuze 86e8bdab6b Make ListenableFuture compliant with Java 8 lambda
Make it possible to use a ListenableFuture with Java 8
lambda expressions, using a syntax like
listenableFuture.addCallback(() -> ..., () -> ...);

Issue: SPR-11820
2014-07-16 16:06:24 +02:00
Juergen Hoeller 777085bbfc MappingJackson2JsonView/MessageConverter calls non-deprecated Jackson 2.1+ createGenerator API
Also removing workaround for https://github.com/FasterXML/jackson-databind/issues/12 (fixed in 2.1+)

Issue: SPR-11262
2014-07-09 21:23:09 +02:00
Brian Clozel a4484bb767 Fix UriComponentsBuilder.fromUriString parsing error
This commit fixes cases where part of the URI was mistaken for the
userinfo when:
* the URI did not contain any path
* the query string contained the "@"

Issue: SPR-11964
2014-07-09 16:58:11 +02:00
Juergen Hoeller 1222ca38fb RestTemplate accepts getMessageConverters() List on setMessageConverters again
Issue: SPR-11962
2014-07-07 14:33:48 +02:00
Juergen Hoeller 367b0394a2 Spring's ROME support requires ROME 1.5 (com.rometools.rome) now
Issue: SPR-11893
2014-07-02 15:04:41 +02:00
Rossen Stoyanchev d3a87a13f7 Polish 2014-07-01 16:10:00 -04:00
Arjen Poutsma f6fbdafb6a Introduce RequestEntity and builder
This commit introduces the RequestEntity, a class similar to
ResponseEntity, but meant for HTTP requests rather than responses. The
RequestEntity can be used both in RestTemplate as well as @MVC
scenarios.

The class also comes with a builder, similar to the one found in
ResponseEntity, which allows for building of a RequestEntity through a
fluent API.

Issue: SPR-11752
2014-07-01 16:10:00 -04:00
Juergen Hoeller 0451232eb4 Polishing
(cherry picked from commit 86ea305)
2014-07-01 15:14:31 +02:00
Juergen Hoeller e90143e03b Polishing 2014-07-01 12:52:09 +02:00
Juergen Hoeller 37ba1b966e Seamless support for Groovy bean definitions mixed with XML bean definitions
GroovyBeanDefinitionReader and Groovy ApplicationContexts redirect ".xml" files to XmlBeanDefinitionReader now, similar to what they've been doing for importBeans directives already. Analogously, @ImportResource for configuration classes redirects ".groovy" to GroovyBeanDefinitionReader now.

Issue: SPR-11924
2014-06-30 22:53:25 +02:00
Juergen Hoeller 442bd682a7 Polishing
Issue: SPR-11910
2014-06-26 18:14:51 +02:00
Juergen Hoeller a9b650fd0f DefaultAdvisorChainFactory never passes null into ClassFilter, enabling async advisor to work without target class as well
Issue: SPR-11910
2014-06-26 18:12:44 +02:00
Juergen Hoeller 98d6f7b443 Polishing 2014-06-26 16:01:24 +02:00
Juergen Hoeller cc917de24d Polishing 2014-06-26 11:44:07 +02:00
Juergen Hoeller b3e3c5312f Introduced AnnotationConfigRegistry as common interface for AnnotationConfig(Web)ApplicationContext
Issue: SPR-11814
2014-06-26 11:43:03 +02:00
Brian Clozel 9919a98231 HttpHeaders fails getAllow if set to EmptyCollection
Prior to this commit, calls to getAllow would fail is setAllow was set
to an EmptyCollection right before.

    java.lang.IllegalArgumentException: No enum constant
    org.springframework.http.HttpMethod

This commit fixes this by testing the header value for an empty value
before trying to use it to get a value from the Enum.

Issue: SPR-11917
2014-06-25 23:12:35 +02:00
Juergen Hoeller d239016a8c UriComponentBuilder allows for multiple independent build() calls on same builder instance
Issue: SPR-11885
2014-06-25 13:19:28 +02:00
Juergen Hoeller 18131bf611 Consistent declaration of private static final logger variables
Issue: SPR-11905
2014-06-24 14:02:05 +02:00
Juergen Hoeller 88eabe874c Latest dependency updates (Jackson 2.4, Jetty 9.2.1, H2 1.4.178, Apache HttpClient 4.3.4) 2014-06-17 21:58:11 +02:00
Rossen Stoyanchev 0dc6082b01 Support java.util.Optional for @MVC named value args
After this change, java.util.Optional is supported with @RequestParam,
@RequestHeader, and @MatrixVariable arguments in Java 8. When Optional
is used the required flag is effectively ignored.

Issue: SPR-11829
2014-06-16 14:16:56 -04:00
Rossen Stoyanchev b214db3fc8 Rename HttpStatus 308 to Permanent Redirect
Issue: SPR-11854
2014-06-10 18:51:22 -04:00
Rossen Stoyanchev 56a82c1cbe Add dependency ordering for @ModelAttribute methods
Before this change @ModelAttribute methods were not invoked in any
particular order other than ensuring global @ControllerAdvice methods
are called first and local @Controller methods second.

This change introduces a simple algorithm that selects the next
@ModelAttribute method to invoke by making a pass over all methods and
looking for one that has no dependencies (i.e. @ModelAttribute
input arguments) or has all dependencies resolved (i.e. available in
the model). The process is repeated until no more @ModelAttribute
methods remain.

If the next @ModelAttribute method cannot be determined because all
remaining methods have unresolved dependencies, the first available
method is picked anyway just as before, i.e. with required
dependencies created through the default constructor.

Examples in ModelFactoryOrderingTests.

Issue: SPR-6299
2014-06-07 16:21:36 -04:00
Rossen Stoyanchev e374769ecc Polish ModelFactory 2014-06-07 16:21:35 -04:00
Juergen Hoeller ae66e45887 Refined tests for FactoryBean return type resolution on @Bean methods
Issue: SPR-11842
2014-06-07 00:24:45 +02:00
Juergen Hoeller 85b2c7d116 AbstractAutowireCapableBeanFactory's getTypeForFactoryBean considers FactoryBean<Object> declarations as non-indicative (just like raw declarations)
Issue: SPR-11842
2014-06-06 18:43:29 +02:00
Rossen Stoyanchev c269d27bde Improve no content handling in MockHttpServletRequest
Issue: SPR-11764
2014-06-06 11:25:15 -04:00
Juergen Hoeller f7b465390c Moved @Uses annotations to org.springframework.lang; fixed Base64Utils to declare Java 8, and fixed PathResource's declaration to refer to Java 7.
Issue: SPR-11604
2014-06-04 21:34:23 +02:00
Juergen Hoeller 64bb308763 GsonBuilderUtils for programmatic Base64 serialization setup; common Base64Utils class adapts between Java 8 and Commons Codec
Issue: SPR-9488
2014-06-04 13:22:11 +02:00
Juergen Hoeller 5ed9bedf32 Introducing GroovyWebApplicationContext along the lines of XmlWebApplicationContext and GenericGroovyApplicationContext
Also includes minor dependency updates such as Groovy 2.3.2.

Issue: SPR-11371
2014-05-30 17:35:00 +02:00
Juergen Hoeller 8220832c4e Polishing 2014-05-27 18:29:51 +02:00
Juergen Hoeller 22a38d4547 Revised GsonFactoryBean's configuration properties; made prettyPrinting test pass on Windows
Issue: SPR-9488
2014-05-27 18:26:48 +02:00
Juergen Hoeller 8f2ed66b4a ServletRequestAttributes considers standard Number subclasses (as defined in NumberUtils) as immutable
Issue: SPR-11738
2014-05-27 17:43:31 +02:00
Rossen Stoyanchev bc3ca2dea1 Polish 2014-05-22 22:21:52 -04:00
Roy Clarkson 811330f5c8 Add GsonHttpMessageConverter
This commit adds support to read and write JSON using the Google Gson
library. GsonHttpMessageConverter offers default Gson configuration, but
can be customized by using GsonFactoryBean. GsonFactoryBean includes
several convenience properties for configuring the internal GsonBuilder
and the resulting Gson object.

By default Gson converts byte arrays to JSON arrays instead of a Base64
encoded string. GsonBase64ByteArrayJsonTypeAdapter provides support to
read and write Base64 encoded byte arrays, and can be enabled in
GsonFactoryBean.

RestTemplate will enable GsonHttpMessageConverter only if Jackson 2 is
not found on the class path, because by default GsonHttpMessageConverter
supports the same media types as Jackson.

Issue: SPR-9488
2014-05-22 22:21:52 -04:00
Rossen Stoyanchev 1338d46a6e Add JSONP support for MappingJackson2MessageConverter
Issue: SPR-9899
2014-05-20 12:13:44 -04:00
Juergen Hoeller c7d1c49d6d Servlet 3 multipart request implements getParameterMap defensively as well
Issue: SPR-11074
2014-05-20 11:10:16 +02:00
Juergen Hoeller 6fef8b996c Polishing 2014-05-20 10:46:06 +02:00
Rossen Stoyanchev 8e096aeef5 Disable URL resolution in DTD declarations
Issue: SPR-11768
2014-05-19 22:45:12 -04:00
Juergen Hoeller a16eeabc4e Further UriComponentsBuilder javadoc revision
(cherry picked from commit 54636b3)
2014-05-20 01:26:08 +02:00
Juergen Hoeller d9b39ad691 Consistent use of IllegalStateException instead of InternalError for UnsupportedEncodingException cause 2014-05-20 00:37:09 +02:00
Juergen Hoeller 73c9d09024 UriComponentsBuilder.toUriString instead of RequestContext.getMvcUrl (breaking cyclic dependency between web.servlet.support and web.servlet.mvc) 2014-05-20 00:35:09 +02:00
Rossen Stoyanchev 51fc3b4aaf Refactor @JsonView support w/ ResponseBodyInterceptor
The newly added support for ResponseBodyInterceptor is a good fit for
the (also recently added) support for the Jackson @JsonView annotation.

This change refactors the original implementation of @JsonView support
for @ResponseBody and ResponseEntity controller methods this time
implemented as an ResponseBodyInterceptor.

Issue: SPR-7156
2014-05-19 15:47:16 -04:00
Juergen Hoeller 6188550a48 ServletRequestAttributes skips well-known immutable values when updating accessed session attributes
Issue: SPR-11738
2014-05-19 16:00:29 +02:00
Juergen Hoeller 82336c320d Servlet 3 multipart request implements getParameterNames defensively (for WebLogic 12 compatibility)
This commit also includes lazy resolution support for StandardServletMultipartResolver, along the lines of existing lazy mode in CommonsMultipartResolver.

Issue: SPR-11074
Issue: SPR-11730
2014-05-18 20:26:02 +02:00
Juergen Hoeller ea88bc2c81 Servlet/PortletResponse supported as a resolvable dependency now (in particular for web controllers)
This feature required support for response exposure on Servlet/PortletRequestAttributes, instead of just in the Servlet/PortletWebRequest subclasses.

Issue: SPR-11795
2014-05-16 18:06:29 +02:00
Sebastien Deleuze be0b69cbf1 Add support for Jackson serialization views
Spring MVC now supports Jackon's serialization views for rendering
different subsets of the same POJO from different controller
methods (e.g. detailed page vs summary view).

Issue: SPR-7156
2014-05-15 23:03:33 -04:00
Rossen Stoyanchev 3bdf8aefa9 Polish 2014-05-15 13:59:36 -04:00
Arjen Poutsma 0499fcbeb2 Move ResponseEntityBuilder into ResponseEntity
Moved the ResponseEntityBuilder into the ResponseEntity itself.

Issue: SPR-11752
2014-05-15 13:41:25 -04:00
Brian Clozel f651065b5e Polish 2014-05-14 18:37:31 +02:00
Arjen Poutsma eb65a37f4b Provide builder for ResponseEntity
This commit introduces a ResponseEntityBuilder, which allows for
building of a ResponseEntity through a fluent API.

Issue: SPR-11752
2014-05-14 08:26:22 -04:00
Rossen Stoyanchev 9d479feadd Add naming strategy for @MVC request mappings.
This change adds a strategy for assigning a default name to an
@RequestMapping controller method. The @RequestMapping annotation
itself now has a name attribute allowing the explicit assignment
of a mapping name.

This is mainly intended for use in EL expressions in views. The
RequestContext class now provides a getMvcUrl method that internally
delegates to MvcUriComponents to look up the handler method.

See the Javadoc of MvcUriComponents.fromMappingName.

Issue: SPR-5779
2014-05-06 15:27:53 -04:00
Mattias Severson f2991da6d6 Made string constants in HttpHeaders public
Issue: SPR-11749
2014-05-01 13:37:39 -04:00
Rossen Stoyanchev 676282c66e Support ListenableFuture on @RequestMapping methods
Issue: SPR-11695
2014-05-01 12:28:59 -04:00
Rossen Stoyanchev 0d2aa51576 Update ContentNegotiationManager for unknown path exts
This change refines the logic of "mapping" content negotiation
strategies with regards to how to handle cases where no mapping is
found.

The request parameter strategy now treats request parameter values that
do not match any mapped media type as 406 errors.

The path extension strategy provides a new flag called
"ignoreUnknownExtensions" (true by default) that when set to false also
results in a 406. The same flag is also exposed through the
ContentNegotiationManagerFactoryBean and the MVC Java config.

Issue: SPR-10170
2014-05-01 12:03:06 -04:00
Stephane Nicoll bd85c916eb Integrate animal sniffer
Animal sniffer provides tools to assist verifying that classes
compiled with a newer JDK are compatible with an older JDK.

This integratesthe latest version of the tool (1.11) that
permits the use of custom annotations. Added @UsesJava7,
@UsesJava8 and @UsesSunHttpServer and annotated the few places
where we rely on a specific environment.

The verification process can be invoked by running the 'sniff'
task.

Issue: SPR-11604

polishing
2014-04-30 13:51:01 +02:00
Chexpir 77a250ef92 Update RequestMapping javadoc typo. 2014-04-28 22:13:17 -04:00
Juergen Hoeller 8e6e6c22af Test for base package specified as config location
Issue: SPR-11647
2014-04-28 21:31:38 +02:00
Juergen Hoeller 6f2e61b19f Polishing
(cherry picked from commit c97c246)
2014-04-28 00:47:50 +02:00
Juergen Hoeller ec7d80b851 Polishing 2014-04-23 23:03:47 +02:00
Juergen Hoeller 21f9ca088d ServletServerHttpResponse specifically checks for Servlet 3.0's HttpServletResponse.getHeader(String) method
Issue: SPR-11712
2014-04-23 22:47:54 +02:00
Juergen Hoeller 794e859e68 checkNotModified leniently handles IE-10-style If-Modified-Since values and silently proceeds if header value cannot be parsed at all
Issue: SPR-11727
2014-04-23 18:16:43 +02:00
Juergen Hoeller 3f392e32f5 ShallowEtagHeaderFilter writes body early on sendError/sendRedirect and interprets setContentLength/setBufferSize as a hint for capacity increase
Issue: SPR-11705
Issue: SPR-11717
2014-04-22 23:14:48 +02:00
Stephane Nicoll 5559209233 Remove useless imports 2014-04-22 09:57:12 +02:00
Philippe Marschall d00d0b0274 Clean up spring-web tests warnings
Clean up compiler warnings in the tests of spring-web. This commit
adds type parameters to all the types (mostly `List` and `Map`).

After this commit the only warnings in spring-web left are in
* `MockExpressionEvaluator` this can't be fixed until JSP-EL is fixed
* `Jackson2ObjectMapperFactoryBeanTests#testSetModules` that code
   would never compile with generics.
2014-04-22 07:30:42 +02:00
Sam Brannen 408fe42df2 Fix Javadoc syntax error in HttpRequestHandler 2014-04-22 01:01:07 -04:00
Juergen Hoeller 086f1eda71 Polishing 2014-04-17 22:39:47 +02:00
Sam Brannen 711c95d7d2 Clean up warnings due to removal of legacy Jackson support 2014-04-06 16:28:28 +02:00
Juergen Hoeller 8006696613 Revised ByteArrayOutputStream handling in MarshallingView and co
Issue: SPR-11646
2014-04-02 20:57:09 +02:00
Stephane Nicoll dcf5f4a6a3 javax.annotation.Priority alternative to @Order
This commit rationalizes the use of @Order so that the standard
@Priority annotation can be used instead. The handling of both
annotations are now defined in OrderUtils.

This also updates the link to the JavaEE API so that we refer to
JavaEE7 instead of JavaEE6.

Issue: SPR-11639
2014-04-01 14:30:47 +02:00
Juergen Hoeller ea1e27efa2 Require Jackson 2.0+, EhCache 2.5+, Quartz 2.1.4+
Issue: SPR-11262
2014-03-27 21:59:23 +01:00
Juergen Hoeller 074590730b Polishing 2014-03-25 00:54:02 +01:00
Juergen Hoeller 53352882ca Polishing 2014-03-24 22:58:33 +01:00
Juergen Hoeller dd7f54c3c0 Revised ResizableByteArrayOutputStream as an actual subclass of ByteArrayOutputStream, and consistently applied appropriate ByteArrayOutputStream initial capacities across the codebase
Issue: SPR-11594
2014-03-24 22:57:38 +01:00
Brian Clozel ae012ae6e2 ShallowEtagHeaderFilter use specified contentlength
Prior to this commit, the ShallowEtagHeaderFilter did not use the
content length given by the content generator to set the
ByteArrayOutputStream's buffer size.
This can lead to performance issues for large content since the buffer
grows as the content is being written.

This commit adds a new ByteArrayOutputStream variant called
ResizableByteArrayOutputStream. This implementation has public methods
for modifying the internal buffer size and does not synchronize on
buffer access.
This commit also make use of this new variant in
ShallowEtagHeaderFilter.

Issue: SPR-8271
2014-03-24 12:11:59 +01:00
Juergen Hoeller 90e3dbb0f5 BufferedImageHttpMessageConverter ignores empty MIME types
Issue: SPR-11581
2014-03-21 14:43:03 +01:00
Stephane Nicoll 4cd818b9e4 Harmonize log configuration
Prior to this commit, the codebase was using a mix of log4j.xml
and log4j.properties for test-related logging configuration. This
can be an issue as log4j takes the xml variant first when looking
for a default bootstrap configuration.

In practice, some modules declaring the properties variant were
taking the xml variant configuration from another module.

The general structure of the configuration has also been
harmonized to provide a standard console output as well as an
easy way to enable trace logs for the current module.
2014-03-20 09:43:29 -07:00
Juergen Hoeller e0757e7ed6 Detect ControllerAdvice beans in ancestor contexts as well
Issue: SPR-11570
2014-03-18 22:29:50 +01:00
Sam Brannen 9dcd03d862 Clean up imports and warnings 2014-03-14 17:34:21 +01:00
Juergen Hoeller 791f58e6be Polishing 2014-03-13 17:31:39 +01:00
Rossen Stoyanchev 6b31074e4a Add HTTP series check shortcut methods to HttpStatus
Issue: SPR-11424
2014-03-12 17:04:16 -04:00
Juergen Hoeller 4d3ca4319e Polishing 2014-03-11 22:09:46 +01:00
Juergen Hoeller bbcb1837c5 Polishing
Issue: SPR-11442
2014-03-10 18:31:03 +01:00
Stephane Nicoll 7a6ec69523 Fix custom config with older HttpClient
Since HttpClient 4.3, custom configuration such as the connection
timeout and the socket timeout are set in a RequestConfig object
stored in the HttpContext.

Unfortunately, older HttpClients are not supporting this
infrastructure and new clients throw an exception when the
deprecated API is used.

This commit detects if the client is an "old" implementation and
set the configuration through the deprecated means to restore
full backward compatibility with these features.

Issue: SPR-11442
2014-03-10 17:42:09 +01:00
Juergen Hoeller 3080ff3890 Polishing 2014-03-06 14:18:26 +01:00
Rossen Stoyanchev 49d7bda722 Improve CORS handling in AbstractSockJsService
After this change, AbstractSockJsService does not add CORS headers if
the response already contains an "Access-Control-Allow-Origin" header.
Essentially it backs off assuming CORS headers are handled centrally
e.g. through a Filter.

In order to support this, the ServletServerHttpResponse now returns an
instance of HttpHeaders that also provides access to headers already
present in the HttpServletResponse.

Issue: SPR-11443
2014-03-05 21:06:46 -05:00
Sam Brannen 9891bdc7b4 Clean up "abstract" test issues
- Deleted empty AbstractWebSocketClientTests class.

 - AbstractServletHandlerMethodTests and AbstractHttpRequestTests are
   now actually declared as abstract.

 - The following classes are not abstract but currently have an
   "Abstract" prefix and therefore get ignored by the Gradle build.
   This commit renames each of these by deleting the "Abstract" prefix.

   - AbstractFlashMapManagerTests
   - AbstractMappingContentNegotiationStrategyTests
   - AbstractSockJsServiceTests
   - AbstractWebSocketHandlerRegistrationTests
2014-03-05 12:41:26 +01:00
Juergen Hoeller 9b771573ec Log4jWebConfigurer does not try to parse empty "log4jRefreshInterval" context-param
Issue: SPR-11507
2014-03-04 13:31:59 +01:00
Rossen Stoyanchev c553d681f1 Add Servlet 3.1 methods to mock request
Issue: SPR-11492
2014-02-28 12:28:17 -05:00
Rossen Stoyanchev c4000727ef Move customize(Un)Marshaller methods to abstract class
Issue: SPR-11488
2014-02-28 11:54:34 -05:00
Sebastien Deleuze 45be8c0692 Add marshalling hooks in Jaxb2RootElementHttpMessageConverter
Allow Jaxb2RootElementHttpMessageConverter subclasses to customize
the {@link Marshaller} and the {@link Unmarshaller} created by the
message converter.

Issue: SPR-11488
2014-02-28 11:48:31 -05:00
Rossen Stoyanchev edba32b309 Add processExternalEntities support to OXM
Update OXM AbstractMarshaller to support processing of external
XML entities. By default external entities will not be processed.

Issue: SPR-11376
2014-02-18 15:54:30 -08:00
Rossen Stoyanchev 268657b6cb Add PropertyNamingStrategy field to ObjectMapperFB
Issue: SPR-11431
2014-02-17 14:57:22 -05:00
Juergen Hoeller bde4964af5 Polishing 2014-02-14 23:48:13 +01:00
Juergen Hoeller 8a96d1a6ee Polishing 2014-02-14 23:40:03 +01:00
Juergen Hoeller 9c6df766cd Related polishing
Issue. SPR-11428
2014-02-14 21:38:44 +01:00
Brian Clozel 6fba8292f5 Restrict ETag generation in ShallowEtagHeaderFilter
Prior to this commit, all 2xx HTTP responses were eligible for ETag
generation in ShallowEtagHeaderFilter. In some cases, this would use
CPU resources for no reason since HTTP clients would not use ETags.

This commit is an optimization and restricts ETags generation in cases
where (all conditions must be met):
- response has a 2xx status
- request is a GET
- response does not contain "no-store" in its "Cache-Control" header

Issue: SPR-11110
2014-02-14 09:52:40 +01:00
Rossen Stoyanchev 0cb27f4bc5 Allow HttpMethod as a controller method argument
Issue: SPR-11425
2014-02-13 12:16:24 -05:00
Juergen Hoeller 0ec99fdef7 Polishing 2014-02-12 18:36:04 +01:00
Juergen Hoeller cead06a3d9 Polishing 2014-02-12 00:12:52 +01:00
Juergen Hoeller 1a1c72ce4b Revised InvocableHandlerMethod exception handling
Issue: SPR-11281
2014-02-11 23:48:10 +01:00
Juergen Hoeller 5f1592a61a Consistently avoid close() call on Servlet OutputStream
Issue: SPR-11413
2014-02-11 23:42:37 +01:00
Rossen Stoyanchev 7301b58ec9 Improve info on use of @Controller's with aop proxying
Before this change, issues surrounding the use of @Controller's in
combination with AOP proxying, resulted in an IllegalArgumentException
when trying to invoke the controller method.

This change detects such cases proactively and reports them with a
clear recommendation to use class-based proxying when it comes to
@Controller's. This is the most optimcal approach for controllers
in many respects, also allows @MVC annotations to remain on the
class.

The documentation has also been updated to have a specific section
on @Controller's and AOP proxying providing the same advice.

Issue:SPR-11281
2014-02-11 12:25:54 -05:00
Rossen Stoyanchev 12598f8581 Fix issue w/ use of UrlPathHelper's urlDecode property
Before this change the getPathWithinServletMapping method of
UrlPathHelper could not work properly when a default servlet mapping
(i.e. "/") was used in combination with urlDecode=false. The fact that
the getServletPath() method of HttpServletRequest always returns a
decoded path was getting in the way.

Although there is no way to check Servlet mappings through the Servlet
API, this change aims to detect the given scenario and returns the full
path following the context path thus avoiding URL decoding.

Note that the same can be achieved by setting urlDecode=false and
alwaysUseFullPath=true. However this change ensures that urlDecode
works properly without having to know that.

Issue: SPR-11101
2014-02-10 21:08:57 -05:00
Sam Brannen c335e99e3f Remove trailing whitespace from source code 2014-02-08 17:30:39 +01:00
Sam Brannen 1f778530b5 Polish test classes
- Consistent importing of org.junit.Assert.*;
- Proper declaration of expected exceptions via @Test(expected).
- Renamed SpEL ExpressionTestCase to AbstractExpressionTests.
- Formatting and test method naming conventions.
2014-02-08 17:24:11 +01:00
Juergen Hoeller 919d6ccb3b Actually log the cause of canRead/canWrite failures
Issue: SPR-11403
2014-02-07 17:27:17 +01:00
Rossen Stoyanchev 42d0470d94 Improve expanding in MvcUriComponentsBuilder
Before this change MvcUriComponentsBuilder could not create a
UriComponentsBuilder for methods where the mapping has a URI variable
and no matching method argument for it.

For example a URI variable may be in the type-level mapping but not
all methods may have an @PathVariable argument for it.

This fix addresses the shortcoming such that MvcUriComponentsBuilder
expands the method argument values available to it and leaves remaining
URI variables to be further expanded via UriComponents.expand().

Issue: SPR-11391
2014-02-06 16:55:19 -05:00
Sam Brannen 67142dcb0a Polish Javadoc in @*ExceptionHandler 2014-02-05 20:15:50 +01:00
Rossen Stoyanchev 1a8629d408 Fix failing test 2014-02-03 21:44:13 -05:00
Sam Brannen b8ed2f4967 Ensure all tests are executed in the Gradle build
Prior to this commit several test classes named "*Test" were not
recognized as tests by the Gradle build. This is due to the configured
inclusion of '**/*Tests.*' which follows Spring's naming convention for
test classes.

This commit addresses this issue by:

 - Renaming real test classes consistently to "*Tests".
 - Renaming internal test classes to "*TestCase".
 - Renaming @WebTest to @WebTestStereotype.
 - Disabling broken tests in AnnoDrivenStaticEntityMockingControlTest.
 - Modifying the Gradle build configuration so that classes ending in
   either "*Tests" or "*Test" are considered test classes.

Issue: SPR-11384
2014-02-03 23:16:47 +01:00
Rossen Stoyanchev 1c5cab2a40 Add external entity test
Issue: SPR-11376
2014-02-03 16:57:03 -05:00
Juergen Hoeller f053f60630 Revised javadoc and related polishing
Issue: SPR-11383
2014-02-03 16:05:00 +01:00
Juergen Hoeller 5f2429429f Defensively handle ServletRequestAttributes casting in requestDestroyed callback
Issue: SPR-11378
2014-02-01 11:04:36 +01:00
Rossen Stoyanchev b6da7e2795 Fix test in Jaxb2RootElementHttpMessageConverterTests 2014-01-31 20:17:44 -05:00
Rossen Stoyanchev e680e34620 Fix test class name 2014-01-31 16:26:28 -05:00
Sam Brannen 474f1b03cd Fix grammar in Javadoc for @ResponseBody 2014-01-31 17:02:40 +01:00
Juergen Hoeller 47395f6b0a Dropped explicit paragraph on web.xml version declaration
Issue: SPR-11364
(cherry picked from commit 36ab65a)
2014-01-28 17:34:27 +01:00
Juergen Hoeller c5f908b174 Consistent use of headersExtractor() template method 2014-01-28 12:56:53 +01:00
Brian Clozel 425e5a066e Add RestTemplate constructor with custom converters
Prior to this commit, RestTemplate's constructors were all initializing
default HTTPMessageConverters. Its API provides a way to replace
those converters with custom ones, but default converters are already
defined and initialized at that point, which can be an issue in some
cases (performance, classpath...).

This commits adds a new constructor for RestTemplate with a list
of message converters as argument. With this new constructor,
default message converters are never initialized.

Issue: SPR-11351
2014-01-28 11:33:45 +01:00
Brian Clozel cc0a845653 Support Part/MultiPartFile arrays in ArgumentResolvers
Prior to this commit, parts of a multipart HTTP request could be
injected in @RequestPart and @RequestParam annotated arguments, when
using types:
* MultipartFile, Collection<MultiPartFile>
* javax.servlet.Part, Collection<Part>

This commits updates @RequestParam and @RequestPart argument resolvers
and now allows the array versions of those types:
* Part[]
* MultiPartFile[]

Note that the MockHtpServletRequest backing tests for standard
Servlets implementations now uses a MultiValueMap to store parts
(versus a simple hashmap).

Issue: SPR-11353
2014-01-27 18:09:29 +01:00
Sam Brannen 78542777d6 Introduce value attribute in @RestController
Stereotype annotations should support a 'value' attribute for
specifying the name of the Spring-managed component; however,
@RestController currently does not provide such an attribute.

This commit introduces a 'value' attribute in @RestController so that
developers can provide custom names for components annotated with
@RestController.

Issue: SPR-11360
2014-01-27 12:07:23 +01:00
Juergen Hoeller 21eb8db5bc Polishing
Issue: SPR-11357
2014-01-24 18:30:31 +01:00
Juergen Hoeller 42db41e007 Polishing 2014-01-23 20:59:53 +01:00
Juergen Hoeller 9c3a972dac Polishing
Issue: SPR-11297
(cherry picked from commit fc36184)
2014-01-23 00:16:29 +01:00
Juergen Hoeller 3514242486 SourceHttpMessageConverter's supports implementation needs to check for StAXSource
Issue: SPR-11341
2014-01-21 16:35:47 +01:00
Rossen Stoyanchev 17e492e641 Polish
Issue: SPR-11129
2014-01-20 21:48:57 -05:00
Juergen Hoeller e2c6e637a4 Polishing 2014-01-16 00:04:20 +01:00
Juergen Hoeller 17cc63ef63 checkNotModified needs to consider HEAD as well
Issue: SPR-11317
2014-01-15 23:06:47 +01:00
Juergen Hoeller a5f9b29292 Polishing 2014-01-15 22:53:46 +01:00
Juergen Hoeller 91881ff036 Introduced "globalInitializerClasses" next to the existing "contextInitializerClasses", applying to FrameworkServlets as well
Issue: SPR-11314
2014-01-15 22:21:27 +01:00
Juergen Hoeller 5661d3826c Fixed Jackson2ObjectMapperFactoryBean class name in javadoc examples 2014-01-05 00:15:33 +01:00
Juergen Hoeller 11b3fe2289 Added setModulesToInstall with convenient Class vararg, renamed setFindModules to setFindModulesViaServiceLoader, made existing setModules override any other setting
Issue: SPR-11040
2014-01-04 23:29:05 +01:00
Rossen Stoyanchev 12fe9174f0 Make ObjectMapper configurable in spring-messaging
Issue: SPR-11279
2014-01-02 11:27:18 -05:00
Juergen Hoeller 0657136605 Support for Jackson's findModules and autodetection of JSR-310 and Joda-Time support
Issue: SPR-11040
2013-12-29 21:52:58 +01:00
Juergen Hoeller 85921808b3 MappingJackson2(Http)MessageConverter logs warnings after canRead/canWrite checks
This change involves a general upgrade to Jackson 2.3 in our build.

Issue: SPR-11261
2013-12-29 21:50:43 +01:00
Juergen Hoeller 260bbe319d Fixed accidental use of Java 8 getParameterCount(), plus polishing of related classes
Issue: SPR-11245
2013-12-18 18:08:32 +01:00
Rossen Stoyanchev ff92f5af57 Fix typo
Issue: SPR-11241
2013-12-17 08:26:50 -05:00
Juergen Hoeller 2a3ca619f9 Polishing
Issue: SPR-11221
2013-12-17 12:40:21 +01:00
Rossen Stoyanchev 5f38996cd6 Add methods for static resolution of @ExceptionHandler 2013-12-09 08:19:17 -05:00
Juergen Hoeller f70739430b Polishing 2013-12-08 23:27:31 +01:00
Juergen Hoeller ea8a2095ec Polishing 2013-12-06 21:51:18 +01:00
Juergen Hoeller 2a52decbbc Polishing (including removal of javadoc imports that show as package cycles in IntelliJ) 2013-12-02 23:57:00 +01:00
Phillip Webb 043a41e382 Consistent whitespace after imports
Update code to have a consistent number of new-line characters after
import statements.
2013-11-26 15:14:43 -08:00
Phillip Webb 15698860e1 General polish of new 4.0 classes
Apply consistent styling to new classes introduced in Spring 4.0.

- Javadoc line wrapping, whitespace and formatting
- General code whitespace
- Consistent Assert.notNull messages
2013-11-26 15:11:18 -08:00
Phillip Webb a31ac882c5 Fix various javadoc warnings 2013-11-26 13:25:37 -08:00
Eric Dahl e9f78f6043 Fix various typos
Fix a variety of typos throughout the project, primarily in
comments (javadoc or otherwise) but also in a handful of log messages
and a couple exception messages.

ISSUE: SPR-11123
2013-11-25 15:58:27 -08:00
Phillip Webb 59002f2456 Fix remaining compiler warnings
Fix remaining Java compiler warnings, mainly around missing
generics or deprecated code.

Also add the `-Werror` compiler option to ensure that any future
warnings will fail the build.

Issue: SPR-11064
2013-11-25 12:52:42 -08:00
Juergen Hoeller 0de112198e Rely on presence of Servlet 2.5's ServletContext.getContextPath() 2013-11-20 14:50:32 +01:00
Brian Clozel cc4faa5990 Fix standard multipart binding + Polish
Fixing standard multipart binding when multiple parts share
the same name.

Uncomment previously @Ignored tests now that Jetty supports
Servlet 3.0 spec.

Issue: SPR-10591
2013-11-19 17:13:31 -08:00
Juergen Hoeller b43901ed86 Upgraded to JSF 2.0 baseline; building against JSF 2.2 now 2013-11-15 12:07:42 +01:00
Rossen Stoyanchev 2ae6a6a341 Disable ext entities in SourceHttpMessageConverter
This change disables the processing of external entities in
SourceHttpMessageConverter by default and provides an option to enable
it if required.
2013-11-05 09:23:20 -05:00
Rossen Stoyanchev bfa6c2d5a2 Tweak method signatures in HttpComponentsClientHttpRF
This change replaces CloseableHttpClient with HttpClient in the
methods signatures of HttpComponentsClientHttpRequestFactory.
This allows 3rd party libraries such as Spring OAth, which configure
an instance of HttpComponentsClientHttpRequestFactory on the
RestTemplate to remain compatible with both Spring Framework 3/4

Issue: SPR-11053
2013-10-31 11:10:35 -04:00
Juergen Hoeller 84bc474016 Upgraded to Apache HttpComponents HttpClient 4.3.1 and HttpAsyncClient 4.0 GA, as well as Jackson 2.2.2 2013-10-31 15:26:11 +01:00
Sam Brannen 2e6c998168 Update Javadoc for mocks regarding Servlet 3.0
Commit deba32cad9 upgraded the Servlet API mocks to Servlet 3.0;
however, not all of the Javadoc was updated accordingly.

This commit updates the remaining Javadoc with regard to Servlet 3.0 as
the baseline for mocks in the spring-test module.

In addition, this commit syncs up the mocks used for internal testing in
the spring-web module with the most current versions from spring-test.

Issue: SPR-11049
2013-10-31 11:51:15 +01:00
Rossen Stoyanchev 5d8fac86d7 Add timeout async request handling to OSIV components
This change adds async web request timeout handling to OSIV filters
and interceptors to ensure the session or entity manager is released.

Issue: SPR-10874
2013-10-30 22:54:21 -04:00
Brian Clozel 397d52ad17 Upgrade to Jetty 9.1.0 .RC0
This commit upgrades Jetty to the latest available 9.1.x version while
also preserving compatibility with 9.0.x.
2013-10-29 15:02:25 -04:00
Rossen Stoyanchev 81dda069af Update WebSocket extensions change
- add WebSocketHttpHeaders
- client-side support for WebSocket extensions
- DefaultHandshakeHandler updates
- replace use of ServletAttributes in JettyRequestUpgradeStratey
- upgrade spring-web to jetty 9.0.5
2013-10-28 22:40:22 -04:00
Rossen Stoyanchev cf5db8362b Replace MvcUrls with MvcUriComponentsBuilder
Issue: SPR-8826
2013-10-25 22:29:38 -04:00
Phillip Webb 12e896ed8b Polish 2013-10-25 16:42:47 -07:00
Rossen Stoyanchev bafc73f147 Integrate suggested support for creating MVC URLs
The key contract is MvcUrls. An instance is automatically created with
the Spring MVC namespace and the MVC Java config but can also be easily
created in any configuration.

Some example tests can be found in DefaultMvcUrlsTests.

Issue: SPR-10665, SPR-8826
2013-10-21 16:26:08 -04:00
Oliver Gierke 4fd27b12fc Introduced MvcUriComponentsBuilder to create URIs pointing to controller methods.
MvcUriComponentsBuilder allows creating URIs that point to Spring MVC
controller methods annotated with @RequestMapping. It builds them by
exposing a mock method invocation API similar to Mockito, records the
method invocations and thus builds up the URI by inspecting the mapping
annotations and the parameters handed into the method invocations.

Introduced a new SPI UriComponentsContributor that should be implemented 
by HandlerMethodArgumentResolvers that actually contribute path segments 
or query parameters to a URI. While the newly introduced 
MvcUriComponentsBuilder looks up those UriComponentsContributor instances 
from the MVC configuration.

The MvcUriComponentsBuilderFactory (name to be discussed - MvcUris maybe?) 
prevents the multiple lookups by keeping the UriComponentsBuilder 
instances in an instance variable. So an instance of the factory could 
be exposed as Spring bean or through a HandlerMethodArgumentResolver to 
be injected into Controller methods.

Issue: SPR-10665, SPR-8826
2013-10-21 16:26:07 -04:00
Rossen Stoyanchev 4f28c77db7 Polish ControllerAdvice selectors
Issue: SPR-10222
2013-10-18 12:24:55 -04:00
Brian Clozel c4a8bf9c4d Add new features on @ControllerAdvice
Prior to this commit, @ControllerAdvice annotated beans would
assist all known Controllers, by applying @ExceptionHandler,
@InitBinder, and @ModelAttribute.

This commit updates the @ControllerAdvice annotation,
which accepts now base package names, assignableTypes,
annotations and basePackageClasses.

If attributes are set, only Controllers that match those
selectors will be assisted by the annotated class.
This commit does not change the default behavior when
no value is set, i.e. @ControllerAdvice().

Issue: SPR-10222
2013-10-18 11:35:06 -04:00
Juergen Hoeller 187b681b9e Consistency between InvocableHandlerMethod in web and messaging modules 2013-10-16 01:51:48 +02:00
Juergen Hoeller 3bd6dfe047 Autowiring of generic types
Includes revisions of MethodParameter and DependencyDescriptor (in particular towards a reference to the containing class). Also refines several ResolvableType method signatures.

Issue: SPR-9965
2013-10-15 00:11:23 +02:00
Juergen Hoeller 74794190a5 Implement java.io.Flushable wherever applicable 2013-10-14 23:52:31 +02:00
Rossen Stoyanchev 8ae88c20d1 Add support for resolving message headers
This change adds support for @Header and @Headers annotated method
arguments to spring-messaging. Also supported are arguments of type
MessageHeaders, and MessageHeaderAccessor (including sub-types of
MessageHeaderAccessort as long as they provide a wrap(Message<?>)
static factory method).

This change also renames @MessageBody to @Payload.

Issue: SPR-10985
2013-10-13 11:13:16 -04:00
Phillip Webb ca9df4d2ef Return rather than throw converted http exception
Fix HttpInvokerClientInterceptor.convertHttpInvokerAccessException to
return the translated exception rather than throwing it. This brings
the method implementation in line with the Java Doc and the obvious
original intent.

Issue: SPR-10965
2013-10-11 14:47:58 -07:00
Juergen Hoeller 4574528a27 Comprehensive update to the framework's TimeZone handling, including a new TimeZoneAwareLocaleContext and a LocaleContextResolver for Spring MVC
A few noteworthy minor changes: LocaleContext.getLocale() may return null in special cases (not by default), which our own accessing classes are able to handle now. If there is a non-null TimeZone user setting, we're exposing it to all collaborating libraries, in particular to JSTL, Velocity and JasperReports. Our JSR-310 and Joda-Time support falls back to checking the general LocaleContext TimeZone now, adapting it to their time zone types, if no more specific setting has been provided. Our DefaultConversionService has TimeZone<->ZoneId converters registered. And finally, we're using a custom parseTimeZoneString method now that doesn't accept the TimeZone.getTimeZone(String) GMT fallback for an invalid time zone id anymore.

Issue: SPR-1528
2013-10-04 23:14:08 +02:00
Juergen Hoeller 52cca48f40 Polishing 2013-10-04 22:53:49 +02:00
Juergen Hoeller 8b3afda6f4 Marked Jackson 1.x support classes as deprecated 2013-10-04 22:52:47 +02:00
Brian Clozel a5e3916724 Add Jackson's Modules registration in Jackson2OMFactoryBean
Prior to this commit, one couldn't configure Jackson's ObjectMapper
with (De)SerializerModifiers or advanced configuration features
using XML configuration.

This commit updates the FactoryBean and adds a setModule method
that will register Modules with the ObjectMapper.

Note that this commit is only about XML configuration, since
this feature was already available with JavaConfig.

Issue: SPR-10429
2013-10-02 17:23:55 -04:00
Brian Clozel e91ce23cd0 Add javax.servlet.http.Part support for data binding
Prior to this commit, Multipart databinding would only support
MultiPartFile databinding using commons-multipart.

Now the WebRequestDataBinder supports Part and List<Part>
databinding for Servlet 3.0 compliant containers.

Issue: SPR-10591
2013-10-02 17:19:44 -04:00
Rossen Stoyanchev 92795f463a Polish
Issue: SPR-10539
2013-09-25 12:47:50 -04:00
Brian Clozel 2dd4480103 Add IPv6 support in RestTemplate
Prior to this commit, RestTemplate would not would
not accept IPv6 raw addresses in URLs because UriComponentsBuilder
would not parse/encode the Host part correctly.

The UriComponentsBuilder now parses and encode raw IPv6 addresses
in the "[1abc:2abc:3abc::5ABC:6abc]" format and also supports the
use of IPv6 scope_ids (see JDK8 java.net.Inet6Address),
like "[1abc:2abc:3abc::5ABC:6abc%eth0]".

Issue: SPR-10539
2013-09-25 16:28:12 +02:00