Commit Graph

1374 Commits

Author SHA1 Message Date
Juergen Hoeller 4ef428de28 Polishing 2016-08-30 23:57:11 +02:00
Juergen Hoeller 03609c1518 Consistent comma splitting without regex overhead
Issue: SPR-14635
2016-08-30 23:56:58 +02:00
Sam Brannen d6d05e8ca0 Remove trailing whitespace in Java source code 2016-08-29 15:25:10 +02:00
Juergen Hoeller 2e4a7480fc Consistent use of JDK 7 StandardCharsets over Charset.forName
Issue: SPR-14492
2016-08-26 14:16:19 +02:00
Juergen Hoeller 14046575b0 Polishing 2016-08-26 13:27:33 +02:00
Juergen Hoeller a8f7f75f64 Moved encodeHttpHeaderFieldParam method to HttpHeaders itself (including tests)
This commit also sets the test source encoding to UTF-8.

Issue: SPR-14547
2016-08-26 11:14:02 +02:00
Brian Clozel f2faf84f31 Add RFC5987 support for HTTP header field params
This commit adds support for HTTP header field parameters encoding, as
described in RFC5987.
Note that the default implementation still relies on US-ASCII encoding,
as the latest rfc7230 Section 3.2.4 says that:

> Newly defined header fields SHOULD limit their field values to
  US-ASCII octets

Issue: SPR-14547
2016-08-25 14:26:58 +02:00
Juergen Hoeller c4fcdb6864 DefaultListableBeanFactory does not trigger early candidate creation ahead of primary bean selection
Issue: SPR-14611
2016-08-24 22:56:47 +02:00
Juergen Hoeller ab0d523cc0 Polishing
(cherry picked from commit 1932a9d)
2016-08-17 21:54:40 +02:00
Sebastien Deleuze 106bda7294 Fix NettyDataBuffer#lastIndexOf() 2016-08-09 18:07:10 +02:00
Rossen Stoyanchev cc288a0c4a Switch back to Reactor 3.0 snapshots 2016-08-08 16:42:30 -04:00
Sebastien Deleuze 5531e80724 Anticipate reactor.test.TestSubscriber removal
reactor.test.TestSubscriber will not be part of Reactor Core
3.0.0 since it needs to be refactored to fit all the needs
expressed by the users. It is likely to be back later in one
of the Reactor Core 3.0.x releases.

This commit anticipate this removal by temporarily copying
TestSubscriber in spring-core test classes. As soon as
the new TestSubscriber will be available in Reactor Core,
Spring Framework reactive tests will use it again.
2016-08-08 11:24:21 +02:00
Juergen Hoeller b9ab895743 Inferred generics for newSetFromMap arrangements
Issue: SPR-13188
2016-07-26 21:26:31 +02:00
Juergen Hoeller e03dea1d64 Polishing 2016-07-26 17:15:19 +02:00
Juergen Hoeller c13f8419f9 Minor revision of reactive support layout (ahead of 5.0 M1)
DataSourceUtils moved to main core.io.buffer package.
Consistently named Jackson2JsonDecoder/Encoder and Jaxb2XmlDecoder/Encoder.
Plenty of related polishing.
2016-07-26 15:39:32 +02:00
Juergen Hoeller ae28815886 Polishing 2016-07-25 23:27:06 +02:00
Juergen Hoeller 87a89c216c Javadoc revision 2016-07-25 14:21:19 +02:00
Juergen Hoeller 01110f678d Upgrade JiBX (and BCEL) towards support of 1.8 bytecode level
This commit also drops the now-unused CUSTOM_COMPILATION test group and the outdated JavaVersion class.

Issue: SPR-10423
2016-07-25 14:10:46 +02:00
Juergen Hoeller dd65f7acfc LinkedCaseInsensitiveMap properly overrides HashMap.clone()
Issue: SPR-14509
2016-07-25 12:08:55 +02:00
Juergen Hoeller 382a931e7d Polishing 2016-07-22 22:28:20 +02:00
Arjen Poutsma b0d7625e3e Reactor StringEncoder into CharSequenceEncoder
This commit refactors the StringEncoder to a CharSequenceEncoder, in
order to support StringBuilders, Groovy GStrings, etc.

Issue: https://github.com/spring-projects/spring-reactive/issues/120
2016-07-22 12:47:46 -04:00
Rossen Stoyanchev 101220bad1 Add ReactiveAdapterRegistry
Issue: SPR-14159
2016-07-22 12:21:28 -04:00
Brian Clozel 78b6ba0569 Filter irrelevant nodes in StaxHandler tests 2016-07-21 23:01:55 +02:00
Marius Grama 3635c9dbfe Update xmlunit library to version 2.1.0
xmlunit 2.1.0 is the latest release for xmlunit.
Most of the xmlunit functionality used within spring-framework
was done through the xmlunit 1.x helper class
`org.custommonkey.xmlunit.XMLAssert`.

As of xmlunit 2.0.0 most of the XML comparison methods are done
through hamcrest matchers exposed by the xmlunit-matchers
library. In some cases during the migration, the matchers
had to be customized with custom `NodeMatcher` or
`DifferenceEvaluator` instances in order to keep the assertions
correct (they were performed with xmlunit 1.x previously).

Issue: SPR-14043
2016-07-21 15:04:21 +02:00
Juergen Hoeller e756a5b54b ResourcePatternUtils.getResourcePatternResolver actually accepts null argument
Issue: SPR-14500
2016-07-21 14:06:30 +02:00
Arjen Poutsma 7b2196b408 Add writeAndFlushWith to ReactiveHttpOutputMessage
This commit changes the reactive flushing mechanism to use a newly
introduced writeAndFlushWith(Publisher<Publisher<DataBuffer>>) on
ReactiveHttpOutputMessage instead of using the FlushingDataBuffer.

Issue: https://github.com/spring-projects/spring-reactive/issues/125
2016-07-21 11:08:54 +02:00
Juergen Hoeller 9cc625ee2c Polishing
(cherry picked from commit 5a92aa4)
2016-07-20 23:25:17 +02:00
Juergen Hoeller 28e7c11234 Polishing 2016-07-20 22:41:56 +02:00
Juergen Hoeller 99be15f58b Revise encoding steps towards use of JDK Charset and StandardCharsets
Issue: SPR-14492
2016-07-19 23:43:06 +02:00
Juergen Hoeller a4743c07d4 Polishing 2016-07-19 20:09:00 +02:00
Juergen Hoeller 88fcd0a2ed Framework build compatible with JDK 9 (tests running against java.base module)
Issue: SPR-13344
2016-07-19 19:37:34 +02:00
Juergen Hoeller d07381e862 Avoid deprecated number constructors on JDK 9
Issue: SPR-13344
2016-07-19 19:25:55 +02:00
Juergen Hoeller 8580483d72 SerializableTypeWrapper reobtains type accessors from declaring interface
Issue: SPR-14487
2016-07-19 19:22:32 +02:00
Juergen Hoeller aaac199e8b Consistently use constructor-based instantiation instead of Class.newInstance / BeanUtils.instantiate
Issue: SPR-14486
2016-07-19 19:21:06 +02:00
Juergen Hoeller 8bb34bc962 Resource.isFile() and JAF MediaTypeFactory
Issue: SPR-14484
2016-07-19 18:53:31 +02:00
Juergen Hoeller 5ea8c2670e Reinstated tests for implicit aliases
Issue: SPR-14437
2016-07-19 17:26:47 +02:00
Arjen Poutsma 35ce1945e0 Improved DataBufferUtilsTest 2016-07-19 11:11:11 +02:00
Rossen Stoyanchev 3e096ce810 Improve javadoc on reactive classes
Ensure type-level Javadoc in every class, comply with guidelines for
80 char on Javadoc, and minor polish.
2016-07-18 14:59:15 -04:00
Arjen Poutsma 041437f3ee Fixed DataBufferUtilsTest on Windows
DataBufferUtilsTests checked for newline characters before, resulting in
failures on Windows.
2016-07-18 17:08:46 +02:00
Fredrik Sundberg d3b051a933 Fix javadoc reference
Method is called nextBackOff() and not nextBackOffMillis().

Closes gh-1115
2016-07-18 08:14:12 +02:00
Rossen Stoyanchev 028be2a298 Switch to Reactor 3 snapshots and Netty 4.1.3 2016-07-15 17:16:26 -04:00
Juergen Hoeller dc1664939c Javadoc fixes and pruning of outdated references 2016-07-15 22:12:11 +02:00
Sam Brannen 177f4ec3a7 Polish annotation utils 2016-07-15 19:54:53 +02:00
Sam Brannen 53c9584025 Remove obsolete references to @AliasFor in Javadoc for AnnotationAttributes 2016-07-15 19:53:54 +02:00
Sam Brannen 53dd88437e Delete dead code in AnnotationAttributes 2016-07-15 19:51:33 +02:00
Juergen Hoeller 3d3407c789 Consistent alias processing behind AnnotatedTypeMetadata abstraction (also for ASM)
Issue: SPR-14427
2016-07-15 13:59:25 +02:00
Rossen Stoyanchev d2e105f28d Add @Since 5.0 and package-info for reactive classes 2016-07-14 17:40:17 -04:00
Juergen Hoeller e2c7653da4 Correct parameter index boundary in exception message
Issue: SPR-14466
2016-07-14 22:29:14 +02:00
Rossen Stoyanchev 2e8326220b Move spring-web-reactive classes to spring-core 2016-07-14 12:30:30 -04:00
Juergen Hoeller dd65689e0a MethodParameter.equals accepts subclasses pointing to same target declaration again
Issue: SPR-14438
2016-07-14 09:51:37 +02:00
Sam Brannen 264f5860a8 Use Supplier<String> support in Assert in spring-core
This commit makes use of the new Supplier<String> variants of utility
methods in org.springframework.util.Assert within the spring-core
module.

Issue: SPR-14450
2016-07-12 16:41:03 +02:00
Sam Brannen 17dd5dd22d Introduce Supplier<String> support in Assert util
Prior to this commit, utility methods in
org.springframework.util.Assert accepted String arguments for custom
error messages. Such Strings are evaluated (e.g., concatenated)
eagerly, and for performance reasons, it was therefore not always
possible to make use of these utility methods. Consequently, there are
several places in the code base that "inline" identical functionality
in order to lazily evaluate error message concatenation and avoid an
unnecessary performance penalty. This leads to verbose code like the
following.

if (!contextPath.startsWith("/")) {
    throw new IllegalArgumentException("contextPath '" + contextPath +
    "' must start with '/'.");
}
if (contextPath.endsWith("/")) {
    throw new IllegalArgumentException("contextPath '" + contextPath +
    "' must not end with '/'.");
}

This commit addresses this shortcoming by introducing Supplier<String>
variants of all utility methods in org.springframework.util.Assert that
allow custom error messages to be evaluated lazily via a lambda
expression that is only evaluated if the assertion fails. This results
in a simplification of the previous examples as follows.

Assert.isTrue(contextPath.startsWith("/"), () -> "contextPath '" +
    contextPath + "' must start with '/'.");
Assert.isTrue(!contextPath.endsWith("/"), () -> "contextPath '" +
    contextPath + "' must not end with '/'.");

