Commit Graph

7873 Commits

Author SHA1 Message Date
Chris Beams
1070e4d5c1 Initialize FrameworkServlet property sources eagerly
Prior to this change,
FrameworkServlet#configureAndRefreshWebApplicationContext called
 #postProcessWebApplicationContext(wac) and #applyInitializers(wac)
prior to #refresh, but because servlet-based property source stubs were
not replaced until #refresh, any post-processing or initialization
routines could not benefit from accessing the Environment to retrieve
properties from the ServletContext or ServletConfig.

The workaround to this problem is detailed in SPR-9610 - the user simply
needed to call WebApplicationContextUtils#initServletPropertySources
manually within their ApplicationContextInitializer (or overridden
 #postProcessWebApplicationContext method)

This commit ensures that
FrameworkServlet#configureAndRefreshWebApplicationContext calls
WebApplicationContextUtils#initServletPropertySources eagerly, prior to
invoking #postProcessWebApplicationContext and #applyInitializers.
Related Javadoc has also been updated throughout to clarify the behavior
of #initServletPropertySources, when it can be called and what the
effects are, etc.

Note also that a reproduction issue was added to demonstrate the problem
and verify its resolution [1].

[1]: https://github.com/SpringSource/spring-framework-issues/tree/master/SPR-9610

Issue: SPR-9610
2012-11-02 13:05:48 +01:00
Rossen Stoyanchev
242bf7c4e3 Refine hamcrest dependency in spring-test-mvc project
1) removed the hamcrest-all dependency requirement and replaced it with
the more focused hamcrest-library dependency

2) added MatcherAssertionErrors as a replacement of
org.hamcrest.MatcherAssert, which in hamcrest 1.1 is only available
through the hamcrest-all dependency (and not in hamcrest-core nor in
the hamcrest embedded in JUnit 4.4 through 4.8)

3) changed the required hamcrest version from 1.1 to 1.3 and made sure
the spring-test-mvc project does not rely on newer hamcrest
functionality without checking if it is available first

Applications that already depend on older versions of hamcrest
(in particular 1.1) via hamcrest-library, hamcrest-all or as part of
junit 4.4 through 4.8 should not be disrupted if they add spring-test
but may wish to exclude the hamcrest-library transitive dependency
from spring-test in order to avoid extra jars in the classpath

Applications that depend on hamcrest 1.3 should not have to do anything

Issue: SPR-9940
2012-11-01 23:58:50 -04:00
Phillip Webb
468f9c7814 Polish 2012-11-01 11:10:25 -07:00
Phillip Webb
15b64ba601 Restore -XX:MaxHeapSize=256m for gradlew.bat
Restore the MaxHeapSize setting for the Windows build only.
2012-11-01 10:29:07 -07:00
Chris Beams
bbe1301d63 Remove -XX:MaxHeapSize=256m from default GRADLE_OPTS
This setting was causing failures in the CI build, and was not present
prior to the recent updates to gradle wrapper generation.

This commit also simplifies the gradle wrapper customizations by placing
the logic in a doLast block within the original 'wrapper' task, as
to creating a second wrapper task and extending from the first.
2012-11-01 11:04:58 +01:00
Rossen Stoyanchev
c0baea58c0 Fix issue with generic @RequestBody arguments
The original commit c9b7b1 ensured the ability to read parameterized
type @RequestBody arguments via GenericHttpMessageConverter (e.g.
application/json and List<String>). However, it also affected the
ability to read @RequestBody arguments that happen are parameterized
but aren't treated as such (e.g. application/x-www-form-urlencoded and
MultiValueMap<String, String>). This commit corrects the issue.

Issue: SPR-9570
2012-10-31 21:15:16 -04:00
Rossen Stoyanchev
0e3aa0eec4 Peek into the content for @RequestBody(required=false)
For @RequestBody(required=false), it is not sufficient to check if the
InputStream is null. This change reads the first byte of the request
InputStream to determine if the request body is empty or not.

If the InputStream implementation supports mark(int) and reset(), then
we use those. Otherwise we use PushbackInputStream to read and unread
the first byte.

All of this is done only if the required flag of @RequestBody is set
to "false" (default is "true").

