Commit Graph

430 Commits

Author SHA1 Message Date
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
Sam Brannen 796af90ba7 Polish ASM-based annotation processing
- AnnotationAttributesReadingVisitor no longer processes annotations
  from the java.lang.annotation package.

- Simplified logic in AnnotationReadingVisitorUtils
  getMergedAnnotationAttributes().

Issue: SPR-11574
2014-03-21 15:26:13 +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 ad09f1b5ec Upgraded embedded ASM version to 5.0
Issue: SPR-11239
2014-03-20 01:06:22 +01:00
Sam Brannen 99cd2f6098 Support meta-annotation overrides in ASM processing
Prior to this commit, Spring supported meta-annotation attribute
overrides in custom composed annotations with reflection-based
annotation processing but not with ASM-based annotation processing.

This commit ensures that meta-annotation attribute overrides are
supported in AnnotationMetadataReadingVisitor.getAnnotationAttributes().

Issue: SPR-11574
2014-03-19 23:44:13 +01:00
Sam Brannen 9ce0df89ff Support Class meta-annotation attributes with ASM
Prior to this commit, AnnotationAttributesReadingVisitor treated Class
annotation attributes as Strings instead of Classes. As a result,
look-ups for Class attributes in meta-annotations failed with an
IllegalArgumentException.

This commit fixes this issue by consistently treating Class attributes
as Classes in AnnotationAttributesReadingVisitor.

Issue: SPR-11557
2014-03-18 18:20:15 +01:00
Juergen Hoeller 5ff1c696c8 Check raw Type objects, not ResolvableType instances, during isAssignableFrom recursion
Issue: SPR-11522
2014-03-14 00:45:40 +01:00
Juergen Hoeller 4744180d3d NumberUtils reports overflow when converting from BigInteger/BigDecimal to Long
Issue: SPR-11434
2014-03-13 17:03:55 +01:00
Sam Brannen 2bfd6ddcf4 Refactor SQL script support
This commit continues the work in the previous commit as follows:

 - Introduced an exception hierarchy for exceptions related to SQL
   scripts, with ScriptException as the base.

 - CannotReadScriptException and ScriptStatementFailedException now
   extend ScriptException.

 - Introduced ScriptParseException, used by ScriptUtils.splitSqlScript().

 - DatabasePopulatorUtils.execute() now explicitly throws a
   DataAccessException.

 - Polished Javadoc in ResourceDatabasePopulator.

 - Overhauled Javadoc in ScriptUtils and documented all constants.

 - Added missing @author tags for original authors in ScriptUtils and
   ScriptUtilsTests.

 - ScriptUtils.splitSqlScript() now asserts preconditions.

 - Deleted superfluous methods in ScriptUtils and changed method
   visibility to private or package private as appropriate.

 - Deleted the ScriptStatementExecutor introduced in the previous
   commit; ScriptUtils.executeSqlScript() now accepts a JDBC Connection;
   JdbcTestUtils, AbstractTransactionalJUnit4SpringContextTests, and
   AbstractTransactionalTestNGSpringContextTests now use
   DatabasePopulatorUtils to execute a ResourceDatabasePopulator instead
   of executing a script directly via ScriptUtils.

 - Introduced JdbcTestUtilsIntegrationTests.

Issue: SPR-9531
2014-03-13 12:00:01 +01:00
Juergen Hoeller bea94d5302 CollectionToCollectionConverter avoids collection copy for untyped collection when simply returning source anyway
Also uses addAll instead of iteration over untyped collection now, supporting optimized addAll in target collection type, and avoids repeated getElementTypeDescriptor calls.

Issue: SPR-11479
2014-03-10 15:59:19 +01:00
Sam Brannen b364599278 Update links to Spring JIRA server 2014-03-10 12:26:29 +01:00
Sam Brannen 1ade9b5433 Polish various test classes 2014-03-07 18:06:30 +01:00
Juergen Hoeller 3dfa7e9ac0 Avoid stack overflow in case of circular type reference
Issue: SPR-11522
2014-03-07 00:08:15 +01:00
Juergen Hoeller 793cab4f80 Allow generics-based injection in case of nested unresolved type variable
Issue: SPR-11471
2014-03-06 14:13:33 +01:00
Juergen Hoeller 2a2816dfc3 Restored proper handling of varargs in case of unresolvable type variable
Fixed through falling back to the raw parameter type in the TypeDescriptor(MethodParameter) constructor, properly detecting the vararg array even in case of an unresolvable type variable, and through restoring getElementTypeDescriptor's original behavior for arrays, i.e. always returning a non-null descriptor.