Issue: SPR-14450
2016-07-12 16:41:03 +02:00
Sam Brannen 3d4338f555 Clean up warnings in spring-core 2016-07-12 16:41:03 +02:00
Brian Clozel 147a35f4f1 Polish AntPathMatcher.setTrimTokens javadoc
Issue: SPR-14247
2016-07-12 14:47:18 +02:00
Stephane Nicoll c425e774a3 Polish 2016-07-12 09:10:34 +02:00
Sam Brannen 40b2d26bd4 Avoid reflection for @Repeatable look-ups
Issue: SPR-13188
2016-07-08 13:21:31 +02:00
Juergen Hoeller 61db8e9f1e DigestUtils processes InputStream with buffered read instead of full copy
Issue: SPR-14427
2016-07-08 12:20:49 +02:00
Juergen Hoeller 6aa5931e28 Polishing 2016-07-07 01:05:25 +02:00
Juergen Hoeller a1f5fb53db Java 8 getParameterCount() instead of getParameterTypes().length
Issue: SPR-13188
2016-07-07 01:04:24 +02:00
Juergen Hoeller 39e3f2ebf6 MethodParameter supports Java 8 Executable/Parameter and validates parameter indexes
Also, equals insists on the same class now, differentiating from SynthesizingMethodParameter.

Issue: SPR-14055
Issue: SPR-13456
Issue: SPR-14438
2016-07-07 00:37:52 +02:00
Juergen Hoeller 102dc8a4dd Polishing 2016-07-06 15:29:15 +02:00
Stephane Nicoll e4b0486c5a Add @FunctionalInterface on candidate interfaces
Issue: SPR-14432
2016-07-06 14:32:13 +02:00
Juergen Hoeller 7dda9fbd8c Drop JasperReports support
Issue: SPR-13294
2016-07-05 23:06:15 +02:00
Sam Brannen 1391248ea6 Introduce log4j 2 for Spring's test suite
This commit adds a test runtime dependency on log4j 2 for every project
and migrates all log4j.properties files to log4j2-test.xml files.

Issue: SPR-14431
2016-07-05 19:19:09 +02:00
Stephane Nicoll 00d2606b00 Explicit type can be replaced by <>
Issue: SPR-13188
2016-07-05 17:00:34 +02:00
Juergen Hoeller b5db5d3aac Broadly remove deprecated core classes and methods
Issue: SPR-14430
2016-07-05 15:52:49 +02:00
Juergen Hoeller 0fc0ce78ae Drop deprecated dependencies on Log4j, JRuby, JExcel, Burlap, Commons Pool/DBCP
This commit also removes outdated support classes for Oracle, GlassFish, JBoss.

Issue: SPR-14429
2016-07-05 15:46:53 +02:00
Juergen Hoeller 51252ebbca Avoid defensive checks against Java 8 API (java.util.Optional etc)
This commit also fixes broken javadoc links and code references.

Issue: SPR-13188
2016-07-05 02:09:00 +02:00
Juergen Hoeller 2b3445df81 Drop Portlet MVC support
This commit also removes the corresponding deprecated Servlet MVC variant and updates DispatcherServlet.properties to point to RequestMappingHandlerMapping/Adapter by default.

Issue: SPR-14129
2016-07-04 23:33:47 +02:00
Juergen Hoeller a6e4b64c23 PropertySourcesPropertyResolver provides logKeyFound template method
Issue: SPR-14370
2016-07-02 15:43:40 +02:00
Sam Brannen 8389e3fc35 Suppress warnings in Gradle build 2016-07-01 13:08:39 +02:00
Juergen Hoeller 66ec1c1618 Add missing package-info files for common packages
Issue: SPR-14420
2016-06-30 21:39:06 +02:00
Juergen Hoeller 232cfe5e98 Polishing 2016-06-30 14:03:28 +02:00
Juergen Hoeller c4c941c43f Convert comma-separated string into list of classes analogous to existing support for class array
Issue: SPR-14415
2016-06-30 14:02:51 +02:00
Juergen Hoeller f2328e8e3c Polishing 2016-06-29 10:57:16 +02:00
Juergen Hoeller 1d42009c0a Deprecated getPropertyAsClass and refined PropertySourcesPropertyResolver's logging
Issue: SPR-14370
2016-06-29 10:51:06 +02:00
Juergen Hoeller a2aa82eb31 Polishing 2016-06-22 11:55:33 +02:00
Juergen Hoeller ca12e13ef8 ObjectUtils.nullSafeEquals allows for JVM method inlining (through reducing its bytecode size)
Issue: SPR-14349
2016-06-09 22:40:08 +02:00
Juergen Hoeller d51c22a789 Consistent processing of empty values and catching of RuntimeExceptions for Formatters
Issue: SPR-14345
2016-06-09 10:49:15 +02:00
Juergen Hoeller 8c4bc3656b Polishing 2016-06-07 15:42:16 +02:00
Juergen Hoeller 24f5f368b0 Consistent meta-annotation attributes lookup through ASM
Issue: SPR-14257
2016-05-30 22:39:27 +02:00
Juergen Hoeller a979885d17 SettableListenableFuture properly rethrows Error
Issue: SPR-14298
2016-05-26 19:39:22 +02:00
Juergen Hoeller 5682950289 Polishing 2016-05-06 12:03:10 +02:00
Juergen Hoeller 42d32ba396 ResourceRegion fits better in core.io.support (next to EncodedResource)
Issue: SPR-14221
2016-05-06 12:02:51 +02:00
Juergen Hoeller 5400bb9110 ListenableFutureAdapter keeps propagating onSuccess/onFailure exceptions
Issue: SPR-13785
2016-05-05 20:39:53 +02:00
Brian Clozel 3c92ddc94b Fix path matching for paths containing spaces
Prior to this commit, the latest optimizations introduced in SPR-13913
would prevent matching when patterns contained spaces. Indeed, the
optimized path would not fully tokenize the paths nor trim the tokens,
as the "longer" code path does.

This commit disables this optimized path when the `trimTokens` option is
set to `true`.

Also, the `trimTokens` setting is now set to `false` by default.

Issue: SPR-14247
2016-05-04 22:28:06 +02:00
Brian Clozel 5ac31fb39d Refactor HTTP Range support with ResourceRegion
Prior to this commit, the `ResourceHttpMessageConverter` would support
all HTTP Range requests and `MethodProcessors` would "wrap" controller
handler return values with a `HttpRangeResource` to support that use
case in Controllers.

This commit refactors that support in several ways:
* a new ResourceRegion class has been introduced
* a new, separate, ResourceRegionHttpMessageConverter handles the HTTP
range use cases when serving static resources with the
ResourceHttpRequestHandler
* the support of HTTP range requests on Controller handlers has been
removed until a better solution is found

Issue: SPR-14221, SPR-13834
2016-05-02 19:00:52 +02:00
Alex Panchenko 8d36332268 "final" for public static fields in ReflectionUtils
Closes gh-1046
2016-04-28 08:34:10 +02:00
Sam Brannen 1838d7e97f Update Javadoc for ReflectionUtils re: exception handling 2016-04-27 12:44:09 +03:00
Juergen Hoeller 65a8f5ed64 PathMatchingResourcePatternResolver reuses resolved root dir URL
Issue: SPR-14202
2016-04-26 17:09:57 +02:00
Juergen Hoeller bf7b475267 SocketUtils considers port range including maxPort
Issue: SPR-14211
2016-04-26 17:09:57 +02:00
Juergen Hoeller 9bf5a5cbcb FastByteArrayInputStream returns correct count from read(byte[])
Issue: SPR-14209
2016-04-26 17:09:57 +02:00
Johnny Lim 44e652f99e Remove duplicate words
Closes gh-1039
2016-04-19 08:24:21 +02:00
Rossen Stoyanchev 50c11028d5 Improve illegal MimeType checks
Issue: SPR-14124
2016-04-18 10:01:18 -04:00
Brian Clozel 368f29d5bc Fix AntPathMatcher multiple segments matching
Prior to this commit, the new match algorithm wouldn't work for multiple
consecutive path separators.
This commit separately matches path segments and path separators and
allows for multiple, consecutive path separators.

Issue: SPR-14141
2016-04-15 23:10:29 +02:00
Juergen Hoeller f1cb793ccb Rename MimeType's getCharSet() to getCharset()
Issue: SPR-14172
2016-04-14 16:38:59 +02:00
Juergen Hoeller 74608e6b49 Polishing 2016-04-12 16:03:57 +02:00
Juergen Hoeller bdb94738ec Refined default excluded packages
Issue: SPR-13886
2016-04-12 05:14:14 +02:00
Juergen Hoeller 537193a4e0 Consistent license header 2016-04-11 20:49:38 +02:00
Juergen Hoeller b82df144e4 LoadTimeWeaver.getThrowawayClassLoader() decorated for exclude support (if necessary)
Issue: SPR-13886
2016-04-11 19:19:37 +02:00
Sam Brannen e18d5b591a Limit size of context cache in the TestContext framework
Prior to this commit, the size of the ApplicationContext cache in the
Spring TestContext Framework could grow without bound, leading to
issues with memory and performance in large test suites.

This commit addresses this issue by introducing support for setting the
maximum cache size via a JVM system property or Spring property called
"spring.test.context.cache.maxSize". If no such property is set, a
default value of 32 will be used.

Furthermore, the DefaultContextCache has been refactored to use a
synchronized LRU cache internally instead of a ConcurrentHashMap. The
LRU cache is a simple bounded cache with a "least recently used" (LRU)
eviction policy.

Issue: SPR-8055
2016-04-04 20:56:04 +02:00
Juergen Hoeller 26378cd604 Polishing 2016-04-04 20:51:30 +02:00
Sam Brannen 6826bdd111 Document disabled test for hybrid annotation attribute overrides
This commit documents the @Ignore'd test to explain that Spring does not
support a hybrid approach for annotation attribute overrides with
transitive implicit aliases.

Issue: SPR-13554
2016-03-31 14:38:15 +02:00
Juergen Hoeller 14bf6509ec Consistent cache key implementation across transaction and cache attribute sources
Includes consistent applicability of class-level metadata to user-level methods only.

Issue: SPR-14017
Issue: SPR-14095
2016-03-30 14:13:04 +02:00
Juergen Hoeller 5619b005f0 Polishing 2016-03-30 10:22:30 +02:00
Sam Brannen d40d2ffe5e Polishing 2016-03-29 18:04:26 +02:00
Brian Clozel b947bfe8e9 Support of HTTP persistent connections for JDK client
Prior to this commit, HTTP clients relying on the JDK HTTP client would
not properly reuse existing TCP connections (i.e. HTTP 1.1 persisten
connection). The SimpleClientHttpResponse would close the actual connection once the
response is handled.