Issue: SPR-9942
2012-10-31 21:15:15 -04:00
Phillip Webb
742d5f6f38 Restore GRADLE_OPTS from wrappers
Run the updated build script to generate gradlew and gradlew.bat files
that have correct GRADLE_OPTS.
2012-10-31 17:30:52 -07:00
Phillip Webb
23b091b786 Remove need to manually set wrapper GRADLE_OPTS
Replace the wrapper task with a variant that automatically adds the
appropriate GRADLE_OPTS to the shell and bat files.
2012-10-31 17:29:00 -07:00
Sam Brannen
00220ebab0 Fix typo in changelog 2012-10-31 20:35:11 +01:00
Phillip Webb
6c63271f55 Update changelog 2012-10-31 12:08:44 -07:00
Sam Brannen
5b59a25a59 Update changelog
Added missing JIRA issue IDs.
2012-10-31 18:45:31 +01:00
Sam Brannen
462605987d Delete unused import 2012-10-31 17:46:24 +01:00
Sam Brannen
0b45daf5e9 Assess claims made in SPR-9799
This commit validates the claims made in SPR-9799.

 - Spr9799XmlConfigTests demonstrates that a WAC is not always necessary
   when integration testing with XML configuration that uses
   <mvc:annotation-driven />.

 - Spr9799AnnotationConfigTests demonstrates that a WAC is in fact
   necessary when integration testing with a configuration class that
   uses @EnableWebMvc.

Issue: SPR-9799
2012-10-31 17:41:25 +01:00
Phillip Webb
4cdf46f83c Polish @Imports search code
Issue: SPR-9925
2012-10-31 09:30:17 -07:00
Sam Brannen
8bb19f05ea Fix typos in Javadoc 2012-10-31 16:22:16 +01:00
Phillip Webb
3416e058a0 Ensure @Imports are processed in correct order
Issue: SPR-9925
2012-10-31 13:40:06 +01:00
Juergen Hoeller
af56b3b7e3 Extended support for meta-annotations etc 2012-10-31 12:11:12 +01:00
Juergen Hoeller
914a1b2088 @Autowired, @Value and qualifiers may be used as meta-annotations for custom injection annotations 2012-10-31 12:10:17 +01:00
Chris Beams
985cb9df11 Merge pull request #176 from philwebb/SPR-9925
# By Phillip Webb
* SPR-9925:
  Prevent duplicate @Import processing
  Polish Javadoc for @Import
  Improve #toString for AnnotationAttributes
2012-10-31 09:59:10 +01:00
Phillip Webb
6d8b37d8bb Prevent duplicate @Import processing
Refactor ConfigurationClassParser to recursively find values from
all @Import annotations, combining them into a single unique set.

This change prevents ImportBeanDefinitionRegistrars from being
invoked twice.

Issue: SPR-9925
2012-10-31 09:42:27 +01:00
Phillip Webb
e6c4840356 Polish Javadoc for @Import 2012-10-31 09:42:27 +01:00
Phillip Webb
4036ffc4d4 Improve #toString for AnnotationAttributes
Improve the #toString method for AnnotationAttributes to print array
values as a comma-separated list. This change is primarily to provide
better variable inspection when debugging code within an IDE.
2012-10-31 09:42:27 +01:00
Juergen Hoeller
2081521695 @Autowired and @Value may be used as meta-annotations for custom injection annotations 2012-10-31 09:38:13 +01:00
Juergen Hoeller
7fdb637df0 Clarified ServletConfigAware behavior in case of no ServletConfig being available
Issue: SPR-9855
2012-10-31 09:38:12 +01:00
Juergen Hoeller
54d083a6f8 Added proper synchronization and not-null check to SimpleMessageListenerContainer's doShutdown
Issue: SPR-9930
2012-10-31 09:38:11 +01:00
Rossen Stoyanchev
1acd5cff8f Polish methods to register async interceptors 2012-10-30 22:38:39 -04:00
Rossen Stoyanchev
d701464517 Add onTimeout/onCompletion callbacks to DeferredResult
Issue: SPR-9914
2012-10-30 21:58:44 -04:00
Juergen Hoeller
3a09644843 Adapted PropertySourcesPropertyResolverTests for different error message format 2012-10-31 02:53:24 +01:00
Juergen Hoeller
5b93b14392 DateTimeFormat annotation supports use as a meta-annotation as well 2012-10-31 02:53:23 +01:00
Juergen Hoeller
ee50d849a1 Polished "Could not resolve placeholder" error message 2012-10-31 02:53:22 +01:00
Juergen Hoeller
69763fe249 Added test for custom async annotation 2012-10-31 02:53:22 +01:00
Juergen Hoeller
0e0200769d ManagedResource annotation supports placeholders for String attributes
In particular, the specified object name may use a placeholder for its domain part now, allowing for several instances of the MBean to be registered against the same MBeanServer from different applications.

Issue: SPR-8244
2012-10-31 02:53:21 +01:00
Juergen Hoeller
8f8e517c0d Portlet mapping predicate compareTo implementations are transitive now
Also removed unused validateHandler code with dead cachedMappings HashMap.