Issue: SPR-11494
2014-03-05 22:36:12 +01:00
Juergen Hoeller f3884084f2 Optimized DefaultResourceLoader's getResource implementation for "/..." paths, not relying on URL parsing exceptions for such a common case anymore
Issue: SPR-8283
2014-03-04 13:31:51 +01:00
Juergen Hoeller ac61b13a7c AnnotatedElementUtils wraps unexpected exceptions with descriptive IllegalStateException
Issue: SPR-10441
2014-02-28 14:17:37 +01:00
Juergen Hoeller 1763bfbad0 Fixed content length check in XmlValidationModeDetector
Issue: SPR-11477
2014-02-28 14:00:32 +01:00
Sam Brannen 0637864b39 Ensure AnnotationUtils is compatible with Java 6
The previous commit introduced a dependency on
Class.getDeclaredAnnotation() which is a Java 8 API.

This commit refactors AnnotationUtils.findAnnotation(Class, Class, Set)
to use Class.getAnnotation() in conjunction with
isAnnotationDeclaredLocally() in order to achieve the same desired
behavior.

Issue: SPR-11475
2014-02-26 17:51:26 +01:00
Sam Brannen 1d30bf83a0 Favor 'local' annotations over inherited ones
Prior to this commit, the implementations of findAnnotation() in
AnnotationUtils and getAnnotationAttributes() in AnnotatedElementUtils
favored inherited annotations and inherited composed annotations over
composed annotations that are declared closer to the starting class
passed to these methods.

This commit addresses this issue as follows:

- Refactored AnnotationUtils to use getDeclaredAnnotation() and
  getDeclaredAnnotations() instead of getAnnotation() and
  getAnnotations() where appropriate.

- AnnotatedElementUtils.doProcess() supports a traverseClassHierarchy
  flag to control whether the class hierarchy should be traversed,
  using getDeclaredAnnotations() instead of getAnnotations() if the
  flag is true.

- Overhauled Javadoc in AnnotatedElementUtils.

Issue: SPR-11475
2014-02-26 16:06:42 +01:00
Sam Brannen 979c483384 Do not inspect meta-annotations on Java annotations
This commit introduces a new isInJavaLangAnnotationPackage(Annotation)
method in AnnotationUtils. This method is now used in AnnotationUtils,
AnnotatedElementUtils, and MetaAnnotationUtils to ensure that search
algorithms do no search for meta-annotations on annotations in the
"java.lang.annotation" package.

The following are some empirical results from this change:

- The number of times that the findAnnotation(Class,Class,Set) method in
  AnnotationUtils is recursively invoked while executing
  AnnotationUtilsTests drops from 51 to 29.

- The number of times that the process(AnnotatedElement) method in
  AnnotationUtils.AnnotationCollector is recursively invoked while
  executing AnnotationUtilsTests.getRepeatableFromMethod() drops
  from 16 to 2.

- The number of times that the doProcess() method in
  AnnotatedElementUtils is recursively invoked while executing the
  "getAnnotationAttributes() On MetaCycleAnnotatedClass with missing
  target meta-annotation" test in AnnotatedElementUtilsTests drops
  from 23 to 5.

- The number of times that the findAnnotationDescriptor(Class,Set,Class)
  method in MetaAnnotationUtils is recursively invoked while executing
  the "findAnnotationDescriptor() on MetaCycleAnnotatedClass with
  missing target meta-annotation" test in MetaAnnotationUtilsTests drops
  from 16 to 8.

Issue: SPR-11483
2014-02-25 21:57:35 +01:00
Sam Brannen 90b938aa8f Verify status quo when searching for non-inherited composed annotations
Issue: SPR-11475
2014-02-24 00:13:47 +01:00
Sam Brannen 7e38f479e0 Polishing 2014-02-21 22:56:23 +01:00
Sam Brannen 42a36349e9 Support nested meta-annotations in AnnotationUtils
Prior to this commit, AnnotationUtils.findAnnotation(Class, Class)
claimed to recursively search through annotations; however, only one
level of annotations was supported by the algorithm.