As explained in the JDK documentation
(http://docs.oracle.com/javase/8/docs/technotes/guides/net/http-keepalive.html)
HTTP clients should do the following to allow resource reuse:

* consume the whole HTTP response content
* close the response inputstream once done

This commit makes sure that the response content is
totally drained and then the stream closed (and not the connection).

Issue: SPR-14040
2016-03-29 17:31:42 +02:00
Juergen Hoeller 3910350b0a ASM ClassReader leniently handles label offset mismatch
Issue: SPR-14089
2016-03-29 15:38:23 +02:00
Juergen Hoeller 54aeb7a5d6 Cache key classes implement Comparable and consistently provide a toString representation
Issue: SPR-14017
2016-03-26 14:32:10 +01:00
Sam Brannen fee056a1b1 Simplify search algorithms in AnnotatedElementUtils
This commit introduces a boolean alwaysProcesses() method in the
Processor API which allows for simplification across all search
algorithms within AnnotatedElementUtils.

Specifically, it is no longer necessary for process() methods to verify
that the supplied annotation is actually the sought target annotation.

In addition, duplicated code has been extracted into common methods
(e.g., hasMetaAnnotationTypes()) and common Processor implementations
(e.g., AlwaysTrueBooleanAnnotationProcessor).
2016-03-25 15:59:54 +01:00
Sam Brannen 6b7731cc89 Cross reference getMergedRepeatableAnnotations() in AnnotationUtils 2016-03-25 00:47:44 +01:00
Sam Brannen 46e0484bf8 Support searches for merged repeatable annotations with "get" semantics
This commit picks up where 2535469099 left off with added support for
"get" search semantics for merged repeatable annotations.

Specifically, this commit introduces a new
getMergedRepeatableAnnotations() method in AnnotatedElementUtils.

Issue: SPR-13973
2016-03-24 19:27:32 +01:00
Sam Brannen 8d0083ca96 Polishing 2016-03-24 19:27:32 +01:00
Juergen Hoeller 517ebd1d3e Consistent formatting 2016-03-24 19:22:50 +01:00
Juergen Hoeller 55f1c98c39 Consistent alphabetical sorting of directory content
Issue: SPR-14085
2016-03-24 15:00:17 +01:00
Sam Brannen 1ec35e9c62 Support searches for multiple merged annotations with "get" semantics
This commit picks up where a5139f3c66 left off with added support for
"get" search semantics for multiple merged annotations.

Specifically, this commit introduces a new getAllMergedAnnotations()
method in AnnotatedElementUtils.

Issue: SPR-13486
2016-03-24 14:46:56 +01:00
Sam Brannen 2453edbb10 Reorganize methods in AnnotatedElementUtils 2016-03-24 13:18:54 +01:00
Sam Brannen 2535469099 Support repeatable annotations as composed annotations
Prior to this commit, AnnotationUtils supported searching for
repeatable annotations even if the repeatable annotation was declared
on a custom stereotype annotation. However, there was no support for
merging of attributes in composed repeatable annotations. In other
words, it was not possible for a custom annotation to override
attributes in a repeatable annotation.

This commit addresses this by introducing
findMergedRepeatableAnnotations() methods in AnnotatedElementUtils.
These new methods provide full support for explicit annotation
attribute overrides configured via @AliasFor (as well as
convention-based overrides) with "find semantics".

Issue: SPR-13973
2016-03-23 21:58:34 +01:00
Juergen Hoeller 63115ed6eb Do not use annotation detection shortcuts on Class
Issue: SPR-13440
2016-03-23 19:27:30 +01:00
Juergen Hoeller c5b318a4cc Revised 4.3 signatures for MethodParameter/DependencyDescriptor
Issue: SPR-13440
2016-03-23 18:52:27 +01:00
Juergen Hoeller 9af12d290e Polishing 2016-03-23 18:39:29 +01:00
Juergen Hoeller 5025c615b1 Consistent use of AnnotatedElementUtils.findMergedAnnotation/hasAnnotation
Issue: SPR-13440
2016-03-23 18:39:20 +01:00
Sam Brannen a5139f3c66 Support searches for multiple merged composed annotations
Prior to this commit it was possible to search for the 1st merged
annotation above an annotated element. It was also possible to search
for annotation attributes aggregated from all annotations above an
annotated element; however, it was impossible to search for all
composed annotations above an annotated element and have the results as
synthesized merged annotations instead of a multi-map of attributes.

This commit introduces a new findAllMergedAnnotations() method in
AnnotatedElementUtils that finds all annotations of the specified type
within the annotation hierarchy above the supplied element. For each
such annotation found, it merges that annotation's attributes with
matching attributes from annotations in lower levels of the annotation
hierarchy and synthesizes the results back into an annotation of the
specified type. All such merged annotations are collected and returned
as a set.

Issue: SPR-13486
2016-03-20 19:18:11 +01:00
Sam Brannen f1378aa376 Test status quo for finding multiple composed annotations
This commit introduces tests that verify the status quo for finding
multiple merged composed annotations on a single annotated element.

Issue: SPR-13486
2016-03-19 20:22:04 +01:00
Sam Brannen 744350a262 Polishing 2016-03-19 18:28:05 +01:00
Sam Brannen d22480b0eb Ensure all aliased attributes in target annotation are overridden
Prior to this commit, it was possible that implicit aliases and
transitive implicit aliases (configured via @AliasFor) might not be
honored in certain circumstances, in particular if implicit aliases
were declared to override different attributes within an alias pair in
the target meta-annotation.

This commit addresses this issue by ensuring that all aliased
attributes in the target meta-annotation are overridden during the
merge process in AnnotatedElementUtils.

In addition, concrete default values for attributes in a
meta-annotation declaration can now be effectively shadowed by
transitive implicit aliases in composed annotations.

Issue: SPR-14069
2016-03-19 16:42:56 +01:00
Juergen Hoeller 6e3fac85f3 AnnotationAwareOrderComparator uses DecoratingProxy interface for target class introspection
Issue: SPR-13884
2016-03-18 22:12:10 +01:00
Sam Brannen 11221f5ccb Fix Javadoc errors in AnnotatedElementUtils 2016-03-18 19:31:05 +01:00
Juergen Hoeller 1ca4340271 NumberUtils consistently raises overflow exception for BigInteger/BigDecimal input
Issue: SPR-14041
2016-03-18 18:51:41 +01:00
Juergen Hoeller ec7c3aa349 Correct RFC 4648 references in method-level javadoc
Issue: SPR-14067
2016-03-18 15:30:33 +01:00
Sam Brannen 2153d88706 Add TODO in AnnotatedElementUtilsTests
Issue: SPR-14069
2016-03-18 15:29:25 +01:00
Sam Brannen 856da8e395 Introduce tests for transitive aliases with implied attribute names 2016-03-17 20:53:52 +01:00
Juergen Hoeller 35eb52e558 Abstract(Stax)XMLReader recognizes standard features as not supported
Issue: SPR-14056
2016-03-16 18:04:02 +01:00
Stephane Nicoll f422e490b0 Polish contribution
Issue: SPR-14039 - Closes gh-998
2016-03-16 17:00:00 +01:00
Yanming Zhou 1a302e1fac Add converters between Enum and Integer 2016-03-16 17:00:00 +01:00
Sam Brannen dfd4aae4f6 Add missing constructors to SynthesizingMethodParameter
This commit primarily allows for a `SynthesizingMethodParameter` to be
created for a `Constructor` parameter but also introduces an additional
overloaded constructor from `MethodParameter`.

Issue: SPR-14054
2016-03-15 16:28:36 +01:00
Juergen Hoeller 71294df238 Upgrade to ASM 5.1
Issue: SPR-14037
2016-03-11 15:09:03 +01:00
Sam Brannen eb654dc177 Allow single element to override array in synthesized annotation
This commit picks up where 8ff9e818a5
left off.

Specifically, this commit introduces support that allows a single
element attribute to override an array attribute with a matching
component type when synthesizing annotations (e.g., in annotations
synthesized from attributes that have been merged from the annotation
hierarchy above a composed annotation).

Issue: SPR-13972
2016-03-07 15:22:27 +01:00
Sebastien Deleuze c385427397 Allow to specify AbstractHttpMessageConverter default charset
Before this commit, specifying the charset to use with produces or
consumes @RequestMapping attributes resulted in default charset
loss. That was really annoying for JSON for example, where using
UTF-8 charset is mandatory in a lot of use cases.

This commit adds a defaultCharset property to
AbstractHttpMessageConverter in order to avoid losing the
default charset when specifying the charset with these
@RequestMapping attributes.

It changes slightly the default behavior (that's why we have waited
4.3), but it is much more error prone, and will match with most
user's expectations since the charset loss was accidental in most
use cases (users usually just want to limit the media type supported
by a specific handler method).

Issue: SPR-13631
2016-02-29 23:34:32 +01:00
Stephane Nicoll 5923ee8af3 Add sun.misc annotation marker
This commit adds an annotation that should be used to mark any usage of
the `sun.misc` API.
2016-02-29 17:43:04 +01:00
Juergen Hoeller 7a32ce317c LinkedCaseInsensitiveMap provides reliable getOrDefault implementation
Issue: SPR-13981
2016-02-25 21:42:11 +01:00
Juergen Hoeller b6dd8a9233 Consistent UnsatisfiedDependencyException exposure with injection point metadata
Issue: SPR-13968
2016-02-25 21:36:49 +01:00
Juergen Hoeller 4c964473b1 Defensively close jar files from non-cached JarURLConnections
Issue: SPR-6295
2016-02-25 10:25:13 +01:00
Juergen Hoeller ca19920d74 Refined ApplicationContextInitializer assignability exception 2016-02-24 17:50:14 +01:00
Juergen Hoeller 028a690100 Polishing 2016-02-23 14:31:09 +01:00
Juergen Hoeller 1899fb37c1 Polishing 2016-02-22 23:26:41 +01:00
Juergen Hoeller a3789120c9 Support for @PropertySource annotations with custom implementation types
Issue: SPR-8963
2016-02-22 23:25:50 +01:00
Juergen Hoeller 8ff9e818a5 Allow for a single element overriding an array attribute in a meta-annotation
Includes refinements for consistent quoting of names in exception messages.

Issue: SPR-13972
2016-02-22 23:24:30 +01:00
Phillip Webb d8a05592e2 Allow package private classes in spring.factories
Update SpringFactoriesLoader so that package private classes can be
used.

Issue: SPR-13969
2016-02-22 10:01:35 -08:00
mnhock e98977cbc8 Fix Format-string method arguments
Closes gh-934
2016-02-20 09:01:54 +01:00
Phillip Webb c4117885bd Refine AntPathMatcher optimizations
Refine the optimizations made in 6f55ab69 in order to restore binary
compatibility and resolve a regression.

Tests of the form pathMatcher.match("/foo/bar/**", "/foo/bar") should
return true as this was the behavior in Spring 4.2.

Issue: SPR-13913
2016-02-18 18:49:58 -08:00
Juergen Hoeller 25be5e060c TaskDecorator callback supported by common TaskExecutor implementations
Issue: SPR-13930
2016-02-17 16:58:02 +01:00
Juergen Hoeller f6ebc4ce97 Polishing 2016-02-11 22:24:50 +01:00
Juergen Hoeller 37de0b241d ProtocolResolver SPI allows for custom resource resolution
Issue: SPR-12857
Issue: SPR-13905
2016-02-11 22:21:26 +01:00
soldierkam e77ff3c991 Improve AntPathMatcher matching performance
This commit speeds up the AntPathMatcher implementation by
pre-processing patterns and checking that candidates are likely
matches if they start with the static prefix of the pattern.

Those changes can result in a small performance penalty for positive
matches, but with a significant boost for checking candidates that don't
match. Overall, this tradeoff is acceptable since this feature is often
used to select a few matching patterns in a much bigger list.

This will lead to small but consistent performance improvements in
Spring MVC when matching a given request with the available routes.

Issue: SPR-13913
2016-02-10 11:39:38 +01:00
Juergen Hoeller 449f704650 PathMatchingResourcePatternResolver consistently logs retrieval results
Issue: SPR-13923
2016-02-08 13:18:43 +01:00
Juergen Hoeller e90310612f Polishing 2016-02-04 20:00:00 +01:00
Juergen Hoeller b4f33adf48 Consistent java.util.Optional resolution, lenient handling of optional multipart files, correct Servlet 3.0 Part list/array selection
Issue: SPR-13418
Issue: SPR-13849
Issue: SPR-13850
Issue: SPR-13893
2016-01-26 18:06:15 +01:00
Juergen Hoeller 64ce8a81c3 Polishing 2016-01-25 20:33:48 +01:00
Juergen Hoeller 8a69159004 ConverterRegistry's addConverter declares generic type variables
Issue: SPR-12948
2016-01-25 20:33:26 +01:00
Juergen Hoeller 74c07d3085 Removed JavaVersion checks from spring-core tests (for JDK 9 compatibility)
Issue: SPR-13344
2016-01-15 17:45:37 +01:00
Stephane Nicoll 2fc2c29e9a Update copyright header 2016-01-15 10:51:11 +01:00
Rossen Stoyanchev 3dae3fd8a9 Refine ListenableFutureCallback policy for exceptions
This change updates all cases where callbacks are invoked to catch and
suppress errors (since there is not match to do with and error from
a callback be it success or failure).

Also updated is the contract itself to clarify this and emphasize the
callbacks are really notifications for the outcome of the
ListenableFuture not the callbacks themselves.

Issue: SPR-13785
2016-01-14 17:49:01 -05:00
Juergen Hoeller 5d4547d343 FastByteArrayInputStream consistently returns -1 when no data available
Issue: SPR-13858
2016-01-13 12:44:34 +01:00
Juergen Hoeller 8968f09c59 Polishing 2015-12-29 22:04:38 +01:00
Juergen Hoeller 27c2e8c80d Polishing 2015-12-29 21:40:20 +01:00
Juergen Hoeller aecb8b6c6b Avoid sensitive Proxy.getInvocationHandler call in synthesizeAnnotation
Issue: SPR-13829
2015-12-29 21:39:43 +01:00
Juergen Hoeller 4f955932a7 @Value can be used as aliased meta-annotation
Issue: SPR-13603
2015-12-29 18:02:16 +01:00
Juergen Hoeller 3242ad8fc4 @AliasFor attribute name defaults to declaring attribute
Issue: SPR-13828
2015-12-29 17:58:57 +01:00
Juergen Hoeller d1551bdcec Polishing 2015-12-23 21:19:18 +01:00
Juergen Hoeller 470ea977e1 Consistent validation of annotated methods behind AOP proxies
Issue: SPR-13816
2015-12-23 20:47:28 +01:00
Juergen Hoeller 95d62658ff SystemEnvironmentPropertySource replaces hyphens in property names as well
Issue: SPR-13594
2015-12-22 16:18:13 +01:00
Juergen Hoeller cf20308134 SerializationDelegate as convenient Serializer/Deserializer combo
Issue: SPR-13758
2015-12-22 13:04:10 +01:00
Juergen Hoeller f8860e2938 SimpleNamespaceContext implements all subtleties of the NamespaceContext contract
Issue: SPR-13713
2015-12-21 20:37:44 +01:00
Juergen Hoeller 64bd8b7f34 Polishing 2015-12-18 22:19:03 +01:00
Juergen Hoeller 387c8a8181 Differentiate between TypeDescriptors with same annotations but different attributes
Issue: SPR-13714
2015-12-18 22:10:50 +01:00
Juergen Hoeller 08748ecaa4 PathMatchingResourcePatternResolver evaluates classpath manifest entries as well
Issue: SPR-13685
2015-12-18 12:17:57 +01:00
Sam Brannen 5b3edcd9f9 Spring Cleaning in December
- Delete unused imports
- Delete unused code
- Clean up warnings
2015-12-17 20:27:33 +01:00
Juergen Hoeller a36c0a50e6 Defensive error reporting when StandardAnnotationMetadata introspects declared methods
Issue: SPR-13791
2015-12-14 15:13:29 +01:00
Juergen Hoeller 0968e47b04 Polishing 2015-12-11 21:56:26 +01:00
Gary Russell 14fc6c2a99 SPR-13784: Base64Utils: URL/File Safe Alphabet
JIRA: https://jira.spring.io/browse/SPR-13784

JDK8 and Apache Commons Codec support the RFC 4648
"URL and Filename Safe" Base64 alphabet.

Add methods to `Base64Utils` to support this feature.
2015-12-11 14:55:15 -05:00
Juergen Hoeller fdc14a16ee AbstractApplicationContext clears ReflectionUtils cache as well
Issue: SPR-13783
2015-12-09 19:25:27 +01:00
Juergen Hoeller d0814703c4 AnnotationUtils.synthesizeAnnotation explicitly checks whether SynthesizedAnnotation is exposable
Issue: SPR-13696
2015-12-07 17:36:14 +01:00
Juergen Hoeller ee35b5ed07 Polishing 2015-12-07 12:52:06 +01:00
Juergen Hoeller 08b6daf1eb Polishing 2015-12-03 18:41:03 +01:00
Juergen Hoeller c909789ea9 Avoid mismatch between cached top-level versus nested parameter type
Issue: SPR-13755
2015-12-03 12:53:18 +01:00
Juergen Hoeller 44651fdf7c ObjectToObjectConverter caches detected methods/constructors
This commit reworks the arrangement to a centralized cache, avoiding any extra reflection attempts if a cache entry is known already. In the course of this, it also enforces toXXX methods to be declared as non-static now (which is the only sensible arrangement anyway).

Issue: SPR-13703
2015-12-01 16:07:21 +01:00
Juergen Hoeller 38c21ee6bf Class identity comparisons wherever possible
Issue: SPR-12926
2015-12-01 14:11:44 +01:00
Juergen Hoeller 4755467cca Polishing 2015-11-30 12:36:30 +01:00
Juergen Hoeller 3234d9ede3 ObjectToObjectConverter caches detected methods/constructors
Includes polishing of related conversion exception messages.

Issue: SPR-13703
2015-11-29 22:17:16 +01:00
Juergen Hoeller a0747c2148 Consistent bean type checking for endpoint handlers
Issue: SPR-13725
2015-11-25 21:26:03 +01:00
Juergen Hoeller 20a286b4d6 ASM ClassWriter uses application ClassLoader for its getCommonSuperClass check
Issue: SPR-13695
2015-11-24 17:38:02 +01:00
Juergen Hoeller 0524f3a474 Class identity comparisons wherever possible
Issue: SPR-12926
2015-11-24 17:37:30 +01:00
Juergen Hoeller 1cb6069734 Polishing 2015-11-14 23:52:39 +01:00
Juergen Hoeller 4b2ce60d65 Polishing 2015-11-13 08:31:13 +01:00
Juergen Hoeller 2bf8c0bc42 Polishing 2015-11-10 23:47:46 +01:00
Phillip Webb e6b1f0a139 Use constants when caching empty arrays
Reduce cache memory consumption by using a single constant for empty
arrays.
2015-11-09 09:38:48 -08:00
Juergen Hoeller 760bc719f2 Polishing 2015-11-09 15:03:14 +01:00
Juergen Hoeller bc7bcab578 Consistent method selection for listeners and endpoint mappings
Issue: SPR-13654
2015-11-09 14:57:45 +01:00
Sam Brannen 5b06150096 Deprecate correct method in AnnotatedElementUtils 2015-11-09 12:05:28 +00:00
Juergen Hoeller 59b6600763 Class identity comparisons wherever possible
Issue: SPR-12926
2015-11-08 20:45:17 +01:00
Juergen Hoeller ea2843ecc0 MethodInvokeTypeProvider lazily invokes target method (avoiding deserialization exploits)
Issue: SPR-13656
2015-11-08 20:27:06 +01:00
Juergen Hoeller c88877f1c4 Polishing 2015-11-05 16:35:20 +01:00
Juergen Hoeller 9683da52b2 Avoid annotation synthesizing for getAnnotationAttributes retrieval
Issue: SPR-13621
2015-11-05 16:35:07 +01:00
Juergen Hoeller 2ba5cb2734 Polishing 2015-11-05 12:30:29 +01:00
Juergen Hoeller e27df06f91 AnnotatedElementUtils consistently operates on actual annotation type if available (for performance reasons)
The goal is to avoid String name comparisons in favor of annotation type identity checks wherever possible. Also, we avoid double getDeclaredAnnotations/getAnnotations checks on anything other than Classes now, since we'd just get the same result in a fresh array.

Issue: SPR-13621
2015-11-05 12:29:29 +01:00
Juergen Hoeller e35855f9b5 Avoid expensive annotation retrieval algorithm if no annotations present in the first place
Issue: SPR-13621
2015-11-05 12:26:54 +01:00
Phillip Webb 1733d0111d Add shortcuts for elements with no annotations
Improve the performance of the `getMergedAnnotationAttributes` and
`isAnnotated` methods in `AnnotatedElementUtils` by returning
immediately when the element had no annotations.

Issue: SPR-13621
2015-11-04 22:42:34 -08:00
Juergen Hoeller ce64761069 Optimized equals/hashCode handling in ResolvableType
Issue: SPR-13621
2015-11-03 16:56:43 +01:00
Juergen Hoeller 23c8f712c4 Polishing 2015-11-02 21:30:03 +01:00
Juergen Hoeller c3dbaed4ce AnnotationUtils caches findAnnotation results in pre-synthesized form
Issue: SPR-13621
2015-11-02 21:25:08 +01:00
Juergen Hoeller 4dc31667d4 AnnotationUtils defines synthesized proxy class in original annotation's ClassLoader
Issue: SPR-13634
2015-11-02 21:24:32 +01:00
Juergen Hoeller cca037a74d Polishing 2015-11-02 14:42:46 +01:00
Stephane Nicoll 0579e61a65 Add API to register collection converters
Previously, the only way to add the collection converters to a registry
was to add *all* default converters. A new "addCollectionConverters"
public method is now available to only register them.

Issue: SPR-13618
2015-10-28 15:55:29 +01:00
Juergen Hoeller 91b3caf238 Fixed visibility of 4.2's additional default converters
Issue: SPR-12175
Issue: SPR-13020
2015-10-28 15:38:46 +01:00
Juergen Hoeller 400749667a Polishing 2015-10-26 23:10:33 +01:00
Sam Brannen c2bc2b27ea Suppress varargs warnings when compiling tests w/ Gradle 2015-10-14 02:00:08 +03:00
Juergen Hoeller 1c3a668370 AbstractFileResolvingResource uses extractArchiveURL for last-modified check
Issue: SPR-13393
(cherry picked from commit 302a069)
2015-10-13 20:47:29 +02:00
Juergen Hoeller 155bbf5057 ResourceUtils supports Tomcat's "war🫙" URL format
Issue: SPR-13393
2015-10-13 14:36:00 +02:00
Juergen Hoeller 66177dfd8c StreamUtils.emptyInput() for consistent empty InputStream exposure
Issue: SPR-13563
2015-10-12 22:25:40 +02:00
Juergen Hoeller 21e0e27fcb Removed superfluous ObjectStreamException declaration 2015-10-09 22:55:28 +02:00
Sam Brannen 1a227da19e Polish AnnotatedElementUtilsTests 2015-10-09 22:51:27 +02:00
Sam Brannen 5e1d6e47a9 Introduced failing, @Ignored test for SPR-13554
Issue: SPR-13554
2015-10-09 22:23:49 +02:00
Juergen Hoeller 6993a7d3d0 Polishing 2015-10-06 13:30:13 +02:00
Juergen Hoeller 9cf28950e5 PathResourceTests defensively compares last-modified timestamps at seconds precision
Issue: SPR-13542
2015-10-06 13:25:27 +02:00
Juergen Hoeller 427767f21e Fixed event listener caching through equals/hashCode on SyntheticParameterizedType
Issue: SPR-13540
2015-10-06 00:05:51 +02:00
Sam Brannen d5ee787e1e Migrate JUnit 3 tests to JUnit 4
This commit migrates all remaining tests from JUnit 3 to JUnit 4, with
the exception of Spring's legacy JUnit 3.8 based testing framework that
is still in use in the spring-orm module.

Issue: SPR-13514
2015-09-27 21:17:51 +02:00
Juergen Hoeller a6a6aed17f StopWatch provides getId/currentTaskName accessors (plus further fine-tuning)
Issue: SPR-13509
2015-09-25 15:23:39 +02:00
Juergen Hoeller e393c7b1ee AbstractEnvironment defensively synchronizes access to activeProfiles and defaultProfiles
Issue: SPR-13213
2015-09-08 11:03:15 +02:00
Sam Brannen c663fd551a Polishing 2015-09-03 17:31:55 +02:00
Sam Brannen 2caaa81afa Polishing 2015-09-02 15:37:16 +02:00
Sam Brannen 21cfa0e4ba Suppress warning in DefaultDeserializer 2015-09-02 15:25:10 +02:00
Sam Brannen b9e461a54f Polishing 2015-09-02 15:07:49 +02:00
Juergen Hoeller 0867a5e67f Polishing 2015-09-01 10:22:39 +02:00
Sam Brannen 9b1178cf71 Document support for transitive implicit aliases in @AliasFor
Issue: SPR-13405
2015-09-01 00:30:33 +02:00
Juergen Hoeller 566ea30167 Polishing 2015-08-31 17:32:33 +02:00
Juergen Hoeller 2bb7164c64 AsyncRestTemplate and FutureAdapter consistently throw ExecutionException
Issue: SPR-13413
2015-08-31 17:31:52 +02:00
Juergen Hoeller d99717c1cb DefaultDeserializer and DeserializingConverter allow for specifying a ClassLoader
Issue: SPR-13409
2015-08-31 17:31:41 +02:00
Sam Brannen acc8c895bf Make AnnotationUtils Java 6 source compatible 2015-08-31 15:54:46 +02:00
Sam Brannen 2a6716d380 Support transitive implicit attribute aliases with @AliasFor
This commit picks up where 3eacb837c2
(SPR-13345) left off by adding support for transitive implicit aliases
configured via @AliasFor.

Issue: SPR-13405
2015-08-31 15:46:12 +02:00
Sam Brannen a066143a5b Polishing
This commit removes unnecessary not-null checks for annotation
attribute alias names.
2015-08-29 16:05:26 +02:00
Sam Brannen d40a35ba5c Support implicit attribute aliases with @AliasFor
Spring Framework 4.2 introduced support for aliases between annotation
attributes that fall into the following two categories.

1) Alias pairs: two attributes in the same annotation that use
   @AliasFor to declare that they are explicit aliases for each other.
