Commit Graph

31788 Commits

Author SHA1 Message Date
Chris Beams
f3651c9998 Polish static imports 2012-02-15 15:33:35 +01:00
Rossen Stoyanchev
a3484aebb3 Minor fix in ServletResponseMethodArgumentResolver
Issues: SPR-8983
2012-02-15 09:20:02 -05:00
Juergen Hoeller
6fd476e2c5 extracted ResourceUtils.useCachesIfNecessary(URLConnection) method (SPR-9117) 2012-02-14 21:55:29 +01:00
Juergen Hoeller
ab98f288e9 prepared for 3.1.1 release 2012-02-14 21:30:12 +01:00
Juergen Hoeller
acaf820941 CustomSQLExceptionTranslatorRegistry/Registrar etc 2012-02-14 21:29:52 +01:00
Juergen Hoeller
ddf0d071ad revised CustomSQLExceptionTranslatorRegistry/Registrar method naming 2012-02-14 21:29:22 +01:00
Juergen Hoeller
2fa87a71fa use custom InputStream traversal instead of a full byte array (SPR-9118) 2012-02-14 21:16:10 +01:00
Juergen Hoeller
fe57f74c1a PathMatchingResourcePatternResolver preserves caching for JNLP jar connections (SPR-9117) 2012-02-14 18:26:56 +01:00
Juergen Hoeller
81861ca7a8 Resource "contentLength()" implementations work with OSGi bundle resources and JBoss VFS resources (SPR-9118) 2012-02-14 14:46:45 +01:00
Juergen Hoeller
4831ca27d2 fixed MethodInvokingJobDetailFactoryBean for compatibility with Quartz 2.0/2.1 (SPR-8889) 2012-02-14 14:43:37 +01:00
Juergen Hoeller
1bfa7013a0 fixed MethodInvokingJobDetailFactoryBean for compatibility with Quartz 2.0/2.1 () 2012-02-14 14:09:41 +01:00
Chris Beams
81dfef90ef Sync with 3.1.x
* 3.1.x:
  Fix false negative test failure in ResourceTests
  Compensate for Eclipse vs Sun compiler discrepancy
2012-02-13 15:54:14 +01:00
Chris Beams
1d9d3e6ff7 Fix false negative test failure in ResourceTests
Prior to changes in commit 57851de88e,
AbstractResource#getFilename threw IllegalStateException unless
overridden by a subclass. Following that change, this method now throws
null instead, but ResourceTests#testAbstractResourceExceptions had not
been updated to reflect, resulting in a false negative failure. This has
now been fixed.