This commit alters the search algorithm so that nested meta-annotations
(i.e., meta-annotations on meta-annotations) are also supported.

Issue: SPR-11448
2014-02-19 18:27:44 +01:00
Sam Brannen 8f0849f328 Fix minor error in AnnotationUtilsTests
TransactionalAndOrderedClass now extends TransactionalClass.

The tests passed anyway, but they did not actually verify what was meant
to be verified.
2014-02-19 12:47:55 +01:00
Phillip Webb 461816735f Fix unused import warning 2014-02-18 19:37:06 -08:00
Phillip Webb 7efd54e243 Additional caching for ResolvableTypes
Add additional caching to ResolvableTypes and SerializableTypeWrapper
in order to improve SpEL performance.

Issue: SPR-11388
2014-02-18 15:27:28 -08:00
Phillip Webb 319724f0b4 Regularly purge ResolvableType cache
Update ResolvableType to call `purgeUnreferencedEntries` on the cache
on each get.

Issue: SPR-11394
2014-02-18 15:16:03 -08:00
Phillip Webb 2b4c81e642 Fix memory leak in ConcurrentReferenceHashMap
Update ConcurrentReferenceHashMap to protect against references that
have been garbage collected but for some reason do not appear as a
`pollForPurge` result.

Also added purgeUnreferencedEntries() method to allow for programmatic
cleanup.

Issue: SPR-11440
2014-02-18 15:10:30 -08:00
Juergen Hoeller 72fe7ebc34 Objects with multi-threaded access should not lazily populate a hash field
Issue. SPR-11428
2014-02-14 20:46:34 +01:00
Sam Brannen c335e99e3f Remove trailing whitespace from source code 2014-02-08 17:30:39 +01:00
Juergen Hoeller 426f52b393 Polishing 2014-02-06 20:35:59 +01:00
Juergen Hoeller 8c4e372558 Introduced SpringNamingPolicy for CGLIB
Issue: SPR-11398
2014-02-06 20:25:11 +01:00
Juergen Hoeller 1cd5071e6a Use AtomicInteger instead of local synchronization around int field
Issue: SPR-11103
2014-02-04 17:45:03 +01:00
Juergen Hoeller 6634c19e6a Related polishing
Issue: SPR-11386
2014-02-04 16:45:14 +01:00
Juergen Hoeller 60c1905cdd Introduced "spring.jdbc.getParameterType.ignore" property
Issue: SPR-11386
2014-02-04 16:44:08 +01: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
Juergen Hoeller 874a2a9ca2 Backwards-compatible handling of generic and raw collection converters
Issue: SPR-11369
2014-02-01 19:24:40 +01:00
Juergen Hoeller 46b24dbd33 Polishing
Issue: SPR-11369
2014-02-01 12:15:01 +01:00
Juergen Hoeller d52f584322 GenericConversionService matches converters by full generic target type, allowing for the registration of multiple converters from the same source type to different collection types
Issue: SPR-11369
2014-02-01 10:53:01 +01:00
Juergen Hoeller a537eb3a6a Polishing 2014-01-30 12:26:41 +01:00
Juergen Hoeller 8570f607a7 Fixed regression with fallback for non-resolvable property type 2014-01-28 17:16:50 +01:00
Juergen Hoeller bb28d198f5 Polishing 2014-01-26 01:04:21 +01:00
Juergen Hoeller 67e76e9a8d Compatibility with JOpt 4.6
JOpt 4.6 redeclared its nonOptionArguments() method from List<String> to List<?>, requiring us to select String arguments only as we do for regular option values already.

Issue: SPR-11359
2014-01-26 00:05:51 +01:00
Juergen Hoeller 5331da6aff Polishing 2014-01-25 00:27:27 +01:00
Juergen Hoeller 167329ce0c Added test for SpringProperties setFlag method
Issue: SPR-9014
Issue: SPR-11297
(cherry picked from commit 23249cd)
2014-01-24 18:18:41 +01:00
Juergen Hoeller b6073d9ac4 Polishing 2014-01-24 16:22:29 +01:00
Juergen Hoeller 8543b91c50 Introduced SpringProperties class and optional "spring.properties" file
This in particular allows for specifying "spring.getenv.ignore" and "spring.beaninfo.ignore" in a local way within the application, in case that JVM-level system properties are locked.