2) Meta-annotation attribute overrides: an attribute in one annotation
   uses @AliasFor to declare that it is an explicit override of an
   attribute in a meta-annotation.

However, the existing functionality fails to support the case where two
attributes in the same annotation both use @AliasFor to declare that
they are both explicit overrides of the same attribute in the same
meta-annotation. In such scenarios, one would intuitively assume that
two such attributes would be treated as "implicit" aliases for each
other, analogous to the existing support for explicit alias pairs.
Furthermore, an annotation may potentially declare multiple aliases
that are effectively a set of implicit aliases for each other.

This commit introduces support for implicit aliases configured via
@AliasFor through an extensive overhaul of the support for alias
lookups, validation, etc. Specifically, this commit includes the
following.

- Introduced isAnnotationMetaPresent() in AnnotationUtils.

- Introduced private AliasDescriptor class in AnnotationUtils in order
  to encapsulate the parsing, validation, and comparison of both
  explicit and implicit aliases configured via @AliasFor.

- Switched from single values for alias names to lists of alias names.

- Renamed getAliasedAttributeName() to getAliasedAttributeNames() in
  AnnotationUtils.

- Converted alias map to contain lists of aliases in AnnotationUtils.

- Refactored the following to support multiple implicit aliases:
  getRequiredAttributeWithAlias() in AnnotationAttributes,
  AbstractAliasAwareAnnotationAttributeExtractor,
  MapAnnotationAttributeExtractor, MergedAnnotationAttributesProcessor
  in AnnotatedElementUtils, and postProcessAnnotationAttributes() in
  AnnotationUtils.