Issue: SPR-9874
2012-10-31 02:53:20 +01:00
Juergen Hoeller
4ff765446e Added "jtaDataSource" property to JPA LocalContainerEntityManagerFactoryBean (for default units)
Issue: SPR-9883
2012-10-31 02:53:19 +01:00
Juergen Hoeller
88ef3ce51f DispatcherPortlet uses a forward for rendering a view as resource response
Issue: SPR-9876
2012-10-31 02:53:18 +01:00
Phillip Webb
1c7e8cfbf6 Merge pull request #99 from dsyer/SPR-4675
* SPR-4675:
  Throw on advise returning null for primitive type
  Upgrade to Hamcrest 1.3
2012-10-30 16:11:00 -07:00
Dave Syer
3e296974c4 Throw on advise returning null for primitive type
Throw an AopInvocationException when an AOP advisor returns null on
a method that should return a primitive type.

Issue: SPR-4675
2012-10-30 16:09:13 -07:00
Phillip Webb
39682b7d3f Upgrade to Hamcrest 1.3 2012-10-30 15:52:46 -07:00
Phillip Webb
22dfe93f2f Revert ConversionService SPI interface
Remove canBypassConvert() methods from the ConversionService SPI
interface, restoring it to the previous Spring 3.1 incarnation.

Bypassing conversion is now only supported when using a
GenericConversionService.

Issue: SPR-9566
2012-10-30 14:00:12 -07:00
Phillip Webb
e9cdb3d24e Polish JavaDoc 2012-10-30 12:07:31 -07:00
Phillip Webb
31331e6ad3 Avoid NPE in ObjectToObjectConverter
Bypass ObjectToObject conversion when source and object types are
identical and protect against a null source object.

Prior to this commit the TypeDescriptor was used to determine if
conversion was necessary.  This caused issues when comparing a
descriptor with annotations to one without.  The updated code
now compares using TypeDescriptor.getType().

The ObjectToObject converter will now no longer attempt to convert
null source objects.

Issue: SPR-9933
2012-10-30 11:25:10 -07:00
Chris Beams
9055a7f810 Merge pull request #156 from philwebb/SPR-9257
# By Phillip Webb
* SPR-9257:
  Resolve Collection element types during conversion
2012-10-30 14:01:16 +01:00
Phillip Webb
5a1f924ac3 Resolve Collection element types during conversion
TypeDescriptor.valueOf now uses GenericCollectionTypeResolver to resolve
Collection and Map element types whereas previously this information was
simply not supported, i.e. null.

Issue: SPR-9257
2012-10-30 14:00:50 +01:00
Chris Beams
99b2f6a081 Merge pull request #163 from philwebb/SPR-9862
# By Phillip Webb
* SPR-9862:
  Allow SpEL reserved words in type package names
2012-10-30 13:39:20 +01:00
Phillip Webb
edce2e7bca Allow SpEL reserved words in type package names
Expand the kinds of tokens considered when parsing qualified type names.
This allows previously reserved words (for example 'mod') to be used as
part of a package name.

Issue: SPR-9862
2012-10-30 13:38:37 +01:00
Chris Beams
7c399d795e Merge pull request #167 from philwebb/SPR-9707
# By Chris Beams (1) and Phillip Webb (1)
* SPR-9707:
  Introduce MessageCodeFormatter abstraction
  Provide alternative message code resolver styles
2012-10-30 12:21:37 +01:00
Chris Beams
38bfb2bd89 Introduce MessageCodeFormatter abstraction
This commit refactors changes introduced in 21760a8 as follows:

 - Introduce top-level MessageCodeFormatter interface and
   DefaultMessageCodesResolver#setMessageCodeFormatter property to allow
   for user-defined message code formatting strategies

 - Rename DefaultMessageCodesResolver.Style enum => DMCR.Format

 - Refactor DefaultMessageCodesResolver.Format to implement the new
   MessageCodeFormatter interface

The result is that users have convenient access to common formatting
strategies via the Format enum, while retaining the flexibility to
provide their own custom MessageCodeFormatter implementation if desired.

See DefaultMessageCodesResolverTests#shouldSupport*Format tests for
usage examples.

Issue: SPR-9707
2012-10-30 12:19:45 +01:00
Phillip Webb
21760a8b6b Provide alternative message code resolver styles
Introduce new 'style' property to DefaultMessageCodesResolver allowing
for alternative message styles. Current styles are PREFIX_ERROR_CODE
and POSTFIX_ERROR_CODE. The default style retains existing behavior.

Issue: SPR-9707
2012-10-30 10:09:36 +01:00
Chris Beams
a57ff506f2 Merge pull request #132 from philwebb/SPR-9692
# By Phillip Webb (6) and Chris Beams (1)
* SPR-9692:
  Review and polish pull request #132
  Support conversion from Enum Interface
  Test SpEL unconditional argument conversion
  Bypass conversion when possible
  Extend conditional conversion support
  Refactor GenericConversionService
  Additional GenericConversionService Tests
2012-10-30 09:15:57 +01:00