Issue: SPR-9014
Issue: SPR-11297
2014-01-24 16:22:02 +01:00
Juergen Hoeller eeae5fba95 Fixed regression with constructing TypeDescriptor from null Class
Issue: SPR-11354
2014-01-24 13:16:35 +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 6793765b0a Factored out "suppressGetenvAccess()" method
Issue: SPR-11297
(cherry picked from commit 52d050d)
2014-01-23 00:12:09 +01:00
Phillip Webb 59604b1cd5 Unwrap TypeVariables before calling .equals()
Update ResolvableType to unwrap Serialization wrapped TypeVariables
before calling the equals method.

This protects against the recent change in OpenJDK 8 (build 124)
which changed the TypeVariableImpl equals method such that it only
matches against other TypeVariableImpl instances.

Issue: SPR-11342
2014-01-21 16:10:02 -08:00
Phillip Webb d96b91a57b Fix SerializableTypeWrapper equals() performance
Change SerializableTypeWrapper proxies to directly call equals() methods
on the underlying Type, rather than possibly generating more wrappers.

This should help to improve performance, especially as the equals()
method is called many times when the ResolvableType cache is checked.

Issue: SPR-11335
2014-01-21 10:59:25 -08:00
Juergen Hoeller 709ac28f29 Consider wildcard type without bounds as eligible for fallback match too
Issue: SPR-11250
2014-01-21 01:26:30 +01:00
Juergen Hoeller 1aff833282 Polishing 2014-01-21 00:35:38 +01:00
Phillip Webb 9076c70d47 Provide 'with implementationType' overloads
Provided overloaded versions of `forField` and `forMethodParameter` that
accept a `ResolvableType` implementation type (as opposed to a Class).

Primarily added to allow resolution against implementation types that
have been created programmatically using `forTypeWithGenerics`.

Issue: SPR-11218
2014-01-17 11:49:44 -08:00
Phillip Webb 7e6dbc24f6 Make TypeDescriptor more amenable to subclassing
Change the previously package scope TypeDescriptor constructor to
protected and add a getResolvableType() protected method.

Issue: SPR-11303
2014-01-17 11:05:40 -08:00
Juergen Hoeller 4f45ad549e Introduced customizeConnection callbacks for URLConnection used by exists() / contentLength() / lastModified()
Issue: SPR-11320
2014-01-16 17:09:23 +01:00
Juergen Hoeller 11bc9d0aeb Mentioned "-parameters" compiler flag in javadoc 2014-01-16 12:49:31 +01:00
Juergen Hoeller a5f9b29292 Polishing 2014-01-15 22:53:46 +01:00
Juergen Hoeller e670f4e5c6 Polishing 2014-01-15 17:45:04 +01:00
Juergen Hoeller 961f42bd43 Introduced "spring.getenv.ignore" system property for preventing System.getenv calls
Issue: SPR-11297
2014-01-15 17:44:17 +01:00
Juergen Hoeller ab15ed2a05 ObjectUtils.isCompatibleWithThrowsClause supports varargs now 2014-01-15 16:09:31 +01:00
Juergen Hoeller 76bb966b1a Removed Commons Lang references 2014-01-15 15:35:08 +01:00
Juergen Hoeller abff789b0f Removed javadoc references to non-accessible subclasses 2014-01-15 13:39:09 +01:00
Juergen Hoeller cdd65a70af Added compatibility note on WildFly 8 2014-01-13 22:14:51 +01:00
Juergen Hoeller ee2022e54c Polishing 2014-01-05 03:01:44 +01:00
Juergen Hoeller 640d8cb67f Consistent implementation of AsyncListenableTaskExecutor
Issue: SPR-11282
2014-01-03 21:57:07 +01:00
Juergen Hoeller ff26dfdd28 Added cache for path pattern tokenization
Issue: SPR-11258
2014-01-03 17:33:46 +01:00
Juergen Hoeller 6aabb5f17e Support varargs for DomUtils.getChildElementsByTagName
Issue: SPR-11272
(cherry picked from commit e334489)
2014-01-03 16:18:48 +01:00
Rossen Stoyanchev 1f49f994e6 Fix issue with use of SecureRandom for id generation
Switch to using nextBytes as generateSeed doesn't seem to be always
supported by all hardware providers.