- Introduced numerous tests for implicit alias support, including
  AbstractAliasAwareAnnotationAttributeExtractorTestCase,
  DefaultAnnotationAttributeExtractorTests, and
  MapAnnotationAttributeExtractorTests.

- Updated Javadoc in @AliasFor regarding implicit aliases and in
  AnnotationUtils regarding "meta-present".

Issue: SPR-13345
2015-08-28 18:56:17 +02:00
Juergen Hoeller 0c2b787cb5 ASM fix #317578
http://forge.ow2.org/tracker/?func=detail&aid=317578&group_id=23&atid=100023
2015-08-27 22:03:36 +02:00
Sam Brannen 8af0151f1b Suppress recent deprecation warnings in tests 2015-08-27 17:57:50 +02:00
Juergen Hoeller e518d7dcc6 Mark log4j support classes as deprecated in favor of Apache Log4j 2 (following Apache's EOL declaration for log4j 1.x)
Issue: SPR-13400
2015-08-27 12:36:57 +02:00
Juergen Hoeller e05fb494f5 Polishing 2015-08-26 11:04:14 +02:00
Juergen Hoeller 3430f7623c Consistent detection of meta-annotation attributes via ASM
Issue: SPR-13394
2015-08-25 21:52:11 +02:00
Juergen Hoeller b198cad58e SimpleAliasRegistry detects circles between non-canonical aliases as well (through hasAlias)
Additionally, as an optimization, we skip the re-registration step for existing aliases now.

Issue: SPR-13390
2015-08-25 17:06:23 +02:00
Sam Brannen 6085be3a71 Assert status quo for finding annotations on bridged methods 2015-08-22 16:49:12 +02:00
Sam Brannen a3e7848a30 Clean up warnings and tests in spring-core 2015-08-20 15:49:33 +02:00
Stephane Nicoll 71585c909a Polish 2015-08-17 14:44:59 +02:00
Sam Brannen 68c39570fe Revert "Increase randomness in SocketUtils"
This reverts commit d5944c4e39.
2015-08-16 14:39:48 +02:00
Sam Brannen d5944c4e39 Increase randomness in SocketUtils 2015-08-15 23:48:20 +02:00
Sam Brannen f47bbb0d9e Polish tests 2015-08-12 19:35:45 +02:00
Gary Russell f15140415a Properly detect available port on localhost in SocketUtils
SocketUtils is used to find available ports on localhost; however,
prior to this commit, SocketUtils incorrectly reported a port as
available on localhost if another process was already bound to
localhost on the given port but not to other network interfaces. In
other words, SocketUtils determined that a given port was available for
some interface though not necessarily for the loopback interface.

This commit addresses this issue by refactoring SocketUtils so that it
tests the loopback interface to ensure that the port is actually
available for localhost.

Issue: SPR-13321
2015-08-12 18:45:52 +02:00
Juergen Hoeller e0f012f32d Removal of redundant JdkVersion checks in the test suite
Issue: SPR-13312
2015-08-12 18:42:36 +02:00
Sam Brannen acb44f9d46 Suppress warnings regarding deprecated JdkVersion
Issue: SPR-13312
2015-08-12 17:36:28 +02:00
Juergen Hoeller bec3b0fa1a Deprecate JdkVersion (for optimistic compatibility with newer JDK generations)
Issue: SPR-13312
2015-08-12 16:14:43 +02:00
Sam Brannen e20b47c3bc Ensure local aliases don't override meta-annotation
This commit introduces an additional test case to ensure that explicit
local attribute aliases (configured via @AliasFor) do not accidentally
override attributes of the same names in meta-annotations (i.e., by
convention).

Issue: SPR-13325
2015-08-12 14:38:01 +02:00
Sam Brannen 4317e76e79 Polish AnnotationUtilsTests 2015-08-12 14:36:54 +02:00
Sam Brannen 5deeaf348a Polish SynthesizedAnnotation support classes 2015-08-10 15:40:25 +02:00
Sam Brannen f17173f6d5 Synthesize nested maps into annotations
Prior to this commit, attempting to synthesize an annotation from a map
of annotation attributes that contained nested maps instead of nested
annotations would result in an exception.

This commit addresses this issue by properly synthesizing nested maps
and nested arrays of maps into nested annotations and nested arrays of
annotations, respectively.

Issue: SPR-13338
2015-08-10 14:55:54 +02:00
Sam Brannen 8289036165 Throw exception if required meta-annotation is not present
It is a configuration error if an alias is declared via @AliasFor for
an attribute in a meta-annotation and the meta-annotation is not
meta-present. However, prior to this commit, the support for validating
the configuration of @AliasFor in AnnotationUtils currently silently
ignored such errors.

This commit fixes this by throwing an AnnotationConfigurationException
whenever a required meta-annotation is not present or meta-present on
an annotation that declares an explicit alias for an attribute in the
meta-annotation.

Issue: SPR-13335
2015-08-09 19:14:29 +02:00
Sam Brannen 78ff4ff542 Polish AnnotationUtilsTests 2015-08-09 16:48:38 +02:00
Sam Brannen 48b965ad33 Improve performance of NumberUtils
This commit aims to improve the space and time performance of
NumberUtils by invoking valueOf() factory methods instead of the
corresponding constructors when converting a number to a target class.
2015-08-06 19:42:03 +02:00
Sam Brannen e0392d9da5 Polish NumberUtilsTests 2015-08-06 19:31:44 +02:00
Sam Brannen 15033c1cc9 Polish Javadoc for NumberUtils 2015-08-06 19:21:02 +02:00
Sam Brannen c8d604bf05 Ensure @AliasFor overrides attribute in correct meta-annotation
Prior to this commit, an explicit override for an attribute in a
meta-annotation configured via @AliasFor could potentially result in an
incorrect override of an attribute of the same name but in the wrong
meta-annotation.

This commit fixes the algorithm in getAliasedAttributeName(Method,
Class) in AnnotationUtils by ensuring that an explicit attribute
override is only applied to the configured target meta-annotation
(i.e., configured via the 'annotation' attribute in @AliasFor).

Issue: SPR-13325
2015-08-06 19:04:08 +02:00
Stephane Nicoll 1a659e3c1d Polish 2015-08-05 08:36:01 +02:00
Sam Brannen 1ff3af6da3 Improve Javadoc for Ordered/@Order regarding sort semantics 2015-07-30 15:24:04 +02:00
Sam Brannen a07ba695b0 Make @Order @Documented 2015-07-30 15:21:32 +02:00
Sam Brannen 1c8ac2b2aa Update @AliasFor Javadoc regarding new 'value' alias
Issue: SPR-13289
2015-07-29 16:08:42 +02:00
Sam Brannen 725292081e Introduce 'value' alias for 'attribute' in @AliasFor
SPR-11512 introduced support for annotation attribute aliases via
@AliasFor, requiring the explicit declaration of the 'attribute'
attribute. However, for aliases within an annotation, this explicit
declaration is unnecessary.

This commit improves the readability of alias pairs declared within an
annotation by introducing a 'value' attribute in @AliasFor that is an
alias for the existing 'attribute' attribute. This allows annotations
such as @ContextConfiguration from the spring-test module to declare
aliases as follows.

public @interface ContextConfiguration {

     @AliasFor("locations")
     String[] value() default {};

     @AliasFor("value")
     String[] locations() default {};

    // ...
}

Issue: SPR-13289
2015-07-29 15:27:06 +02:00
Juergen Hoeller 291550a484 AntPathMatcher allows for case-insensitive matching
Issue: SPR-13286
2015-07-29 12:38:41 +02:00
Juergen Hoeller 965fca808a Polishing 2015-07-29 01:08:16 +02:00
Sam Brannen 288d253b8b Introduce support for conditional lambda execution in Spring's Assume 2015-07-27 19:48:01 +02:00
Sam Brannen b6c0e7cba3 Remove trailing whitespace in Java source code 2015-07-27 12:40:54 +02:00
Juergen Hoeller 0cce41eb94 Fixed exception message expectation plus formatting
Issue: SPR-13067
2015-07-17 16:19:11 +02:00
Juergen Hoeller aedef43a9a Exception fine-tuning and general polishing
Issue: SPR-13067
2015-07-17 15:24:04 +02:00
Sam Brannen 0940f43a47 Stop documenting annotations using @AliasFor in Javadoc
The removed listing will later be incorporated into the reference manual
in a dedicated section.

Issue: SPR-11515
2015-07-08 15:13:09 +02:00
Juergen Hoeller 145d88d152 Polishing 2015-07-07 00:26:31 +02:00
Juergen Hoeller df8e9638ee LinkedMultiValueMap explicitly supports deep copies
Issue: SPR-13201
2015-07-07 00:24:39 +02:00
Sam Brannen 67ac675e9a Polish AnnotationAttributes[Tests] 2015-07-06 14:41:52 +02:00
Juergen Hoeller b7acddbb19 AnnotationAttributes stores and re-throws resolution exceptions
Issue: SPR-13177
2015-07-06 13:35:16 +02:00
Juergen Hoeller 265cd2ad1e Javadoc fine-tuning for 4.2 2015-06-30 18:02:42 +02:00
Sam Brannen 49aabd5ac2 Polish Javadoc for (Synthesizing)MethodParameter 2015-06-30 00:30:42 +02:00
Juergen Hoeller dc1f921f5c Split between basic MethodParameter and SynthesizingMethodParameter
This split avoids a package tangle (between core and core.annotation) and also allows for selective use of raw annotation exposure versus synthesized annotations, with the latter primarily applicable to web and message handler processing at this point.

Issue: SPR-13153
2015-06-30 00:02:02 +02:00
Juergen Hoeller a5349eb2f8 Base64Utils falls back to JAXB DatatypeConverter for String-based encoding
Issue: SPR-12938
2015-06-26 22:06:13 +02:00
Rossen Stoyanchev b542b52775 Update Javadoc on AntPathMatcher 2015-06-25 09:41:59 -04:00
Sam Brannen 51e30dd221 Polish MimeType 2015-06-24 23:59:22 +02:00
Sam Brannen 89e504c2f1 Uses Charset instead of String in MimeType.equals()
Prior to this commit, Spring's MimeType checked for equality between
two MIME types based on the equality of their properties maps; however,
the properties maps contain string representations of the "charset"
values. Thus, "UTF-8" is never equal to "utf-8" which breaks the
contract for character set names which must be compared in a
case-insensitive manner.

This commit addresses this issue by ensuring that "charset" properties
in MimeType instances are compared as Java Charset instances, thereby
ignoring case when checking for equality between charset names.

Issue: SPR-13157
2015-06-23 22:30:25 +02:00
Sam Brannen f2f58f1677 Polish Javadoc in MimeType 2015-06-23 21:26:50 +02:00
Sam Brannen 3da59178e5 Document attribute alias support in AnnotationUtils 2015-06-23 18:38:00 +02:00
Sam Brannen 2451594cdd Synthesize annotation arrays within AnnotationUtils
Issue: SPR-11393
2015-06-23 18:30:47 +02:00
Juergen Hoeller 3b6548f3c2 Tests for Base64Utils results between JDK 8 and Commons Codec
Issue: SPR-13146
2015-06-22 00:32:33 +02:00
Sam Brannen d0c0d9fc5a Synthesize annotation from defaults
This commit introduces a convenience method in AnnotationUtils for
synthesizing an annotation from its default attribute values.

TransactionalTestExecutionListener has been refactored to invoke this
new convenience method.

Issue: SPR-13087
2015-06-20 18:27:36 +02:00
Sam Brannen a0040245ca Resolve @Repeatable container in AnnotationUtils
This commit introduces support for automatically resolving a container
annotation configured via @Repeatable in AnnotationUtils'
getRepeatableAnnotations() and getDeclaredRepeatableAnnotations()
methods.

Issue: SPR-13068
2015-06-20 18:05:04 +02:00
Sam Brannen 80622803b2 Fix error in HTML syntax in Javadoc 2015-06-20 17:01:03 +02:00
Sam Brannen 594c330205 Honor contract of @Repeatable in AnnotationUtils
This commit introduces a minor bug fix for getRepeatableAnnotations()
so that it fully complies with the contract of Java's
getAnnotationsByType() method with regard to repeatable annotations
declared on multiple superclasses.

Issue: SPR-13068
2015-06-20 16:53:46 +02:00
Sam Brannen 27d1ce84a3 Polishing 2015-06-20 01:45:46 +02:00
Sam Brannen fb83e83e78 Honor contract of @Repeatable in AnnotationUtils
Prior to this commit, the implementation of getRepeatableAnnotation()
in Spring's AnnotationUtils complied neither with the contract of
getAnnotationsByType() nor with the contract of
getDeclaredAnnotationsByType() as defined in AnnotatedElement in Java 8.

Specifically, unexpected results can be encountered when using Spring's
support for @Repeatable annotations: either annotations show up in the
returned set in the wrong order, or annotations are returned in the set
that should not even be found based on the semantics of @Repeatable.

This commit remedies this problem by deprecating the existing
getRepeatableAnnotation() methods and replacing them with new
getRepeatableAnnotations() and getDeclaredRepeatableAnnotations()
methods that comply with the contracts of Java's getAnnotationsByType()
and getDeclaredAnnotationsByType(), respectively.

Issue: SPR-13068
2015-06-20 01:21:39 +02:00
Sam Brannen 078d252d1e Delete trailing whitespace in Java source code 2015-06-19 17:09:52 +02:00
Sam Brannen b36c9f9f23 Polish introspection failure handling in AnnotationUtils 2015-06-19 15:29:57 +01:00
Sam Brannen 23547a72f3 Clean up warnings and polish tests 2015-06-19 14:57:28 +01:00
Sam Brannen 20a1474554 Polishing 2015-06-19 14:40:01 +01:00
Sam Brannen ece12f9d37 Synthesize annotation from map w/ minimal attributes
The initial support for synthesizing an annotation from a Map (or
AnnotationAttributes) introduced in SPR-13067 required that the map
contain key-value pairs for every attribute defined by the supplied
annotationType. However, there are use cases that would benefit from
being able to supply a reduced set of attributes and still have the
annotation synthesized properly.

This commit refines the validation mechanism in
MapAnnotationAttributeExtractor so that a reduced set of attributes may
be supplied. Specifically, if an attribute is missing in the supplied
map the attribute will be set either to value of its alias (if an alias
value configured via @AliasFor exists) or to the value of the
attribute's default value (if defined), and otherwise an exception will
be thrown.

Furthermore, TransactionalTestExecutionListener has been refactored to
take advantage of this new feature by synthesizing an instance of
@TransactionConfiguration solely from the default values of its
declared attributes.

Issue: SPR-13087
2015-06-19 14:27:23 +01:00
Sam Brannen b65c277fc6 Update list of annotations using @AliasFor 2015-06-17 21:30:02 +01:00
Martin Lippert 63f01c851f Fix exception in AntPathMatcher for leading *
Issue: SPR-13139
2015-06-17 16:15:59 -04:00
Sam Brannen 8743b6bb30 Simplify AnnotatedElementUtils.searchWithFindSemantics() 2015-06-16 22:04:16 +01:00
Sam Brannen 913d0bcf24 Add missing @since tags to AnnotatedElementUtils 2015-06-16 21:45:17 +01:00
Juergen Hoeller 92f1754b1e Fixed fallback mode in ObjenesisCglibAopProxy, plus consistent support for bypassing Objenesis (e.g. on Google App Engine)
This 4.2 commit revises SpringObjenesis towards a smart delegate, including support for a "spring.objenesis.ignore" system property.

Issue: SPR-13131
2015-06-16 22:01:37 +02:00
Juergen Hoeller 06a5ed9cae AbstractApplicationContext resets common introspection caches after refresh
Issue: SPR-13093
2015-06-15 20:34:46 +02:00
Juergen Hoeller 7987f80866 GenericConversionService uses ConcurrentReferenceHashMap instead of ConcurrentHashMap
Issue: SPR-13099
2015-06-15 15:55:53 +02:00
Sam Brannen 32c17bf540 Revise method and parameter names in annotation support
In AnnotatedElementUtils, all methods pertaining to merging annotation
attributes have been renamed to "getMerged*()" and "findMerged*()"
accordingly. Existing methods such as getAnnotationAttributes(..) have
been deprecated in favor of the more descriptive "merged" variants.
This aligns the naming conventions in AnnotatedElementUtils with those
already present in AnnotationReadingVisitorUtils.

The use of "annotationType" as a variable name for the fully qualified
class name of an annotation type has been replaced with
"annotationName" in order to improve the readability and intent of the
code base.

In MetaAnnotationUtils.AnnotationDescriptor, getMergedAnnotation() has
been renamed to synthesizeAnnotation(), and the method is now
overridden in UntypedAnnotationDescriptor to always throw an
UnsupportedOperationException in order to avoid potential run-time
ClassCastExceptions.

Issue: SPR-11511
2015-06-14 00:34:40 +02:00
Sam Brannen 31c547456a Introduce getAliasedString() in AnnotationAttributes
Issue: SPR-11393
2015-06-12 21:09:33 +02:00
Sam Brannen 05de9a8c4a Introduce general purpose isEmpty() method in ObjectUtils
Prior to this commit, there existed several isEmpty() methods scattered
across various utilities such as ObjectUtils, CollectionUtils, and
StringUtils; however, each of these methods requires a cast to the type
supported for that particular variant.

This commit introduces a general-purpose isEmpty(Object) method in
ObjectUtils that transparently supports multiple object types in a
central location without the need for casts or juggling multiple
utility classes.

Issue: SPR-13119
2015-06-12 19:19:22 +02:00
Sam Brannen e7f4544248 Polish ObjectUtilsTests 2015-06-12 19:19:22 +02:00
Stephane Nicoll b87816ed20 Add ResolvableTypeProvider
Provide a mean to detect the actual ResolvableType based on a instance as
a counter measure to type erasure.

Upgrade the event infrastructure to detect if the event (or the payload)
implements such interface. When this is the case, the return value of
`getResolvableType` is used to validate its generic type against the
method signature of the listener.

Issue: SPR-13069
2015-06-09 10:57:31 +02:00
Sam Brannen 384ee69300 Introduce getAliasedClassArray() in AnnotationAttributes
Issue: SPR-11393
2015-06-04 15:23:53 -04:00
Sam Brannen e5dc6e964c Introduce getAliasedStringArray() in AnnotationAttributes
Issue: SPR-11393
2015-06-03 21:26:43 -04:00
izeye b8d7d46da7 Fix typo 2015-06-01 09:21:38 +02:00
Sam Brannen 518c85b107 Support synthesized annotations in MethodParameter 2015-05-29 22:48:55 +02:00
Sam Brannen 1afc938da1 Introduce synthesizeAnnotationArray() in AnnotationUtils 2015-05-29 22:45:34 +02:00
Sam Brannen 9f717871e6 Introduce getAnnotation() in AnnotatedElementUtils
This commit introduces a "synthesized annotation" alternative to
getAnnotationAttributes() in AnnotatedElementUtils, analogous to the
recently introduced findAnnotation() methods.

Issue: SPR-13082
2015-05-29 22:04:10 +02:00
Sam Brannen 9afcd17c71 Introduce getAnnotationAttributes(..,Class) in AnnoElUtils 2015-05-29 21:36:00 +02:00
Sam Brannen 46be176875 Allow AnnoConfigEx to propagate from getRepeatableAnnotation()
Issue: SPR-13084
2015-05-29 21:17:33 +02:00
Sam Brannen 7018747cec Remove trailing whitespace in Java source code 2015-05-29 02:03:44 +02:00
Sam Brannen e30c9b2ef3 Synthesize annotation from a map of attributes
Spring Framework 4.2 RC1 introduced support for synthesizing an
annotation from an existing annotation in order to provide additional
functionality above and beyond that provided by Java. Specifically,
such synthesized annotations provide support for @AliasFor semantics.
As luck would have it, the same principle can be used to synthesize an
annotation from any map of attributes, and in particular, from an
instance of AnnotationAttributes.

The following highlight the major changes in this commit toward
achieving this goal.

- Introduced AnnotationAttributeExtractor abstraction and refactored
  SynthesizedAnnotationInvocationHandler to delegate to an
  AnnotationAttributeExtractor.

- Extracted code from SynthesizedAnnotationInvocationHandler into new
  AbstractAliasAwareAnnotationAttributeExtractor and
  DefaultAnnotationAttributeExtractor implementation classes.

- Introduced MapAnnotationAttributeExtractor for synthesizing an
  annotation that is backed by a map or AnnotationAttributes instance.

- Introduced a variant of synthesizeAnnotation() in AnnotationUtils
  that accepts a map.

- Introduced findAnnotation(*) methods in AnnotatedElementUtils that
  synthesize merged AnnotationAttributes back into an annotation of the
  target type.

The following classes have been refactored to use the new support for
synthesizing AnnotationAttributes back into an annotation.

- ApplicationListenerMethodAdapter
- TestAnnotationUtils
- AbstractTestContextBootstrapper
- ActiveProfilesUtils
- ContextLoaderUtils
- DefaultActiveProfilesResolver
- DirtiesContextTestExecutionListener
- TestPropertySourceAttributes
- TestPropertySourceUtils
- TransactionalTestExecutionListener
- MetaAnnotationUtils
- MvcUriComponentsBuilder
- RequestMappingHandlerMapping

In addition, this commit also includes changes to ensure that arrays
returned by synthesized annotations are properly cloned first.

Issue: SPR-13067
2015-05-29 01:38:51 +02:00
Sam Brannen f41de12cf6 Ensure synthesized nested annotation arrays retain correct type
Prior to this commit, when a nested array of annotations was
synthesized while adapting values within an AnnotationAttributes map,
the array was improperly replaced with an array of type Annotation[]
instead of an array of the concrete annotation type, which can lead to
unexpected run-time exceptions.

This commit fixes this bug by replacing annotations in the existing
array with synthesized versions of those annotations, thereby retaining
the original array's component type.

Issue: SPR-13077
2015-05-27 17:55:10 +02:00
Sam Brannen a2f152ce8b Support nested annotations in AnnotationAttributes
This commit introduces support in AnnotationAttributes for retrieving
nested annotations that is on par with the existing type-safe support
for retrieving nested AnnotationAttributes.

Issue: SPR-13074
2015-05-27 17:03:01 +02:00
Sam Brannen 0ac0e2ce20 Document public API in AnnotationAttributes
AnnotationAttributes has existed for several years, but none of the
"get" methods that make up its public API are documented. In many
cases, the behavior can be inferred from the name of the method, but
for some methods there are "hidden gems" and unexpected behavior
lurking behind the scenes.

This commit addresses this issue by documenting all public methods. In
addition, the hidden support for converting single elements into
single-element arrays has also been documented and tested.

Issue: SPR-13072
2015-05-27 16:15:25 +02:00
Sam Brannen 197f6594f4 Simplify annotation attribute override algorithm
Issue: SPR-11513
2015-05-24 17:59:30 +02:00
Sam Brannen c80932490f Complete documentation of synthesized annotations
Issue: SPR-11512
2015-05-24 16:42:09 +02:00
Sam Brannen b6f2d95c3e Cache computed values in SynthesizedAnnotationInvocationHandler
Issue: SPR-11512
2015-05-24 15:58:20 +02:00
Sam Brannen 8ecae8697a Cache attribute methods in AnnotationUtils
Issue: SPR-11512
2015-05-24 15:58:20 +02:00
Sam Brannen d5974a18ab Polish AnnotationUtils 2015-05-24 15:58:19 +02:00
Sam Brannen a1fc2097a1 Document SynthesizedAnnotationInvocationHandler constructor
Issue: SPR-11512
2015-05-24 15:58:07 +02:00
Sam Brannen c13f689537 Document isSynthesizable() in AnnotationUtils
Issue: SPR-11512
2015-05-24 00:13:53 +02:00
Sam Brannen 7f22f09890 PolishingPolish SynthesizedAnnotationInvocationHandler 2015-05-23 23:58:35 +02:00
Sam Brannen def7663ec4 Implement hashCode() for synthesized annotations
Issue: SPR-13066
2015-05-23 23:46:48 +02:00
Sam Brannen ae5c8285a6 Polish SynthesizedAnnotationInvocationHandler 2015-05-23 22:40:05 +02:00
Sam Brannen 7e2e9a80d0 Document getAttributeMethods() in AnnotationUtils
Issue: SPR-11512
2015-05-23 22:29:12 +02:00
Sam Brannen 7bf609f111 Implement equals() for synthesized annotations
Issue: SPR-13065
2015-05-23 22:29:12 +02:00
Sam Brannen 62d1b4b6e8 Document getAttributeAliasMap() in AnnotationUtils
This commit also introduces a cache for attribute alias metadata.

Issue: SPR-11512
2015-05-23 20:30:03 +02:00
Sam Brannen f5e096e2a0 Document @AliasFor
Issue: SPR-11512
2015-05-23 19:52:03 +02:00
Sam Brannen b9e13ea308 Align AnnotationAttributes.toString() with contract in Map 2015-05-23 18:25:50 +02:00
Sam Brannen f380689230 Don't use Java 8's Method.getParameterCount() 2015-05-23 18:18:03 +02:00
Sam Brannen 1e50d8d5c2 Implement toString() for synthesized annotations
Issue: SPR-13064
2015-05-23 18:09:39 +02:00
Sam Brannen ab92f4ed3a Document SynthesizedAnnotation support
Issue: SPR-11512
2015-05-23 01:01:39 +02:00
Sam Brannen bd787769be Introduce "synthesizable" cache in AnnotationUtils
Issue: SPR-11512
2015-05-22 21:40:36 +02:00
Sam Brannen 2e4dabb349 Polishing 2015-05-22 21:37:50 +02:00
Sam Brannen 73170224c9 Polish annotation utility tests 2015-05-22 17:46:34 +02:00
Sam Brannen e7ea92561d Verify that SynthesizedAnnotation must be public
This commit introduces a test that will fail if SynthesizedAnnotation is
not public as is required by the contract for getProxyClass() in
java.lang.reflect.Proxy.

Issue: SPR-13057
2015-05-22 16:42:26 +02:00
Sam Brannen ca09b1ff20 Introduce putIfAbsent() in AnnotationAttributes
Issue: SPR-13060
2015-05-22 15:52:49 +02:00
Sebastien Deleuze 5255e7ae21 Support CompletableFuture in @MessageMapping handler methods
Issue: SPR-12207
2015-05-22 11:30:56 +02:00
Juergen Hoeller 792b7b9d11 ByteBufferConverter explicitly declares applicability to byte[]
Includes an optimization for simple ByteBuffer duplication.

Issue: SPR-13056
2015-05-22 11:19:17 +02:00
Stephane Nicoll 27c435c4ea Polish 2015-05-22 10:28:40 +02:00
Stephane Nicoll 39b2fbbccf Make SynthetizedAnnotation public
Enable public visibility on SynthetizedAnnotation to allow annotation
outside its package to be proxied properly. This commit is pending a
unit test that actually reproduces the problem.

Issue: SPR-13057
2015-05-22 10:21:23 +02:00
Sam Brannen ca66e076d1 Support annotation attribute aliases and overrides via @AliasFor
This commit introduces first-class support for aliases for annotation
attributes. Specifically, this commit introduces a new @AliasFor
annotation that can be used to declare a pair of aliased attributes
within a single annotation or an alias from an attribute in a custom
composed annotation to an attribute in a meta-annotation.

To support @AliasFor within annotation instances, AnnotationUtils has
been overhauled to "synthesize" any annotations returned by "get" and
"find" searches. A SynthesizedAnnotation is an annotation that is
wrapped in a JDK dynamic proxy which provides run-time support for
@AliasFor semantics. SynthesizedAnnotationInvocationHandler is the
actual handler behind the proxy.

In addition, the contract for @AliasFor is fully validated, and an
AnnotationConfigurationException is thrown in case invalid
configuration is detected.

For example, @ContextConfiguration from the spring-test module is now
declared as follows:

    public @interface ContextConfiguration {

        @AliasFor(attribute = "locations")
        String[] value() default {};

        @AliasFor(attribute = "value")
        String[] locations() default {};

        // ...
    }

The following annotations and their related support classes have been
modified to use @AliasFor.

- @ManagedResource
- @ContextConfiguration
- @ActiveProfiles
- @TestExecutionListeners
- @TestPropertySource
- @Sql
- @ControllerAdvice
- @RequestMapping

Similarly, support for AnnotationAttributes has been reworked to
support @AliasFor as well. This allows for fine-grained control over
exactly which attributes are overridden within an annotation hierarchy.
In fact, it is now possible to declare an alias for the 'value'
attribute of a meta-annotation.

For example, given the revised declaration of @ContextConfiguration
above, one can now develop a composed annotation with a custom
attribute override as follows.

    @ContextConfiguration
    public @interface MyTestConfig {

        @AliasFor(
           annotation = ContextConfiguration.class,
           attribute = "locations"
        )
        String[] xmlFiles();

        // ...
    }

Consequently, the following are functionally equivalent.

- @MyTestConfig(xmlFiles = "test.xml")
- @ContextConfiguration("test.xml")
- @ContextConfiguration(locations = "test.xml").

Issue: SPR-11512, SPR-11513
2015-05-22 00:01:07 +02:00
Juergen Hoeller b4095c3e1d Class identity comparisons wherever possible
Issue: SPR-12926
2015-05-20 14:34:16 +02:00
Stephane Nicoll cf391f5ce1 polish
Remove unused imports
2015-05-19 08:49:01 +02:00
Juergen Hoeller 008c9a3b45 Test for ByteBuffer-to-ByteBuffer conversion (fresh copy)
ByteBufferConverter also defensively returns the rewind result now.

Issue: SPR-13031
2015-05-18 16:17:11 +02:00
Juergen Hoeller 1e7d954fcb MethodMetadata exposes method return type
Issue: SPR-13024
2015-05-18 16:16:58 +02:00
Stephane Nicoll 0612bc7bc5 Harmonize default converters
Provide Converter implementations for Charset, Currency and TimeZone as
related PropertyEditors are available for those.

Issue: SPR-13020
2015-05-15 15:23:57 +02:00
Sam Brannen 477d4c5126 Document "present" terminology in AnnotationUtils
Prior to this commit, the documentation in AnnotationUtils was
inconsistent, and at times even misleading, with regard to finding
annotations that are "present" or "directly present" on annotated
elements.

This commit defines the terminology used within AnnotationUtils and
introduces the explicit notion of "meta-present" to denote that
annotations are present within annotation hierarchies above annotated
elements.

Issue: SPR-13030
2015-05-14 21:25:54 +02:00
Sam Brannen ebed52cc22 Favor local, composed annotations in AnnotatedElementUtils
This commit updates the "get semantics" search algorithm used in
`AnnotatedElementUtils` so that locally declared 'composed annotations'
are favored over inherited annotations.

Specifically, the internal `searchWithGetSemantics()` method now
searches locally declared annotations before searching inherited
annotations.

All TODOs in `AnnotatedElementUtilsTests` have been completed, and all
ignored tests have been reinstated.

Issue: SPR-11598
2015-05-13 16:06:36 +02:00
Juergen Hoeller 0711d6d0df Polishing 2015-05-13 15:04:26 +02:00
Juergen Hoeller e83d495cbb SimpleAliasRegistry prevents NPE for alias resolved to null
Issue: SPR-13016
2015-05-12 22:04:44 +02:00
Sam Brannen 52153bd454 Document search scope in Ann*[Element]Utils
This commit improves the documentation for AnnotationUtils and
AnnotatedElementUtils by explaining that the scope of most annotation
searches is limited to finding the first such annotation, resulting in
additional such annotations being silently ignored.

Issue: SPR-13015
2015-05-12 21:06:27 +02:00
Juergen Hoeller 00147379f9 Polishing
(cherry picked from commit 9e925aa)
2015-05-11 22:22:23 +02:00
Juergen Hoeller 64a01d64c5 Polishing 2015-05-11 14:42:45 +02:00
Sam Brannen fcf75c90b1 Fix broken AnnotationAttributesTests
Issue: SPR-13007
2015-05-10 13:10:04 +02:00
Philippe Marschall 994d86992c Avoid eager formatting in pre-condition checks
In general, the Spring Framework aims to construct error message
strings only if an actual error has occurred. This seems to be the
common pattern in the codebase and saves both CPU and memory. However,
there are some places where eager error message formatting occurs
unnecessarily.

This commit addresses this issue in the following classes:
AdviceModeImportSelector, AnnotationAttributes, and
ReadOnlySystemAttributesMap.

The change in ReadOnlySystemAttributesMap also avoids a potential
NullPointerException.

Issue: SPR-13007
2015-05-10 12:36:01 +02:00
Juergen Hoeller 1e046435ab AntPathMatcher actually throws IllegalArgumentException if patterns cannot be combined
Issue: SPR-12998
2015-05-09 15:29:33 +02:00
Sam Brannen 04d6afe54d Support arbitrary levels of meta-annotations in TypeDescriptor
Prior to this commit, the `getAnnotation()` method in `TypeDescriptor`
only supported a single level of meta-annotations. In other words, the
annotation hierarchy would not be exhaustively searched.

This commit provides support for arbitrary levels of meta-annotations
in `TypeDescriptor` by delegating to `AnnotationUtils.findAnnotation()`
within `TypeDescriptor.getAnnotation()`.

Issue: SPR-12793
2015-05-08 16:05:18 +02:00
Sam Brannen 5f03c97295 Polish Javadoc for MethodParameter 2015-05-08 16:03:55 +02:00
Sam Brannen 638926be4f Use JUnit ExpectedException rule in AntPathMatcherTests 2015-05-08 14:37:15 +02:00
Sam Brannen c7cdbe126d Introduce failing test case in AntPathMatcherTests
Issue: SPR-12998
2015-05-08 14:31:21 +02:00
Arjen Poutsma 76beb36e4b Remove duplicate separators when combining paths
Prior to this commit, AntPathMatcher would not correctly combine a path
that ends with a separator with a path that starts with a separator.
For example, `/foo/` + `/bar` combined into `/foo//bar`.

Specifically, this commit:

 - Removes the duplicated separator in combined paths

 - Improves RequestMappingInfo's toString() representation

 - Fixes Javadoc formatting in AntPathMatcher

 - Polishes AntPathMatcherTests

 - Polishes Javadoc in AbstractRequestCondition

Issue: SPR-12975
2015-05-08 13:49:34 +02:00
Juergen Hoeller dbd82d128d Polishing 2015-05-07 20:18:17 +02:00
Juergen Hoeller 783cb2c438 StringUtils.commaDelimitedListToSet/removeDuplicateStrings preserves original order
Issue: SPR-12003
2015-05-07 16:02:48 +02:00
Juergen Hoeller b90085500d Revert introduction of isNotEmpty aliases
Issue: SPR-12009
2015-05-07 15:54:55 +02:00
Juergen Hoeller db80378dbe Avoid infinite loop in PatternMatchUtils
Issue: SPR-12971
2015-05-07 15:41:40 +02:00
Juergen Hoeller 2c043ec9d7 Fix for ASM issue 317555
Issue: SPR-12957
2015-05-07 15:41:24 +02:00
Sam Brannen 401bcd4a8a Polish Javadoc for AnnotatedElementUtils 2015-05-07 14:01:02 +02:00
Sam Brannen 7a690df925 Remove trailing whitespace from Java source code 2015-05-06 20:08:42 +02:00
Sam Brannen 6db8f24aaf Polish AnnotatedElementUtils[Tests]
Issue: SPR-11514
2015-05-06 18:48:26 +02:00
Sam Brannen 270308dfd9 Document "get vs. find" semantics in AnnotatedElementUtils
Issue: SPR-11514
2015-05-06 18:29:26 +02:00
Sam Brannen 5c0f98aea4 Document & test AnnotatedElementUtils.getAllAnnotationAttributes
Issue: SPR-11514
2015-05-06 15:55:37 +02:00
Sam Brannen 9eb3518583 Introduce tests for AnnotatedElementUtils.isAnnotated()
Issue: SPR-11514
2015-05-06 14:07:07 +02:00
Sam Brannen e2158d75de Improve documentation of AnnotatedElementUtils.Processor
Issue: SPR-11514
2015-05-06 14:07:07 +02:00
Sam Brannen 5d67219a4e Eliminate inspection of annotations on core Java annotations
This commit picks up where SPR-11483 left off, with the goal of
eliminating all unnecessary inspection of core JDK annotations in
Spring's annotation search algorithms in AnnotatedElementUtils and
AnnotationMetadataReadingVisitor.

Issue: SPR-12989
2015-05-06 00:17:12 +02:00
Sam Brannen ba84458c65 Overhaul AnnotatedElementUtils
- Methods which search for a specific annotation now properly ensure
   that the sought annotation was actually found.

 - Both the "get" and the "find" search algorithms no longer needlessly
   traverse meta-annotation hierarchies twice.

 - Both the "get" and the "find" search algorithms now properly
   increment the metaDepth when recursively searching within the
   meta-annotation hierarchy.

 - Redesigned getMetaAnnotationTypes() so that it doesn't needlessly
   search irrelevant annotations.

 - Documented and tested hasMetaAnnotationTypes().

 - Documented isAnnotated().

Issue: SPR-11514
2015-05-05 23:35:00 +02:00
Sam Brannen efce40c391 Polish internal Javadoc for AnnotatedElementUtils
Issue: SPR-11514
2015-05-04 14:15:16 +02:00
Sam Brannen bb1886c5a8 Enable AbstractStaxHandlerTestCase to run w/o Internet connection 2015-05-02 23:23:51 +02:00
Sam Brannen e56363737b Make findAnnotationAttributes power search private 2015-05-02 10:38:31 +02:00
Sam Brannen 7ef9ac7a4d Document & test status quo for getMetaAnnotationTypes()
This commit documents the status quo for the getMetaAnnotationTypes()
method in AnnotatedElementUtils and adds appropriate regression tests to
AnnotatedElementUtilsTests.

In addition, this commit also introduces a SimpleAnnotationProcessor
base class in AnnotatedElementUtils.

Issue: SPR-11514
2015-04-26 21:13:19 +02:00
Sam Brannen 99cc7d56ff Document return values in AnnotatedElementUtils
This commit documents return values throughout AnnotatedElementUtils and
improves the documentation for the internal Processor API.

Issue: SPR-11514
2015-04-26 03:00:39 +02:00
Sam Brannen 91e46cf2ad Update TODOs in AnnotatedElementUtils[Tests]
Issue: SPR-12738
2015-04-24 23:05:29 +02:00
Sam Brannen 25187eeb0d Document AnnotatedElementUtils & assert preconditions
This commit consistently documents the 'element' and 'annotationType'
method arguments throughout AnnotatedElementUtils.

In addition, this commit introduces assertions against preconditions
for all 'element' and 'annotationType' method arguments.

Issue: SPR-11514
2015-04-24 22:36:36 +02:00