Issue: SPR-9043
2012-02-13 15:52:37 +01:00
Chris Beams
8e0b1c3a5f Compensate for Eclipse vs Sun compiler discrepancy
Eclipse allows autoboxing on type inference; Sun javac does not. This
means that variables assigned from calls to
AnnotationAttributes#getNumber should consistently use object wrappers
as opposed to number primitives. There was only one such instance
anyway, and has now been updated accordingly.
2012-02-13 15:37:19 +01:00
Chris Beams
ee36c80ca9 Sync with 3.1.x
* 3.1.x: (61 commits)
  Compensate for changes in JDK 7 Introspector
  Avoid 'type mismatch' errors in ExtendedBeanInfo
  Polish ExtendedBeanInfo and tests
  Infer AnnotationAttributes method return types
  Minor fix in MVC reference doc chapter
  Hibernate 4.1 etc
  TypeDescriptor equals implementation accepts annotations in any order
  "setBasenames" uses varargs now (for programmatic setup; SPR-9106)
  @ActiveProfiles mechanism works with @ImportResource as well (SPR-8992
  polishing
  clarified Resource's "getFilename" method to consistently return null
  substituteNamedParameters detects and unwraps SqlParameterValue object
  Replace spaces with tabs
  Consider security in ClassUtils#getMostSpecificMethod
  Adding null check for username being null.
  Improvements for registering custom SQL exception translators in app c
  SPR-7680 Adding QueryTimeoutException to the DataAccessException hiera
  Minor polish in WebMvcConfigurationSupport
  Detect overridden boolean getters in ExtendedBeanInfo
  Polish ExtendedBeanInfoTests
  ...
2012-02-13 15:17:30 +01:00
Chris Beams
0a5392e37d Compensate for changes in JDK 7 Introspector
Prior to JDK 7, java.beans.Introspector registered indexed write methods
irrespective of return type, for example either of the following methods
were legal

    void setFoo(int i, Foo foo)
    Object setFoo(int i, Foo foo)

This was considered a bug and disallowed starting with JDK 7, such that
only the former signature is a candidate.

Supporting non-void returning setter methods is exactly what
ExtendedBeanInfo was designed to do, and prior to this commit, the
implementation of ExtendedBeanInfo assumed this (somewhat surprising)
behavior from the underlying Introspector, and because it worked out of
the box, took no extra steps to recognize and register these methods.
For this reason, non-void returning indexed write methods were not
registered under JDK 7+, causing test failures in ExtendedBeanInfoTests.

Now the implementation is careful to detect these methods without any
assumption about Introspector behavior, such that they are registered in
exactly the same fashion across JDK versions.

Issue: SPR-9014
2012-02-13 15:01:06 +01:00
Chris Beams
b787a68f20 Avoid 'type mismatch' errors in ExtendedBeanInfo
Prior to this commit, ExtendedBeanInfo would add non-indexed write
methods without consideration for the presence of indexed read/write
methods, which is invalid per the JavaBeans spec and per the behavior
of java.beans.Introspector.  That is, a method with the signature

    void setFoo(Foo foo)

Should never be registered as a write method if the following method
signature is also present in the class

    void setFoo(int i, Foo foo)

In most cases, this oversight caused no problems, but in certain
situations where a bean actually contains such a mismatch of methods,
"type mismatch" errors were thrown when ExtendedBeanInfo attempted the
illegal addition against the underlying property descriptor.

The implementation is now more careful about checking the parameter type
of write methods -- if the property descriptor in question is an
IndexedPropertyDescriptor, i.e. has an indexed write method, then any
non-indexed write method candidate must have a single *array* parameter,
which conforms to the spec and to Introspector behavior.

Issue: SPR-8937
2012-02-13 15:01:06 +01:00
Chris Beams
ef143d363e Polish ExtendedBeanInfo and tests
ExtendedBeanInfo

 - Reduce log messages from warn to debug

 - Remove now-incorrect comment indicating underlying property
   descriptors are never modified (they actually are as of SPR-8806)

ExtendedBeanInfoTests

 - Consolidate SPR-8949 tests

 - Eliminate compiler warnings

Issue: SPR-8949, SPR-8806
2012-02-13 15:01:05 +01:00
Chris Beams
e25f1cbca9 Infer AnnotationAttributes method return types
- Drop 'expectedType' parameter from #getClass and #getEnum methods and
   rely on compiler inference based on type of assigned variable, e.g.

     public @interface Example {
         Color color();
         Class<? extends UserType> userType();
         int order() default 0;
     }

     AnnotationAttributes example =
        AnnotationUtils.getAnnotationAttributes(Example.class, true, true);

     Color color = example.getEnum("color");
     Class<? extends UserType> userType = example.getClass("userType");

   or in cases where there is no variable assignment (and thus no
   inference possible), use explicit generic type, e.g.

     bean.setColor(example.<Color>getEnum("color"));

 - Rename #get{Int=>Number} and update return type from int to
   <N extends Number>, allowing invocations such as:

     int order = example.getNumber("order");

These changes reduce the overall number of methods exposed by
AnnotationAttributes, while at the same time providing comprehensive
access to all possible annotation attribute types -- that is, instead of
requiring explicit #getInt, #getFloat, #getDouble methods, the
single #getNumber method is capabable of handling them all, and without
any casting required. And the obvious additional benefit is more concise
invocation as no redundant 'expectedType' parameters are required.
2012-02-13 15:01:05 +01:00
Rossen Stoyanchev
997c6c56f7 Minor fix in MVC reference doc chapter
Issues: SPR-9111
2012-02-12 19:54:17 -05:00
jhoeller
caa50a1d41 Merge pull request #33 from trisberg/SQLException-translation-enhancements
SQL exception translation enhancements
2012-02-12 07:19:21 -08:00
jhoeller
6e00456e67 Merge pull request #25 from trisberg/fixes-for-SimpleJdbcInsert
Fixes for SimpleJdbcInsert [SPR-9006]
2012-02-12 07:17:15 -08:00
Juergen Hoeller
a46facc2f9 Hibernate 4.1 etc 2012-02-11 19:15:42 +01:00
Juergen Hoeller
9e21d2f741 TypeDescriptor equals implementation accepts annotations in any order (SPR-9084) 2012-02-11 19:15:41 +01:00
Juergen Hoeller
9470323724 "setBasenames" uses varargs now (for programmatic setup; SPR-9106) 2012-02-11 19:15:40 +01:00
Juergen Hoeller
b17d545bb7 @ActiveProfiles mechanism works with @ImportResource as well (SPR-8992) 2012-02-11 19:15:39 +01:00
Juergen Hoeller
1bd260adaf polishing 2012-02-11 19:15:38 +01:00
Juergen Hoeller
57851de88e clarified Resource's "getFilename" method to consistently return null if resource type does not have a filename (SPR-9043) 2012-02-11 19:15:37 +01:00
Juergen Hoeller
1e1f8c912b substituteNamedParameters detects and unwraps SqlParameterValue objects (SPR-9052) 2012-02-11 19:15:35 +01:00
Rossen Stoyanchev
66bc214a79 Replace spaces with tabs 2012-02-10 18:24:58 -05:00
Chris Beams
45ad183331 Consider security in ClassUtils#getMostSpecificMethod
Recent changes in ExtendedBeanInfo involve invoking
ClassUtils#getMostSpecificMethod when determining JavaBeans get/set
pairs; if Java security settings control disallow reflective access,
this results in an AccessControlException.

This change defends against this (comparatively rare) scenario by
catching the exception and falling back to returning the method
originally supplied by the user.

This change was a result of noticing CallbacksSecurityTests failing
following the ExtendedBeanInfo modifications mentioned above

Issue: SPR-8949
2012-02-10 00:13:24 +01:00
Thomas Risberg
66012b951e Adding null check for username being null.
The username is usually not null, but it  could be for some embedded databases.

Always setting generatedKeysColumnNameArraySupported to false when getGeneratedKeysSupported is false, since it can't be supported without having generated keys supported. This change only affects logging messages.

Issue: SPR-9006
2012-02-09 17:55:04 -05:00
Thomas Risberg
f6c7d99ba4 Improvements for registering custom SQL exception translators in app contexts.
Adding a static CustomSQLExceptionTranslatorRegistry and a CustomSQLExceptionTranslatorRegistrar that can be used to register custom SQLExceptionTranslator implementations for specific databases from any application context.

This can be used in application contexts like this:

  <bean class="org.springframework.jdbc.support.CustomSQLExceptionTranslatorRegistrar">
    <property name="sqlExceptionTranslators">
      <map>
        <entry key="H2">
          <bean class="com.yourcompany.data.CustomSqlExceptionTranslator"/>
        </entry>
      </map>
    </property>
  </bean>

Issue: SPR-7675
2012-02-09 17:43:05 -05:00
Thomas Risberg
e202d89c29 SPR-7680 Adding QueryTimeoutException to the DataAccessException hierarchy 2012-02-09 17:18:38 -05:00
Rossen Stoyanchev
21aed042ea Minor polish in WebMvcConfigurationSupport 2012-02-09 16:54:55 -05:00
Chris Beams
f1ecd1ca2a Detect overridden boolean getters in ExtendedBeanInfo
Prior to this commit, and due to idiosyncracies of
java.beans.Introspector, overridden boolean getter methods were not
detected by Spring's ExtendedBeanInfo, which relied on too-strict
Method equality checks when selecting read and write methods.

Now ExtendedBeanInfo uses Spring's ClassUtils#getMostSpecificMethod
against the methods returned from java.beans.Introspector in order
to ensure that subsequent equality checks are reasonable to make.

Issue: SPR-8949
2012-02-09 22:23:57 +01:00
Chris Beams
c1df51a3b4 Polish ExtendedBeanInfoTests
Clean up ignored test, consolidate and document tests cornering
covariant return type edge cases.

Issue: SPR-8079, SPR-8806
2012-02-09 22:23:57 +01:00
Arjen Poutsma
edc80ffa95 Use request contentType/encoding in ServletServetHttpRequest/Response
ServletServerHttpRequest now falls back on the contentType and the
the characterEncoding of the ServletRequest, if the headers of the
incoming request don't specify one. Similary ServletServerHttpResponse
sets the contentType and the characterEncoding of the ServletResponse
if not already set.

This allows using the CharacterEncodingFilter to set a character
encoding where the request doesn't specify one and have it be used
in HttpMessageConverter's.

SPR-9096
2012-02-09 12:34:27 -05:00
Chris Beams
ff44c9132c Upgrade Hibernate from 4.0.0.CR7=>4.1.0.Final
spring-orm now successfully builds against Hibernate 4.1.0.Final

Issue: SPR-9082
2012-02-09 12:35:58 +01:00
Juergen Hoeller
0db257cbe3 restored preference for covariant return type if applicable 2012-02-09 12:24:13 +01:00
Chris Beams
3eff364529 Upgrade Hibernate from 4.0.0.CR7=>4.1.0.Final
spring-orm now successfully builds against hibernate-core and
hibernate-entitymanager 4.1.0.Final

Issue: SPR-9082
2012-02-09 12:19:21 +01:00
Juergen Hoeller
35c2869875 INSTANCE constant should be marked as final (SPR-9101) 2012-02-09 11:56:06 +01:00
Juergen Hoeller
c931eaa436 documentation fixes (SPR-9025, SPR-9027) 2012-02-08 18:35:57 +01:00
Juergen Hoeller
357a5193b7 added reference documentation to IntelliJ project 2012-02-08 18:34:44 +01:00
Juergen Hoeller
e4f2cfe39e Provider injection etc 2012-02-08 17:53:15 +01:00
Juergen Hoeller
4aa8b96687 write method parameter type preferred over read method parameter type for property conversion (fixing regression; SPR-8964) 2012-02-08 17:51:06 +01:00
Juergen Hoeller
17bbc623c1 optimized converter lookup to avoid contention in JDK proxy check (SPR-9084) 2012-02-08 17:08:57 +01:00
Juergen Hoeller
c55362c35e Provider injection works with generically typed collections of beans as well (SPR-9030) 2012-02-08 16:29:00 +01:00
Chris Beams
27b8c5d71a Resolve build script plugins via http vs https
The build script should work against http anyway; use of https here was
an oversight. Changing it now is in response to the following build
failure experienced by a user on his initial attempt to build from
source (with --info output):

  09:02:09.437 [ERROR] [org.gradle.BuildExceptionReporter] Caused
  by: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
  ...
  Cause: Could not GET
  https://repo.springsource.org/plugins-snapshot/org/springframework/
  build/gradle/docbook-reference-plugin/0.1.2-SNAPSHOT/maven-metadata.xml

The actual cause is unknown at this time, but worth noting that upon
switching the url to http, the following log message was issued:

  Forcing close on abandoned resource: Http GET Resource:
  http://repo.springsource.org/plugins-snapshot/org/springframework/
  build/gradle/docbook-reference-plugin/0.1.2-SNAPSHOT/maven-metadata.xml
2012-02-08 16:23:23 +01:00
Juergen Hoeller
9a61f36d3d removed optional javax.validation.spi dependency (SPR-8973) 2012-02-08 12:52:51 +01:00