Issue: SPR-11278
2014-01-02 12:06:37 -05:00
Juergen Hoeller f0d21510f5 Polishing
Issue: SPR-11259
2013-12-30 19:13:04 +01:00
Juergen Hoeller 48909886a2 Added support for the Java 8 style 'from'/'to' method conventions
Also introduced a default ZonedDateTime-Calendar converter which is not covered by the default convention due to the 'from' method only being defined on GregorianCalendar.

Issue: SPR-11259
2013-12-30 19:08:36 +01:00
Juergen Hoeller 7f5d6ea3f9 Fixed NavigableSet/NavigableMap detection in createCollection/createMap
Issue: SPR-11257
2013-12-28 20:48:35 +01:00
Juergen Hoeller 9a39f39b6f Polishing
Issue: SPR-11254
2013-12-23 12:49:57 +01:00
Juergen Hoeller ee5b7fdab8 Revised XMLEventStreamWriter to allow for empty elements with attributes
Issue: SPR-11254
2013-12-23 12:49:47 +01:00
Juergen Hoeller f9e8eb59e1 Fixed hasUnresolvableGenerics() to return false in case of an unresolvable bounded variable as well
Issue: SPR-11250
2013-12-20 16:44:25 +01:00
Juergen Hoeller 2faf008c2e Polishing
Issue: SPR-11225
2013-12-19 23:08:18 +01:00
Juergen Hoeller 11fb12b920 Fixed AbstractMessageConverterMethodArgumentResolver's type variable resolution
Issue: SPR-11225
2013-12-19 23:04:23 +01:00
Juergen Hoeller aa2fadd8da Revised ResolvableType's handling of (self-referential) type variables
Also resolving at construction time now, and shortcutting assignability evaluation.

Issue: SPR-11219
2013-12-19 14:55:16 +01:00
Juergen Hoeller 234272eb8f Polishing
Issue: SPR-11215
2013-12-17 21:39:40 +01:00
Juergen Hoeller 63d300ac86 Polishing
Issue: SPR-11242
2013-12-17 20:14:33 +01:00
Juergen Hoeller 1d47fc6e2d Consistent non-declaration of serialVersionUID
Issue: SPR-11242
2013-12-17 20:14:07 +01:00
Juergen Hoeller 994efe45fd Prevented potential infinite recursion in hashCode/equals
Issue: SPR-11219
2013-12-17 20:12:03 +01:00
Juergen Hoeller 078d2fe0e2 Added current version information to SpringAsmInfo's javadoc 2013-12-16 22:50:25 +01:00
Juergen Hoeller 105e176a80 Fixed @Bean meta-annotation detection when using ASM
This turned out to be a bug in the ASM-based AnnotationMetadata implementation where has/getAnnotatedMethods didn't consider meta-annotations., in contrast to its StandardAnnotationMetadata sibling.

Issue: SPR-10488
2013-12-16 22:47:43 +01:00
Juergen Hoeller ca194261a4 Removed support for JBoss AS 5's VFS variant (since we require JBoss AS 6+ now) 2013-12-12 02:57:34 +01:00
Juergen Hoeller 161819f141 Component scanning ignores attributes and meta-annotations on non-public annotations
Issue: SPR-11091
2013-12-11 15:29:55 +01:00
Juergen Hoeller 4fe52d1953 Polishing 2013-12-10 12:00:32 +01:00
Juergen Hoeller 5dcd28761c Fixed type resolution for uninitialized factory-method declaration
Issue: SPR-11112
2013-12-09 18:53:27 +01:00
Juergen Hoeller 6078c27e60 Fixed evaluation of "!" operator in case of multiple profile expressions
Issue: SPR-11093
2013-12-09 13:29:21 +01:00
Phillip Webb fd1b48139f Polish 2013-12-02 21:35:13 -08:00
Phillip Webb cb46ef86c6 Fix test following ResolvableType hashcode change 2013-12-02 16:55:24 -08:00
Phillip Webb ab2949f2b7 Fix ResolvableType hashCode generation
Fix ResolvableType.hashCode() to use the source of the variable
resolver, rather than the resolver itself.
2013-12-02 14:47:44 -08:00
Juergen Hoeller 676ad125a1 Reverted arrayToList signature to return plain List
This is necessary for source compatibility with existing callers, such as code found in Spring Integration: e.g. passing the arrayToList result into a typed HashSet constructor.
2013-12-02 13:10:41 +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