Compare commits

...

1444 Commits

Author SHA1 Message Date
Spring Buildmaster 8242d02f9d Release version 4.3.8.RELEASE 2017-04-18 14:46:11 +00:00
Juergen Hoeller 8b9e9202f1 Upgrade to Hibernate ORM 5.2.10 2017-04-17 19:42:10 +02:00
Juergen Hoeller afe11e7919 Revised logging documentation for the 4.3.x line 2017-04-17 19:41:59 +02:00
Juergen Hoeller 665e6cf6ca Refined log message for interface-implementing method
Issue: SPR-15436
2017-04-17 19:29:01 +02:00
Juergen Hoeller fd1d8aeeb4 Polishing
(cherry picked from commit 91df065)
2017-04-17 15:39:06 +02:00
Juergen Hoeller 9b2f9e655e CglibAopProxy logs explicit warning for interface-implementing method marked as final
Issue: SPR-15436
(cherry picked from commit 0d0b879)
2017-04-17 15:38:59 +02:00
Juergen Hoeller 6c370ed28d Recommendation for consistent @Profile declarations on overloaded @Bean methods
Issue: SPR-15266
(cherry picked from commit 5d3249f)
2017-04-17 15:38:53 +02:00
Juergen Hoeller a2b356162e Explicitly replace target ApplicationListener with singleton proxy, if any (avoiding double registration/invocation)
Issue: SPR-15452
(cherry picked from commit 9abf249)
2017-04-17 15:38:46 +02:00
Stephane Nicoll 71f7fdd632 Polish "Improve unless condition in caching doc"
Closes gh-1387
2017-04-13 17:51:20 +02:00
Michael J. Simons c35ddf905a Improve unless condition in caching doc
See gh-1387
2017-04-13 17:51:12 +02:00
Michael J. Simons d866715556 Polish condition in caching examples
Closes gh-1386
2017-04-13 17:51:02 +02:00
Juergen Hoeller a9a1f783c5 Polishing 2017-04-13 15:59:15 +02:00
Juergen Hoeller 65d52a4b97 Correctly process Postgresql ?| and ?& operator
Issue: SPR-15382
2017-04-13 15:59:07 +02:00
Juergen Hoeller 3c8fc46568 Backported JSON converter alignment (supports method, exception messages)
Includes deprecation of getTypeToken method in GsonHttpMessageConverter.

Issue: SPR-15381
2017-04-13 15:58:53 +02:00
Juergen Hoeller 421fabb2c4 Configurable locale/timezone attribute name for SessionLocaleResolver
Issue: SPR-15450
(cherry picked from commit cec36fe)
2017-04-13 15:56:07 +02:00
Juergen Hoeller 811d523211 FreeMarkerConfigurationFactory falls back to SpringTemplateLoader on any exception
Issue: SPR-15445
(cherry picked from commit a55a0f2)
2017-04-13 15:56:01 +02:00
Juergen Hoeller 40232f4e22 ASM annotation visitor defensively accesses enum constants
Issue: SPR-15442
(cherry picked from commit 4838f06)
2017-04-13 15:55:53 +02:00
Juergen Hoeller 80fa3ac907 ShadowingClassLoader can be constructed without default excludes
Issue: SPR-15439
(cherry picked from commit 1735ba2)
2017-04-13 15:55:44 +02:00
Juergen Hoeller 54180f90e2 UnknownHostException as resource-not-found for properties files
Plus first-class declaration of FileNotFoundException in Resource javadoc.

Issue: SPR-15433
(cherry picked from commit c4e0d6c)
2017-04-13 15:55:29 +02:00
Juergen Hoeller 865953f145 Optimize StringUtils.replace/deleteAny for common no-op case
Issue: SPR-15430
(cherry picked from commit ce4eff3)
2017-04-13 15:55:11 +02:00
Juergen Hoeller 93fac8882f Undeprecate TypeVariableMap methods on GenericTypeResolver
Issue: SPR-15429
(cherry picked from commit 7fbc20e)
2017-04-13 15:55:02 +02:00
Juergen Hoeller a3d199f4dd AcceptHeaderLocaleResolver returns default locale in case of no supported locale found
Issue: SPR-15426
(cherry picked from commit ea98ee8)
2017-04-13 15:54:46 +02:00
Juergen Hoeller 597fe0720f HandlerMethod evaluates ResponseStatus annotation for early caching
Issue: SPR-15227
(cherry picked from commit 5986f88)
2017-04-13 15:54:35 +02:00
Juergen Hoeller 8321f01bf8 SettableTask.checkCompletingThread() only resets marker after match
Issue: SPR-15409
(cherry picked from commit 8cb24e0)
2017-04-13 15:54:22 +02:00
Juergen Hoeller 7e736b69b7 UrlResource applies StringUtils.getFilename against cleaned URL path
Issue: SPR-15411
(cherry picked from commit 702e01a)
2017-04-13 15:54:03 +02:00
Juergen Hoeller 8b054840fc Minimize reflective interaction with annotation instances during retrieval
Issue: SPR-15387
(cherry picked from commit 3037277)
2017-04-13 15:53:46 +02:00
Juergen Hoeller 7f3d0b3e6e Test for BeanPropertySqlParameterSource with collection
Issue: SPR-15390
(cherry picked from commit af6f688)
2017-04-13 15:53:39 +02:00
Rossen Stoyanchev 546d7ddd07 Update @ControllerAdvice Javadoc
Issue: SPR-15432
2017-04-12 17:53:42 -04:00
Rob Winch 95099fd709 Fix ForwardedHeaderFilter preserves semicolon content
Previously a requestURI that contained ';' would have the value incorrectly stripped out when using
ForwardedHeaderFilter.

This commit ensures that the ';' is preserved when using ForwardedHeaderFilter.

Issue: SPR-15428
2017-04-10 09:15:15 -05:00
Rob Winch f65e1edd58 Polish
Group all contextPath tests together
2017-04-10 09:15:07 -05:00
Rob Winch 0a9f98f0df Add test to ensure ForwardedHeaderFilter contextPath preserves encoding
Add a test to verify that the ForwardedHeaderFilter contextPath override preserves URL encoding
as it should.

Issue SPR-15422
2017-04-10 09:13:41 -05:00
Rob Winch 46cf4f9ba1 ForwardedHeaderFilter requestURI preserve encoding
Previously ForwardedHeaderFilter would override the requestURI with a URL decoded value. This would cause
problems when using a URL encoded requestURI since downstream Filters would not see the URL encoded
value as they should.

This commit resolves this issue by ensuring that the requestURI is properly encoded.

Issues SPR-15422
2017-04-10 09:11:08 -05:00
Kirill Gavrilov 2b930e3858 Fix typo
Closes gh-1383
2017-04-10 09:54:44 +02:00
Stephane Nicoll bde2ddbeb1 Update copyright header
Closes gh-1382
2017-04-09 09:48:47 +02:00
John S. Ryan 4eb929c105 Fix typo in AfterReturningAdviceInterceptor JavaDoc
See gh-1382
2017-04-09 09:48:38 +02:00
Bryan Kelly d0d7a88233 Fix ForwardedHeaderFilter getRequestURL()
Previously ForwardedHeaderFilter would return the same StringBuffer for every invocation. This
meant that users that modified the StringBuffer changed the state of the HttpServletRequest.

This commit ensures that a new StringBuffer is always returned for ForwardedHeaderFilter.

Issue: SPR-15423
2017-04-07 15:45:23 -05:00
Rossen Stoyanchev f7548a87ed Deprecations related to reactive type support in 5.0
Issue: SPR-15365
2017-04-03 09:26:46 -04:00
QBNemo e0fe7cdc44 Fix typo
Closes gh-1354
2017-03-27 10:12:53 +02:00
Connor Lin 8289bf0aff Remove a redundant word
Closes gh-1361
2017-03-27 10:10:14 +02:00
Grant Hutchins 79d747410d Fix typo
Closes gh-1364
2017-03-27 10:05:49 +02:00
Brian Clozel 70bca99da8 VersionResourceResolver should delegate to the chain
Prior to this commit, the `VersionResourceResolver` implementation of
`resolveUrlPathInternal` would delegate to the resolver chain but would
never use the give result if the current request didn't match a
configured version strategy pattern.

This is a problem if the resolver supposed to resolve the resource path
is configured after a `VersionResourceResolver` in the resolver chain;
this means that other resolver never gets to participate in the result
of the chain.

Issue: SPR-15372
(cherry picked from commit fdd5031)
2017-03-24 14:27:29 +01:00
Juergen Hoeller 83617f382c Latest dependency updates (Hibernate ORM 5.2.9, Hibernate Validator 5.2.5, Undertow 1.3.28, Jetty 9.4.3, Joda-Time 2.9.9) 2017-03-24 13:41:57 +01:00
Juergen Hoeller 21ac764e5c Polishing 2017-03-24 13:41:34 +01:00
Juergen Hoeller c4fda0e811 Up-to-date guidelines for serialization-based endpoints
Issue: SPR-15317
(cherry picked from commit 2236262)
2017-03-24 13:41:19 +01:00
Juergen Hoeller 66670cfd56 Clarification: Spring AOP pointcuts may match non-public methods
Issue: SPR-15354
(cherry picked from commit b90d3d0)
2017-03-24 13:41:08 +01:00
Juergen Hoeller c31bfe65aa Drop outdated DeferredQueryInvocationHandler.finalize() implementation
Issue: SPR-15363
(cherry picked from commit b2a6a57)
2017-03-24 13:40:58 +01:00
Juergen Hoeller 22ddb35258 HeaderValueHolder.toString() exposes underlying list of header values
Issue: SPR-15375
(cherry picked from commit 15bff8f)
2017-03-24 13:40:43 +01:00
Juergen Hoeller d0177b0f55 Revised supportedMethods null handling in HttpRequestMethodNotSupportedException
Issue: SPR-15377
(cherry picked from commit 5ea4abd)
2017-03-24 13:40:35 +01:00
Juergen Hoeller 2233ec04ff StandardMultipartFile.transferTo falls back to manual copy
Issue: SPR-15257
(cherry picked from commit b73153c)
2017-03-24 13:40:29 +01:00
Juergen Hoeller e9ff3bb4e3 DefaultResponseErrorHandler delegate methods declared as protected
Also revises copyToByteArray/String in FileCopyUtils/StreamUtils for lenient null handling.

Issue: SPR-15329
(cherry picked from commit ab7db41)
2017-03-24 13:40:19 +01:00
Juergen Hoeller 57c8c759ae Avoid pattern misdetection in Tomcat "war:" URL separator
Issue: SPR-15332
(cherry picked from commit 012c56a)
2017-03-24 13:39:42 +01:00
Juergen Hoeller cfd9b3461f Process NULLABLE column as integer instead of boolean
Issue: SPR-15333
(cherry picked from commit 79ea779)
2017-03-24 13:39:10 +01:00
Rossen Stoyanchev d3324c8d4f Trap exception from SockJS HeartbeatTask
Issue: SPR-15307
2017-03-16 18:02:44 -04:00
Rossen Stoyanchev ffe9bae138 Update Javadoc on exception resolvers in MVC config
Issue: SPR-15324
2017-03-07 20:51:22 -05:00
Juergen Hoeller 020e51cb96 Polishing
(cherry picked from commit 94a7624)
2017-03-07 16:04:46 +01:00
Juergen Hoeller a78066830b Retrieve newly created attribute from underlying request (marking it for update)
Issue: SPR-15300
(cherry picked from commit f30c498)
2017-03-07 16:04:39 +01:00
Juergen Hoeller 77c771e874 Lookup methods work on configuration classes as well
Issue: SPR-15316
(cherry picked from commit fc2e635)
2017-03-07 16:04:16 +01:00
Juergen Hoeller 227ac3faa4 Explicit notes on transaction phase processing
Issue: SPR-15323
(cherry picked from commit 8b74150)
2017-03-07 16:04:09 +01:00
Juergen Hoeller 98dbc17591 Polishing 2017-03-07 10:33:48 +01:00
Juergen Hoeller e58b17a3a1 Adapt to JRuby 9.1.7+ RubyException.getMessage() method at runtime
Issue: SPR-15322
2017-03-07 10:33:34 +01:00
Juergen Hoeller 9de97614a0 Adapt to HtmlUnit 2.25 getCharset() return type at runtime
Issue: SPR-15319
2017-03-07 10:33:26 +01:00
Juergen Hoeller 015e00b5dd Upgrade to CGLIB 3.2.5
Includes Jetty 9.4.2, Netty 4.1.8, Commons I/O 1.4 as well.

Issue: SPR-15147
(cherry picked from commit 0d7b25f)
2017-03-07 10:23:57 +01:00
Stephane Nicoll 0bc59225d8 Polish contribution
Closes gh-1349
2017-03-05 09:35:09 +01:00
Aviskar Basnet d8acc27afb Polish doc
See gh-1349
2017-03-05 09:34:58 +01:00
Stephane Nicoll a1e4afe338 Update copyright header
Closes gh-1343
2017-03-03 09:35:29 +01:00
nkjackzhang 3b9faee335 Remove unecessary "<<"
See gh-1343
2017-03-03 09:35:16 +01:00
Spring Buildmaster 0048ff84ea Next Development Version 2017-03-01 08:53:20 +00:00
Juergen Hoeller c3f131325d Upgrade to Groovy 2.4.9 2017-02-28 14:01:09 +01:00
Juergen Hoeller b945e0f202 Polishing
(cherry picked from commit 6d6cf01)
2017-02-28 14:00:59 +01:00
Juergen Hoeller ce3cf3251d Tests for annotation lookups in interfaces (currently ignored for CGLIB proxies)
Issue: SPR-15271
Issue: SPR-14949
Issue: SPR-14322
(cherry picked from commit d003f66)
2017-02-28 14:00:39 +01:00
Juergen Hoeller d69fb06852 Skip transaction/caching metadata retrieval for java.lang.Object methods
Also retrieves CacheConfig as merged annotation now, aligned with other caching annotations.

Issue: SPR-15296
(cherry picked from commit d4a1b59)
2017-02-28 14:00:33 +01:00
Rossen Stoyanchev e9de3bb85b Fix wrong access modifier in MockMvc standalone setup
Issue: SPR-15248
2017-02-23 16:12:14 -05:00
Juergen Hoeller e6a51e3d29 Upgrade to Jackson 2.8.7 2017-02-22 16:32:51 +01:00
Juergen Hoeller c734c3a3fe Polishing 2017-02-22 16:32:21 +01:00
Juergen Hoeller a48a956c0c ConfigurationClassEnhancer explicitly handles non-interceptable FactoryBeans
Issue: SPR-15275
(cherry picked from commit 7fb0ad3)
2017-02-22 16:31:48 +01:00
Juergen Hoeller e5010a823b Test for expected behavior of getAllMergedAnnotations vs findAllMergedAnnotations
Issue: SPR-15271
(cherry picked from commit 6108ab1)
2017-02-22 16:31:40 +01:00
stonio 1db42081e5 Use String#isEmpty()
Closes gh-1335
(cherry picked from commit 7d062df)
2017-02-22 16:31:35 +01:00
Juergen Hoeller 34a0857628 Polishing
(cherry picked from commit d2cc97a)
2017-02-21 23:03:16 +01:00
Rossen Stoyanchev ba0484fcac Add equals/hashcode for STOMP Subscription
Issue: SPR-15229
2017-02-21 15:10:27 -05:00
Juergen Hoeller f1133a8e56 Upgrade to Hibernate ORM 5.2.8 2017-02-20 23:15:41 +01:00
Juergen Hoeller 35e37f6b60 Polishing 2017-02-20 23:15:05 +01:00
Juergen Hoeller f117b804a8 ServletRequestMethodArgumentResolver passes null references through (again)
Issue: SPR-15214
(cherry picked from commit fc11321)
2017-02-20 23:14:54 +01:00
Stephane Nicoll 278199d467 Revert "Improve allowNullValue handling when a null value is provided"
This reverts commit fd568f3e96.
2017-02-20 16:36:23 +01:00
Stephane Nicoll fd568f3e96 Improve allowNullValue handling when a null value is provided
This commit improves `AbstractValueAdaptingCache` to throw a dedicated
exception if `allowNullValues` is `false` and a `null` value is provided
anyway. This avoid a lower-level exception from the cache library that
will miss some context.

Issue: SPR-15173
2017-02-20 16:24:34 +01:00
Brian Clozel 45b27a85f4 Ignore HEAD requests in ShallowEtagHeaderFilter
Prior to this commit, the `ShallowEtagHeaderFilter` could participate in
the response and set its ETag/Content-Length headers, even for HEAD
requests. Since the response body is empty, the filter implementation
would set a `"Content-Length: 0"`.

The RFC states that responses to HEAD requests should exhibit identical
response headers to GET (with the possible exception of payload related
headers such as Content-Length.

With this commit, `ShallowEtagHeaderFilter` now ignores HEAD requests
since the proper values may be set already for payload related headers
by the handler. The filter has no way to generate a proper ETag value
nor calculate the content length without the actual body.

Issue: SPR-15261
(cherry picked from commit b732251)
2017-02-20 12:23:06 +01:00
Juergen Hoeller 0f71f58616 Polishing 2017-02-18 00:52:12 +01:00
Juergen Hoeller 9834c42b5c MutableMessageHeaders serializes itself as regular MessageHeaders
Issue: SPR-15262
(cherry picked from commit 74bdcd8)
2017-02-18 00:51:02 +01:00
Andy Clement 7879bdfc1d Fix compilation of SpEL elvis/ternary expressions
Without this fix the compiled version of elvis
actual behaved differently to the interpreted version
if the value being queried was an empty string. This
is now fixed. It also now correctly handles the
query value being a primitive and addresses the
findings of SPR-15192 where some type inferencing
logic was trying to be too clever, that code has
been deleted.

Issue: SPR-15192
(cherry picked from commit d41d28f)
2017-02-18 00:50:30 +01:00
Juergen Hoeller dfa8a7c358 Polishing 2017-02-16 15:57:52 +01:00
Juergen Hoeller 427fd9b19a OracleTableMetaDataProvider tries Connection.unwrap as well
Issue: SPR-14670
2017-02-16 15:57:39 +01:00
Juergen Hoeller 6417ed47ab Latest dependency updates (Apache HttpAsyncClient 4.1.3, BeanShell 2.0b5) 2017-02-16 14:20:54 +01:00
Juergen Hoeller b0ef80c3ff Polishing 2017-02-16 14:20:40 +01:00
Juergen Hoeller 7ed4884eaa Recent dialects for MySQL and SQL Server (as far as possible in 4.3.x)
Issue: SPR-15255
2017-02-16 14:20:33 +01:00
Juergen Hoeller c3cc42d4d3 Avoid double encoding of URIs
Issue: SPR-15254
2017-02-16 14:20:15 +01:00
Juergen Hoeller 860e2bcc2d Revised isInstanceOf/isAssignable message concatenation
Issue: SPR-15196
(cherry picked from commit 22322fd)
2017-02-16 14:20:07 +01:00
Juergen Hoeller 06231721c3 Consistently support CompletionStage next to CompletableFuture
Issue: SPR-15258
(cherry picked from commit 50d93d3)
2017-02-16 14:20:02 +01:00
Juergen Hoeller 4d2360e5b5 Defensively ignore multipart parsing failure in case of error dispatch
Issue: SPR-15231
(cherry picked from commit d44325e)
2017-02-16 14:19:57 +01:00
Stephane Nicoll 4f52174674 Update copyright header
Closes gh-1327
2017-02-14 10:41:03 +01:00
hengyunabc 7d7c5c9d9c Fix typo
See gh-1327
2017-02-14 10:40:51 +01:00
Brian Clozel 08b9e7b83e Avoid duplicate Content-Length headers in Netty client
This commit checks that a "Content-Length" request header isn't already
present before adding one in `Netty4ClientHttpRequestFactory`.
`HttpMessageConverter` implementations can write that request header so
the Netty request factory should only write that value when the header
is missing.

If that header is not written (and since we're not dealing with
the HTTP exchange in a chunked-based fashion), the HTTP client might not
send the request body at all.

Issue: SPR-15241
2017-02-13 21:19:51 +01:00
Juergen Hoeller e24c530705 Upgrade to Undertow 1.3.27 2017-02-10 11:48:18 +01:00
Juergen Hoeller 5017c05c23 Polishing
(cherry picked from commit e9019cd)
2017-02-10 11:47:28 +01:00
Juergen Hoeller 6e93834e27 Correct explanation of example patterns
Issue: SPR-15240
(cherry picked from commit e1bb697)
2017-02-10 11:47:10 +01:00
Juergen Hoeller 5f90a7eee9 Delegate to common ClassUtils.getQualifiedName
Issue: SPR-15237
(cherry picked from commit 81aca78)
2017-02-10 11:47:00 +01:00
Juergen Hoeller eff285eb3b MockHttpServletRequest exposes "HTTP/1.1" as default protocol
Issue: SPR-15232
(cherry picked from commit ed85337)
2017-02-10 11:46:42 +01:00
Juergen Hoeller da7d79b3a1 Test for ObjectFactory injection at constructor level
Issue: SPR-15222
(cherry picked from commit 65d8d69)
2017-02-10 11:46:32 +01:00
Juergen Hoeller d6216fb74a Consistent logging in ignoreResourceNotFound scenarios
Issue: SPR-15218
(cherry picked from commit 448ea4c)
2017-02-10 11:46:24 +01:00
Juergen Hoeller 941f3e7166 Clear synchronization before triggering afterCompletion callbacks
Issue: SPR-15194
Issue: SPR-11590
(cherry picked from commit b630c9b)
2017-02-10 11:46:13 +01:00
Stephane Nicoll e80c251c7a Update copyright header 2017-02-09 16:07:14 +01:00
Masayasu Yamamoto 56abc4a429 Fix Javadoc in ContentResultMatchers
Closes gh-1322
2017-02-09 16:07:05 +01:00
Stephane Nicoll dde9e27630 Polish 2017-02-06 15:31:39 +01:00
Stephane Nicoll 15b174a522 Polish contribution
Closes gh-1292
Issue: SPR-15188
2017-02-06 15:31:31 +01:00
David Brimley 1fcb2608fb Honour ErrorHandler if Cache.put fails
This commit makes sure that the `ErrorHandler` is invoked if the cache
fails to put an element (be it in the main cache or the exception cache).

See gh-1292
Issue: SPR-15188
2017-02-06 15:31:18 +01:00
Juergen Hoeller c15d687bf0 Polishing
(cherry picked from commit acf511a)
2017-02-02 21:20:27 +01:00
Juergen Hoeller e038631a6d Support for read-only transactions through explicit SET TRANSACTION statement
Issue: SPR-15210
(cherry picked from commit 02195f5)
2017-02-02 21:20:17 +01:00
Juergen Hoeller d5daa8e3a7 Skip default Content-Length if Transfer-Encoding header has been set
Issue: SPR-15212
(cherry picked from commit 9b3131f)
2017-02-02 21:19:53 +01:00
Juergen Hoeller 6014ca9140 ServletRequestMethodArgumentResolver validates argument type match
Issue: SPR-15214
(cherry picked from commit e44533f)
2017-02-02 21:19:45 +01:00
Juergen Hoeller d4010573af MockHttpServletRequest returns empty BufferedReader in case of no content
Issue: SPR-15215
(cherry picked from commit 0da964f)
2017-02-02 21:16:44 +01:00
Juergen Hoeller e3cd5c8ef0 SettableListenableFuture centralizes state in ListenableFutureTask subclass
Issue: SPR-15216
(cherry picked from commit c9b99da)
2017-02-02 21:16:36 +01:00
Juergen Hoeller dec1c93b24 SettableListenableFuture consistently tracks cancellation state
Issue: SPR-15202
(cherry picked from commit 9666fcc)
2017-01-31 16:11:23 +01:00
Juergen Hoeller 3ef6697536 Refined assertion messages
Issue: SPR-15196
(cherry picked from commit 9b26fcd)
2017-01-31 16:07:09 +01:00
Juergen Hoeller 8207c53b9a Polishing 2017-01-31 11:36:52 +01:00
Juergen Hoeller e3be94c961 Add headers in InterceptingClientHttpRequest
This commit *adds* the "intercepted" headers to the ClientHttpRequest,
as opposed to replacing them, which is what happened before this commit.

Issue: SPR-15166
2017-01-31 11:32:21 +01:00
Juergen Hoeller b40f016de2 Latest dependency updates (OkHttp 3.6, Apache HttpClient 4.5.3) 2017-01-31 10:29:21 +01:00
Juergen Hoeller 28849e0987 Revisit Assert to avoid single-arg assert methods (with refined messages)
Issue: SPR-15196
(cherry picked from commit 1b2dc36)
2017-01-31 10:28:46 +01:00
Spring Buildmaster b386be1529 Next Development Version 2017-01-25 13:34:40 +00:00
Juergen Hoeller a98a61852f HandlerMethod pre-resolves parameter types at construction time
Issue: SPR-15186
(cherry picked from commit 8038fb9)
2017-01-25 11:12:27 +01:00
Juergen Hoeller 3304efd64d Consistent type variable resolution for arrays/collections (in particular at field level)
Deprecating GenericCollectionTypeResolver in favor of direct ResolvableType usage.

Issue: SPR-15160
(cherry picked from commit 5e946c2)
2017-01-24 19:31:41 +01:00
Juergen Hoeller b97e7d53bc Revised CookieLocaleResolver parse exception handling
Issue: SPR-15182
(cherry picked from commit e8776f8)
2017-01-24 19:28:47 +01:00
Juergen Hoeller 4af6d58d8d Upgrade to Objenesis 2.5.1
Includes Hibernate ORM 5.2.7, Rome 1.7.1, Jetty 9.4.1, Undertow 1.3.26

Issue: SPR-15146
2017-01-23 23:47:22 +01:00
Juergen Hoeller e2d06eaae5 Deprecate outdated abstractions/delegates in core/util
Issue: SPR-15159
2017-01-23 23:47:14 +01:00
Juergen Hoeller fcfacd9f83 Polishing
(cherry picked from commit f095aa2)
2017-01-23 23:47:01 +01:00
Juergen Hoeller bddcc669b3 WebSocketSession.getExtensions consistently exposes unmodifiable/empty list
Issue: SPR-15180
(cherry picked from commit e94fa3f)
2017-01-23 23:33:04 +01:00
Juergen Hoeller 2024b37e65 HiddenHttpMethodFilter defensively proceeds with original request in case of error dispatch
Issue: SPR-15179
(cherry picked from commit a0df36d)
2017-01-23 23:32:20 +01:00
Juergen Hoeller fb3191904a DispatcherServet.checkMultipart considers MultipartException cause as well
Issue: SPR-15178
(cherry picked from commit ecc22f7)
2017-01-23 23:31:55 +01:00
Juergen Hoeller 9e4d74c502 Consider abstract classes with @Lookup methods as candidate components
Issue: SPR-14550
(cherry picked from commit 7d3fcaa)
2017-01-23 23:31:31 +01:00
Juergen Hoeller 9b221f58b9 Document further configuration class restrictions
Issue: SPR-14602
(cherry picked from commit 6fe7e56)
2017-01-23 23:31:03 +01:00
Juergen Hoeller f7c3b814e3 Only expose ASM-driven method order if the methods match
Issue: SPR-14505
(cherry picked from commit 253060c)
2017-01-23 23:30:36 +01:00
Juergen Hoeller 155bbb8466 Clear nonAnnotatedClasses cache in afterSingletonsInstantiated
Issue: SPR-15175
(cherry picked from commit e566e25)
2017-01-23 23:30:13 +01:00
Juergen Hoeller 4f690eea2a Drop classes folder (accidentally added in 35b67a5) 2017-01-23 22:37:39 +01:00
Rossen Stoyanchev 70a1ecba7f Documentation update related to Reactor version
Issue: SPR-15129
2017-01-23 15:02:01 -05:00
Rossen Stoyanchev c8b0ff2fca Add ExpectedCount#never()
Issue: SPR-15168
2017-01-20 17:11:09 -05:00
Stephane Nicoll f9a4856c3b Backport log4j doc improvements
Issue: SPR-15170
2017-01-20 17:38:20 +01:00
Brian Clozel 35b67a54d2 Upgrade to Tomcat 8.5.11 2017-01-20 09:55:33 +01:00
Rossen Stoyanchev 78a23be9bc Polish Reactor2TcpStompClient 2017-01-18 11:46:36 -05:00
Juergen Hoeller 09c5958608 Polishing 2017-01-18 00:53:59 +01:00
Juergen Hoeller ffb295971a Polishing 2017-01-18 00:27:04 +01:00
Rossen Stoyanchev 77bb7e6030 Add accessor methods to HttpPutFormContentFilter
Issue: SPR-14503
2017-01-17 17:18:03 -05:00
Rossen Stoyanchev 75daf781c2 Well-known names for beans in message broker XML config
Issue: SPR-15068
2017-01-17 17:08:45 -05:00
Rossen Stoyanchev fcead670f0 Add locking to AbstractRequestExpectationManager
This commit ensures that verifying a request, which includes finding
and updating expectations, is done synchronously to avoid concurrent
modification exceptions.

Technically SimpleRequestExpectationManager is not even expected to see
concurrent requests by definition but with
UnorderedRequestExpectationManager it can happen.

Issue: SPR-15029
2017-01-17 16:48:26 -05:00
Juergen Hoeller 801b93a078 Clarify WebContentInterceptor path mappings and efficiently match them
Issue: SPR-15096
2017-01-17 21:12:54 +01:00
Juergen Hoeller 4beeeb8118 ContentCachingRequestWrapper supports content cache limit
Issue: SPR-14829
(cherry picked from commit ad53867)
2017-01-17 20:57:28 +01:00
Juergen Hoeller 64d4afad9f SimpleApplicationEventMulticaster defensively swallows ClassCastException without message
Issue: SPR-15145
(cherry picked from commit 976d32f)
2017-01-17 20:43:59 +01:00
Rossen Stoyanchev 48f57e3bb2 Explicitly manage event loop in Reactor2TcpStompClient
Reactor2TcpStompClient now explicitly manages a Netty EventLoopGroup
which prevents resource leaks on attempts to reconnect.

Issue: SPR-15035
2017-01-17 14:19:36 -05:00
Juergen Hoeller d92f69747b Remove outdated groovy-bean-definition-dsl id in whats-new
Issue: SPR-15153
2017-01-17 16:23:55 +01:00
Juergen Hoeller 315698b50e Clarified cookieMaxAge default
Issue: SPR-15155
(cherry picked from commit 874b653)
2017-01-17 15:36:33 +01:00
Juergen Hoeller 6deccf123d Reference documentation for Groovy bean definition DSL
Issue: SPR-15153
(cherry picked from commit 2047f8d)
2017-01-17 15:35:24 +01:00
Juergen Hoeller 391ebc8eda Correct reference to XJC classpath
(cherry picked from commit 54da4a8)
2017-01-17 15:35:03 +01:00
Brian Clozel 28c7f65a25 Add SNI support in Netty4ClientHttpRequestFactory
This commit changes the `Bootstrap` to create a SSL Handler with
advisory peer information; this enables support for SNI.

Issue: SPR-15101
(cherry picked from commit 0c99346)
2017-01-17 11:32:10 +01:00
Juergen Hoeller caebe72083 Proper resolution of Optional.empty() for header arguments
Issue: SPR-15151
(cherry picked from commit e9db4d6)
2017-01-17 11:04:43 +01:00
Juergen Hoeller f79baec5ff Polishing
(cherry picked from commit 46fc7fb)
2017-01-16 23:14:12 +01:00
Vedran Pavić d1c0ea7d74 Set MockSessionCookieConfig#maxAge default to -1
Issue: SPR-15142
(cherry picked from 83beb9d57d)
2017-01-16 23:07:26 +01:00
Juergen Hoeller 53e2d7d160 Upgrade to Objenesis 2.5
(plus Groovy 2.4.8, Jackson 2.8.6, Netty 4.1.7)

Issue: SPR-15146
2017-01-16 22:44:07 +01:00
Juergen Hoeller 8c62a2f11a Polishing
(cherry picked from commit 95330d0)
2017-01-16 22:43:54 +01:00
Juergen Hoeller 8656e30550 Revised InvocableHandlerMethod exception messages (controller vs endpoint vs handler)
Introduces dedicated MethodArgumentResolutionException for spring-messaging invocations.

Issue: SPR-15139
(cherry picked from commit 047786a)
2017-01-16 22:43:48 +01:00
Juergen Hoeller 0655d73f8e SimpleApplicationEventMulticaster defensively handles ClassCastException without message
Issue: SPR-15145
(cherry picked from commit 153fd82)
2017-01-16 22:43:35 +01:00
Juergen Hoeller 24ebd15f9c Introspect FactoryBean class declaration if no early instantiation possible
Issue: SPR-15125
(cherry picked from commit 32fc855)
2017-01-16 22:43:18 +01:00
Juergen Hoeller cce84711c6 MockHttpServletRequestBuilder reliably detects form body content type again
Issue: SPR-15116
(cherry picked from commit e88e8f1)
2017-01-16 22:43:01 +01:00
Juergen Hoeller 7f127300f9 Polishing 2017-01-12 23:43:27 +01:00
Juergen Hoeller 1521094c5b MimeTypeUtils constants cleanup: deprecated web media types
Issue: SPR-15137
2017-01-12 23:43:00 +01:00
Juergen Hoeller 0b8134049c Upgrade to Joda-Time 2.9.7 2017-01-12 22:55:23 +01:00
Juergen Hoeller 70a980db58 Polishing 2017-01-12 22:54:23 +01:00
Juergen Hoeller 8b960099f1 Introduce media types for application/rss+xml
Issue: SPR-15109
2017-01-12 22:53:38 +01:00
Juergen Hoeller cc53d597c0 MySQLMaxValueIncrementer supports "useNewConnection" mode for INNODB tables
Issue: SPR-15107
2017-01-12 22:53:10 +01:00
Juergen Hoeller 5982f732b4 Improve performance of StringUtils.capitalize()
Issue: SPR-15094
2017-01-12 22:51:56 +01:00
Juergen Hoeller c5500b2332 MockHttpServletRequestBuilder supports multiple locales
Includes revised content type handling.

Issue: SPR-15116
(cherry picked from commit 02d727f)
2017-01-12 22:50:50 +01:00
Juergen Hoeller de611cb3a9 SpringValidatorAdapter properly handles HV-5-style list constraint violations
Issue: SPR-15082
(cherry picked from commit d0e9328)
2017-01-12 22:50:33 +01:00
Juergen Hoeller 72a76367f2 AbstractMessageSource does not attempt to format code-as-default-message
Issue: SPR-15123
(cherry picked from commit b06423a)
2017-01-12 22:50:22 +01:00
Juergen Hoeller 5afc3a3a50 Map resolution for multiple beans applies to plain Map interface declaration only
Issue: SPR-15117
(cherry picked from commit 8084da5)
2017-01-12 22:50:04 +01:00
Juergen Hoeller 2f2ef00d1f BeanDefinitionBuilder supports factory method on factory bean
Issue: SPR-15098
(cherry picked from commit 9e6aa0f)
2017-01-12 22:49:44 +01:00
Juergen Hoeller de7eea4498 GenericTableMetaDataProvider falls back to single schema as default
Issue: SPR-15090
(cherry picked from commit de43497)
2017-01-12 22:49:32 +01:00
Juergen Hoeller e9a87de965 LinkedCaseInsensitiveMap provides case-insensitive keySet again
Issue: SPR-15026
(cherry picked from commit 50e5a65)
2017-01-12 22:49:25 +01:00
Gary Russell db7b74feac Implement MessagingException.toString()
Issue: SPR-15091
Closes gh-1284
2017-01-05 10:25:55 +01:00
Philippe Marschall f7d126043b Remove use of Boolean constructors
Codacy warns us that there are several references to Boolean
constructors in the tests. Direct usage of the Boolean constructor is
discouraged and even deprecated in Java 9 [1]. Boolean constructor use
can easily be replaced with the constant instances.

This commit contains the following changes:

 - replace references to Boolean constructors with boolean constants in
   JSP tag tests
 - update the copyright year where necessary
 - BooleanComparatorTests is intentionally left unchanged as it should
   also work with the non-constant instances correctly

 [1] http://download.java.net/java/jdk9/docs/api/java/lang/Boolean.html#Boolean-boolean-

Issue: SPR-15076
2017-01-04 09:32:32 +01:00
Philippe Marschall 55b44b4f86 Avoid use of double constructor of BigDecimal
Codacy warns about an Error Prone [1] use of the double constructor of
BigDecimal in tests. The reason given is that it is a source of
precision loss if the number does not have an exact double
representation. The recommendation is to use the String constructor of
BigDecimal instead as it does not require using a lossy argument.

This commit contains the following changes:

 - replace usage of the double constructor of BigDecimal with the
   String constructor of BigDecimal in JdbcTemplateQueryTests
 - update the copyright year

 [1] http://errorprone.info/bugpattern/BigDecimalLiteralDouble

Issue: SPR-15077
2017-01-04 09:32:23 +01:00
Rob Winch 523370b6f2 Fix ForwardedHeaderFilter with non-empty contextPath
Issue: SPR-15088
2017-01-03 14:52:50 -06:00
Philippe Marschall 131d2c2051 Remove String#toCharArray from ScriptUtils
ScriptUtils contains two calls to String#toCharArray for the sole
purpose to iterating over all chars in a String. Not only is this
unnecessary and can be replaced with String#charAt it also causes
additional allocator and heap pressure because String#toCharArray
rather than returning the backing array (which is gone in Java 9)
creates a copy.

This commit contains the following changes:

 - remove String#toCharArray from ScriptUtils and replace with
   String#charAt

Issue: SPR-15075
2017-01-03 18:02:45 +01:00
Brian Clozel 7f05c2a18c Fix default content-type for ResourceRegion HTTP responses
Prior to this commit, the `ResourceRegionHttpMessageConverter` would
rely on the default implementation of `getDefaultContentType` to guess
the default Content-Type of the resource region to be written to the
HTTP response. That implementation fetches the first media type
provided in the HTTP request "Accept" header.

This behavior is not correct when converting resources and this commits
aligns this converter with the `ResourceHttpMessageConverter` which uses
JAF to guess the correct Content-Type of the given resource, or just
returns "application/octet-stream" as a default value.

Issue: SPR-15041
2017-01-03 11:18:40 +01:00
Juergen Hoeller 8fc65ab0a5 Clarified setAutowireCandidate semantics (plus attribute reordering in BeanDefinition)
Issue: SPR-15072
(cherry picked from commit e8a082f)
2016-12-30 11:55:55 +01:00
Juergen Hoeller b6108e3b2d Upgrade to ASM 5.2
Issue: SPR-15071
(cherry picked from commit ccabff6)
2016-12-30 11:55:50 +01:00
Juergen Hoeller 26a4aef417 Polishing
(cherry picked from commit fc629bb)
2016-12-29 23:12:11 +01:00
Juergen Hoeller 050f2c746d Track bean dependencies for calls between @Bean methods within @Configuration classes
Issue: SPR-15069
(cherry picked from commit a5c6658)
2016-12-29 23:12:05 +01:00
Juergen Hoeller fd21e0e69a @Scheduled reliably applies after other post-processors and shuts down before TaskScheduler
Issue: SPR-14692
Issue: SPR-15067
(cherry picked from commit edc62be)
2016-12-29 23:12:00 +01:00
Juergen Hoeller 794580ffcd TypeDescriptor efficiently matches equal annotations as well
Issue: SPR-15060
(cherry picked from commit e38c020)
2016-12-28 23:21:14 +01:00
Juergen Hoeller d44bc27c9a Avoid FactoryBean initialization on isSingleton check for decorated bean definition
Issue: SPR-14892
Issue: SPR-15042
(cherry picked from commit 209e7a7)
2016-12-28 23:20:15 +01:00
Juergen Hoeller 243e21a3ea Backport streamlined ClassPathBeanDefinitionScanner setup
Issue: SPR-15061
2016-12-27 18:32:03 +01:00
Juergen Hoeller 20aaa8841c PATCH does not work with the standard JDK HTTP library
Issue: SPR-15052
(cherry picked from commit 0480981)
2016-12-27 18:31:14 +01:00
Juergen Hoeller d77ab67c56 AbstractNestablePropertyAccessor's setPropertyValue refactored into several delegate methods
Issue: SPR-15053
(cherry picked from commit 64d6561)
2016-12-27 18:31:05 +01:00
Sebastien Deleuze dd2b6a0fc5 Avoid NPE in AutoProxyRegistrar when no attribute found
Issue: SPR-15055
2016-12-27 16:34:29 +01:00
Juergen Hoeller f949461297 Polishing
(cherry picked from commit a8741dd)
2016-12-26 11:40:49 +01:00
Juergen Hoeller 9a39a25bb5 Detect generic type match behind interface-based proxy as well
Issue: SPR-14097
(cherry picked from commit f805427)
2016-12-26 11:40:40 +01:00
Juergen Hoeller 4b018407c1 Expose reflection metadata with ASM-driven method order
Issue: SPR-14505
(cherry picked from commit 0208198)
2016-12-26 11:40:33 +01:00
Juergen Hoeller 28e114b569 Clarify programmatic contract (no annotation-driven injection)
Issue: SPR-8704
(cherry picked from commit fd41f63)
2016-12-26 11:40:25 +01:00
Juergen Hoeller 99226e0fa6 Polishing 2016-12-23 21:16:43 +01:00
Juergen Hoeller 4a84ee07be ConfigurationClassParser enforces @Bean declaration order through ASM metadata
Issue: SPR-14505
(cherry picked from commit 3295a4e)
2016-12-23 20:46:11 +01:00
Juergen Hoeller 505480cf63 LinkedCaseInsensitiveMap delegates to LinkedHashMap instead of extending it
Issue: SPR-15026
(cherry picked from commit 8147c11)
2016-12-23 20:46:07 +01:00
Juergen Hoeller fa2bfdd326 Remove unused Log object from MessageHeaderAccessor
Issue: SPR-15045
(cherry picked from commit 5c48daa)
2016-12-22 23:44:34 +01:00
Juergen Hoeller afe022853c Reintroduced initDefaultStrategies callback for compatibility with old MessageListenerAdapter subclasses
Issue: SPR-15043
2016-12-22 22:17:01 +01:00
Juergen Hoeller 41b834f76e Consistent ClassLoader propagation and ConcurrentHashMap setup for AspectJ pointcuts
Issue: SPR-15040
(cherry picked from commit d64d9ab)
2016-12-22 22:16:54 +01:00
Spring Buildmaster a88436c806 Next Development Version 2016-12-21 11:11:53 +00:00
Brian Clozel e2d6e709c3 Normalize resource URL in ResourceServlet
Issue: SPR-14946
2016-12-21 10:21:28 +01:00
Juergen Hoeller bd7fee5a77 Upgrade to Hibernate ORM 5.2.6 2016-12-21 10:10:49 +01:00
Juergen Hoeller 709d4ba6e7 Avoid explicit DecoratedObjectFactory setup in JettyRequestUpgradeStrategy
Issue: SPR-14940
2016-12-21 09:47:29 +01:00
Juergen Hoeller 8d55c7d60a Backported DataBinder configuration tests
Issue: SPR-15009
2016-12-21 09:31:55 +01:00
Juergen Hoeller 9cb4de8b5e Polishing 2016-12-20 21:11:07 +01:00
Juergen Hoeller 8662c61a17 Polishing
(cherry picked from commit 154ef8b)
2016-12-20 20:14:25 +01:00
Juergen Hoeller 935671ae32 Defensively catch any exception from match attempts (for compatibility with AspectJ 1.8.10)
Issue: SPR-15019
(cherry picked from commit 97ea22c)
2016-12-20 12:25:30 +01:00
Juergen Hoeller a5ce965d22 ConfigurationClassPostProcessor programmatically registers unified ImportAwareBeanPostProcessor
Issue: SPR-14931
(cherry picked from commit f6b2a21)
2016-12-20 12:25:22 +01:00
Juergen Hoeller 1e58c80fe7 MBeanExporter silently ignores null beans
Issue: SPR-15031
(cherry picked from commit 9c55d22)
2016-12-19 16:57:48 +01:00
Juergen Hoeller a92ae4ba30 Fixed backport gaps 2016-12-19 02:09:05 +01:00
Juergen Hoeller b5f2e56e38 Polishing 2016-12-19 01:51:57 +01:00
Juergen Hoeller 594f4d56b8 RestTemplate provides patchForObject operations
Issue: SPR-14857
2016-12-19 01:51:47 +01:00
Juergen Hoeller 2d83ca61e7 JdbcTemplate consistently delegates to getColumnMapRowMapper
Issue: SPR-15018
2016-12-19 01:49:58 +01:00
Juergen Hoeller 307e37a69f Flexible setMessageCodesResolver and deprecated setExtractOldValueForEditor at DataBinder level
Issue: SPR-15009
2016-12-19 01:49:38 +01:00
Juergen Hoeller 8310eb3b1f Latest dependency updates (OkHttp 3.5, Jackson 2.8.5, Jetty 9.3.14, Tomcat 8.5.9) 2016-12-19 01:49:12 +01:00
Juergen Hoeller b9c4f1fa95 ResolvableType-based matching respects generic factory method return type
Includes consistent use of ResolvableType.resolve() wherever applicable.

Issue: SPR-15011
(cherry picked from commit 4c005e6)
2016-12-19 01:12:14 +01:00
Juergen Hoeller faab4f9e28 Consistent DeferredResultHandler invocation outside of result lock
Issue: SPR-14978
(cherry picked from commit 37c734e)
2016-12-19 01:10:38 +01:00
Juergen Hoeller 271b0abc45 LocaleContextHolder provides support for framework-level default settings
Issue: SPR-15017
(cherry picked from commit 23f0418)
2016-12-19 01:10:09 +01:00
Juergen Hoeller f0c3d50408 Defensively catch IllegalStateException from match attempts (for compatibility with AspectJ 1.8.10)
Issue: SPR-15019
(cherry picked from commit 3370f41)
2016-12-19 01:09:36 +01:00
Juergen Hoeller f0fdff1f07 OkHttpClientHttpRequestFactory allows POST request without body
Issue: SPR-15015
(cherry picked from commit 2954385)
2016-12-19 01:09:06 +01:00
Juergen Hoeller d15df3489e Avoid proxy replacement for generic return type signatures
Issue: SPR-15010
(cherry picked from commit 6d1cae2)
2016-12-19 01:04:00 +01:00
Juergen Hoeller f3cc4ab09d @RequestBody supports java.util.Optional
Issue: SPR-15007
(cherry picked from commit eeb7ae5)
2016-12-19 01:03:18 +01:00
Juergen Hoeller 442d8a68a6 TypeDescriptor properly narrows ResolvableType for non-typed collection elements
Issue: SPR-14971
(cherry picked from commit aef1460)
2016-12-19 01:02:18 +01:00
Juergen Hoeller 934fffec68 AutowiredAnnotationBeanPostProcessor tolerates annotated no-arg constructors
Issue: SPR-15005
(cherry picked from commit 8b5ee4e)
2016-12-19 01:01:59 +01:00
Juergen Hoeller 8190e7838f SQLErrorCodesFactory provides unregisterDatabase method
This commit also migrates from a WeakHashMap to a ConcurrentReferenceHashMap, allowing for concurrent access to existing cache entries.

Issue: SPR-15006
(cherry picked from commit b825528)
2016-12-19 01:01:41 +01:00
Juergen Hoeller 4571975414 Collection injection may refer back to factory methods on same bean again
Issue: SPR-14996
(cherry picked from commit 547b963)
2016-12-19 01:01:16 +01:00
Juergen Hoeller 5115c61b03 CommonsMultipartFile.getOriginalFilename() can be configured to preserve header-specified filename as-is
Issue: SPR-14613
(cherry picked from commit aa29495)
2016-12-19 00:59:28 +01:00
Juergen Hoeller 54c7a9ee95 Revised Jetty 9.3 vs 9.4 differentiation
Issue: SPR-14940
(cherry picked from commit 52799c0)
2016-12-19 00:58:53 +01:00
Juergen Hoeller 0296c7c5b6 Stronger explanation of default rollback rules
Issue: SPR-14994
(cherry picked from commit 953bc18)
2016-12-19 00:58:44 +01:00
Juergen Hoeller 84d8135cbb MimeType parsing properly handles quoted semicolons
Issue:  SPR-14986
(cherry picked from commit 7714eec)
2016-12-19 00:58:23 +01:00
Juergen Hoeller dd3c370bca ImportRegistry properly tracks excluded superclasses
Issue: SPR-14972
(cherry picked from commit a7ec6dc)
2016-12-19 00:57:45 +01:00
Juergen Hoeller 4e41f74925 Explicit support for retrieving enum values
Issue: SPR-14990
(cherry picked from commit 278a625)
2016-12-19 00:56:44 +01:00
Juergen Hoeller c6663f59b8 HttpInvokerClientInterceptor propagates client-side Error as-is
Issue: SPR-14985
(cherry picked from commit ee30ce9)
2016-12-19 00:56:06 +01:00
Juergen Hoeller ced7503d95 Revised forClass argument names
Issue: SPR-14976
(cherry picked from commit 8ab977e)
2016-12-19 00:55:39 +01:00
Juergen Hoeller 04af30daed JPA/Hibernate docs: transaction management, JTA setup
Issue: SPR-14957
(cherry picked from commit 2f80b84)
2016-12-19 00:55:19 +01:00
Juergen Hoeller 5ccc8e341c SpEL docs: supported literals, null comparisons
Issue: SPR-14361
Issue: SPR-14987
(cherry picked from commit 05579fd)
2016-12-19 00:55:03 +01:00
Juergen Hoeller 71977e8f9d Consistent use of "URI variables" terminology
Issue: SPR-14969
(cherry picked from commit 6517c53)
2016-12-19 00:54:49 +01:00
Rob Winch 5e774e0b44 Add Support for ForwardedHeaderFilter sendRedirect
Previously ForwrdedHeaderFilter did not ensure that
HttpServletResponse.sendRedirect worked properly based on
X-Forwarded-* headers.

This commit updates ForwardedHeaderFilter to overrided the
HttpServletResponse.sendRedirect method to ensure
X-Forwarded-* headers are honored.

Issue SPR-15020
2016-12-15 19:38:40 -05:00
Rossen Stoyanchev e16d753439 Allow athentication at the STOMP level
This commit makes it possible for a ChannelInterceptor to override the
user header in a Spring Message that contains a STOMP CONNECT frame.

After the message is sent, the updated user header is observed and
saved to be associated with session thereafter.

Issue: SPR-14690
2016-12-13 16:17:05 -05:00
Rossen Stoyanchev b14d189db9 MockRestRequestMatchers can match query params
Issue: SPR-14995
2016-12-13 16:07:19 -05:00
Brian Clozel 14de29c031 Improve VersionResourceResolve javadoc
The `pathPatterns` args are relative to the patterns configured for the
resource handler.

Issue: SPR-14817
Cherry-picked from: 52f664139
2016-12-13 11:01:14 +01:00
Brian Clozel b59455b63c Do not include URL hash in resource paths
When getting the lookup path of a resource, both query params and hashes
should be removed from the request path.

This commit fixes the public path resolution for paths like
`/resources/main.svg#icon-hamburgermenu`.

Issue: SPR-14928
2016-12-12 15:23:23 +01:00
Brian Clozel 1a6dc86fed Allow RedirectAttributes on ExceptionHandlers
Prior to this commit, `@ExceptionHandler` methods could not be injected
with `RedirectAttributes` arguments. This would make it impossible to
handle an error by redirecting to another view and add flashmap
attributes, to be included in the model when the next view is called.

Here is an example:

```
@ExceptionHandler(MyException.class)
public String handleException(MyException ex, RedirectAttributes
    redirectAttributes) {

  redirectAttributes.addFlashAttribute("errorMessage",
      "This is an error message");
  return "redirect:/";
}
```

This commit adds a new `RedirectAttributesMethodArgumentResolver`
instance in the list of pre-configured `HandlerMethodArgumentResolver`
in `ExceptionHandlerExceptionResolver`.

Issue: SPR-14651
Cherry-picked from: 17089d6
2016-12-12 09:09:35 +01:00
Brian Clozel 35b0c8b577 Update websocket support for Jetty 9.3+
Due to a few changes in `WebSocketServerFactory` and `Session` API, our
`JettyRequestUpgradeStrategy` and `JettyWebSocketSession` needed to
adapt. As of 9.3.15+ and 9.4.0+, some reflection is required to support
previous versions.

Spring 4.3 websocket officially supports Jetty 9.1 to 9.3.

Issue: SPR-14940
2016-12-09 14:58:18 +01:00
Brian Clozel 75034c3710 Revert "Update websocket support for Jetty 9.3+"
This reverts commit 305cea28c5.
2016-12-08 22:48:06 +01:00
Brian Clozel 305cea28c5 Update websocket support for Jetty 9.3+
Due to a few changes in `WebSocketServerFactory` and `Session` API, our
`JettyRequestUpgradeStrategy` and `JettyWebSocketSession` needed to
adapt. As of 9.3.15+ and 9.4.0+, some reflection is required to support
previous versions.

Spring 4.3 officially supports Jetty 9.1 to 9.3.

Issue: SPR-14940
2016-12-08 21:44:31 +01:00
Rossen Stoyanchev 69ba85b051 Backport of STOMP message header encoding improvements
Issue: SPR-14901
2016-12-08 11:33:16 -05:00
Sebastien Deleuze 5700d65a53 Append "data:" after line breaks for SSE JSON data fields
Issue: SPR-14899
2016-12-08 14:16:41 +01:00
bedrin e707c40e0b Add consumes attribute to @GetMapping
Issue: SPR-14988
2016-12-07 17:51:05 -05:00
Brian Clozel 9d37472f23 Fix Netty4ClientHttpRequestFactory POST/PUT requests
This commit ensures that POST/PUT requests sent by the Netty client have
a Content-Length header set.

Integration tests have been refactored to use mockwebserver instead of
Jetty and have been parameterized to run on all available supported
clients.

Issue: SPR-14860
Cherry-picked from: ec8391a7fb
2016-12-07 09:24:13 +01:00
Juergen Hoeller eb97335c6f Polishing 2016-12-01 20:19:49 +01:00
Juergen Hoeller 0028b29760 Polishing 2016-12-01 19:09:26 +01:00
Juergen Hoeller 1ded1e38e8 Latest dependency updates (Caffeine 2.3.5, Hibernate ORM 5.2.5, Joda-Time 2.9.6, Tomcat 8.5.8, JOpt Simple 5.0.3) 2016-12-01 19:08:57 +01:00
Juergen Hoeller 149acdae7d @UsesJava8
Issue: SPR-14958
2016-12-01 14:23:59 +01:00
Juergen Hoeller 5fee5f39ea Polishing 2016-12-01 14:13:23 +01:00
Juergen Hoeller f16d453805 PathMatchingResourcePatternResolver converts manifest entries to absolute paths and tries all root URLs (any file extension) as jar file
Issue: SPR-14934
Issue: SPR-14936
2016-12-01 14:12:56 +01:00
Juergen Hoeller 2b0293578f Consistent use of "URI variables" terminology
Issue: SPR-14969
(cherry picked from commit 7a8ec4f)
2016-12-01 14:12:07 +01:00
Juergen Hoeller 66aeeedaef Test injection point match for narrow target return type
Issue: SPR-14960
(cherry picked from commit 845dbf0)
2016-12-01 14:12:00 +01:00
Juergen Hoeller af41dd1ed6 Efficient ISO_LOCAL_* variants for printing LocalDate/LocalTime/LocalDateTime
Issue: SPR-14958
(cherry picked from commit 1ae17c2)
2016-12-01 14:11:49 +01:00
Juergen Hoeller 17f7f1fc15 Consistent catching of Throwable for introspection failures
Issue: SPR-12889
(cherry picked from commit 0186809)
2016-12-01 14:11:43 +01:00
Juergen Hoeller cbc512f3be Efficient type plus annotation comparisons during converter retrieval
Issue: SPR-14926
Issue: SPR-12926
(cherry picked from commit f6b8b84)
2016-12-01 14:11:34 +01:00
Juergen Hoeller 7ac9f92bc2 Various DefaultListableBeanFactory clarifications
* getBeanDefinitionNames defensively returns a copy of the bean definition names array.
* copyConfigurationFrom provides an independent AutowireCandidateResolver instance and copies a ConversionService and dependency comparator configuration as well.
* findAutowireCandidates only considers a self reference fallback for direct dependency declarations, not as a collection element.

Issue: SPR-14897
Issue: SPR-14921
Issue: SPR-14965
(cherry picked from commit ac5933a)
2016-12-01 14:11:08 +01:00
Juergen Hoeller a7ba63d425 Shared DefaultConversionService instance for simple fallback purposes
Issue: SPR-14948
(cherry picked from commit 80931b2)
2016-12-01 14:10:39 +01:00
Juergen Hoeller 5ca10b1d67 Consistent ExpressionException-style quoting of expression string and position
Issue: SPR-14942
(cherry picked from commit 14eba50)
2016-12-01 14:10:23 +01:00
Juergen Hoeller f22a4a4e80 No warn logging for propagated original exception
Issue: SPR-14907
(cherry picked from commit 96bfc14)
2016-12-01 14:10:01 +01:00
Juergen Hoeller b53ee13662 JdbcUtils explicitly extracts SQL date/time for JSR-310 LocalDate/Time
Issue: SPR-14898
(cherry picked from commit a0fee46)
2016-12-01 14:09:53 +01:00
Christoph Dreis 8de100b116 Implement allocation-friendly method to get user count in SimpUserRegistry
SPR-14930
(cherry picked from commit a929e9c)
2016-12-01 14:09:43 +01:00
Juergen Hoeller ac30bcb0eb WebSocketServerSockJsSession uses dedicated disconnect lock
Issue: SPR-14917
(cherry picked from commit a49809b)
2016-12-01 14:09:34 +01:00
Rossen Stoyanchev 872d6ef55a HtmlUnitRequestBuilder detects form encoding type
Issue: SPR-14916
2016-11-28 18:08:44 -05:00
Rossen Stoyanchev dd3b9c7c35 ResponseEntity headers builder casts body to any type
Issue: SPR-14939
2016-11-28 17:25:20 -05:00
Rossen Stoyanchev 9755ae3cbe PayloadArgumentResolver has useDefaultResolution flag
Issue: SPR-14937
2016-11-28 17:02:03 -05:00
Brian Clozel bc29fb5a09 Do not execute ResourceUrlEncodingFilter only once per request
In case the filter is also registered to the ERROR dispatcher, the
following happens:
* the filter is executed once for the regular execution
* the filter should be executed a second time when dispatched to error

Since the filter is a `OncePerRequestFilter`, the filter is only
executed once and won't be executed when handling the error.

This can lead to situations like spring-projects/spring-boot#7348

This commit makes this filter a simple `GenericFilterBean`.

Issue: SPR-14891
2016-11-24 10:03:08 +01:00
Rossen Stoyanchev 646a574b9c Deprecate ResourceServlet 2016-11-23 21:22:58 -05:00
Rossen Stoyanchev 8f19650fd7 Avoid locking in WebSocket session "close" callback
When processing a "close" notification from the server make an effort
to cancel any outstanding heartbeat but avoid going as far as acquiring
the responseLock since the server itself may already hold a lock of its
own leading to a potential deadlock.

The heartbeat task is now also further protected with an isClosed()
check in case the heartbeat does not get cancelled in a concurrent
scenario.

Issue: SPR-14917
2016-11-23 20:58:22 -05:00
Stephane Nicoll f08980967b Polish doc 2016-11-17 07:25:42 +09:00
Mark Paluch 5285f5300a Fix TLS detection in URLs for Netty Client RequestFactory
Do not check on non-specified port when scheme is https.
Enables SSL for https URIs with a specified port.

Issue: SPR-14889
2016-11-11 16:49:18 +01:00
Juergen Hoeller 1608d0596d Polishing 2016-11-11 16:48:43 +01:00
Juergen Hoeller 62631bfe33 Detect invalid configuration for autoGrowCollectionLimit on DataBinder
Issue: SPR-14888
2016-11-08 17:47:29 +01:00
Juergen Hoeller 7ffed858f0 ASM-generated class names get interned for better memory allocation
Issue: SPR-14886
(cherry picked from commit 3a29daa)
2016-11-08 17:47:14 +01:00
Spring Buildmaster 3a1334e0d4 Next Development Version 2016-11-07 21:35:52 +00:00
Juergen Hoeller 37f4f43726 Consistent 4.x style NoClassDefFoundError handling
Issue: SPR-14883
2016-11-07 19:13:00 +01:00
Juergen Hoeller db1a84ede1 Polishing 2016-11-07 18:48:35 +01:00
Juergen Hoeller 3d2e4c338c Refined throwing of BeanCreationExceptions (and reflection exceptions)
Issue: SPR-14883
2016-11-07 18:47:54 +01:00
Juergen Hoeller b42d731fc8 Consistent throwing of BeanCreationExceptions (and reflection exceptions)
Issue: SPR-14883
2016-11-07 16:56:35 +01:00
Juergen Hoeller fd7045adac Polishing
(cherry picked from commit 9b57437)
2016-11-07 13:02:50 +01:00
Juergen Hoeller e26d3505f7 Upgrade to OkHttp 3.4.2 and Tiles 3.0.7 2016-11-04 14:55:37 +01:00
Juergen Hoeller fe0249bf8f Polishing 2016-11-04 13:37:06 +01:00
Juergen Hoeller 2ac682e125 Upgrade to Joda-Time 2.9.5 2016-11-04 13:30:25 +01:00
Juergen Hoeller 9be1710dca @Async docs explicitly mention ListenableFuture and CompletableFuture
Issue: SPR-14881
(cherry picked from commit 8df45dd)
2016-11-04 13:30:11 +01:00
Juergen Hoeller 7e7504f5ea Polishing 2016-11-03 23:20:33 +01:00
Juergen Hoeller e83c11667f ApplicationListenerDetector ignores non-managed bean instances
Issue: SPR-14879
(cherry picked from commit 8ae0bd6)
2016-11-03 23:20:06 +01:00
Juergen Hoeller 05547979de Polishing
Issue: SPR-14867
(cherry picked from commit a90e4b2)
2016-11-03 14:54:15 +01:00
Juergen Hoeller 9e67ba83a5 Consistent support for early placeholder resolution in properties locations
Issue: SPR-10502
(cherry picked from commit 8053fef)
2016-11-03 14:53:46 +01:00
Juergen Hoeller 2bb3522bbb ReloadableResourceBundleMessageSource sets file timestamp on merged holder
Issue: SPR-14583
(cherry picked from commit 03468fd)
2016-11-03 14:53:24 +01:00
Rossen Stoyanchev 8f4ec35697 Check SockJS session type
This commits adds a validation check whether the SockJS session type
matches the transport type and rejects requests for which they
don't match.

Issue: SPR-14867
2016-11-03 09:38:24 +02:00
Juergen Hoeller 17863dfbda AnnotatedElementAdapter explicitly declares isAnnotationPresent method
Issue: SPR-14872
2016-11-02 14:41:11 +01:00
Juergen Hoeller 56bb20d489 Upgrade to HtmlUnit 2.23 and JSONAssert 1.4 2016-11-02 14:40:10 +01:00
Juergen Hoeller 5baf32cd81 Upgrade to Caffeine 2.3.4 2016-11-02 14:02:49 +01:00
Andy Clement 38cd1ecff4 Rework compilation of OpNE/OpEQ SpEL operators
For SPR-14863 we need to adjust the code generation for OpNE
to use !x.equals(y) rather than x!=y. There are also further
cases in the equalityCheck() code in Operator that were not
being handled in the compilation case (when comparators are
used for example). This latter issue also affects OpEQ.

Rather than add yet more bytecode generation, both OpNE and
OpEQ generateCode() methods have been simplified. The
generated code now delegates to equalityCheck() in Operator
which is exactly what the interpreted case does.

This ensures that the compiled code continues to behave just
like the interpreted case. It ensures changes to the interpreted
case are automatically picked up for the compiled case. It
makes the bytecode generation simpler.

The benefit of compilation of SpEL expressions is to avoid
slow reflective calls - that doesn't apply for a basic
(in)equality test so there is no need to go crazy in bytecode
gen.

Issue: SPR-14863
(cherry picked from commit 9000acd)
2016-11-02 12:40:24 +01:00
Juergen Hoeller 77e00f1926 Polishing 2016-10-31 20:40:46 +01:00
Juergen Hoeller ade139f2d0 Polishing
(cherry picked from commit 45fc449)
2016-10-31 19:29:04 +01:00
Juergen Hoeller 653f35a3d8 Upgrade to H2 1.4.193 and Derby 10.13.1.1
(cherry picked from commit eaf8078)
2016-10-31 19:28:58 +01:00
Juergen Hoeller baa7aecf60 Polishing
(cherry picked from commit 7f280a3)
2016-10-31 12:40:44 +01:00
Juergen Hoeller d859826be6 ASM-generated class names get interned for better memory allocation
Issue: SPR-14862
2016-10-31 11:56:34 +01:00
Juergen Hoeller d759c96a98 Latest applicable dependency updates (Hibernate ORM 5.2.4, Gson 2.8, Guava 20) 2016-10-31 11:54:29 +01:00
Juergen Hoeller 7cbab0efe3 LocalSessionFactoryBean clears default MetadataSources on reinitialization
Issue: SPR-14815
2016-10-31 11:53:10 +01:00
Arjen Poutsma b6b536682e Make HttpComponentsAsyncClientHttpRequest abortable
This commit aborts the HttpComponentsAsyncClientHttpRequest whenever the
returned Future is canceled.

Issue: SPR-14845
(cherry picked from commit 8f84446)
2016-10-31 11:51:26 +01:00
Juergen Hoeller edf1df33cc ObjectToObjectConverter properly handles constructors on non-public classes
Issue: SPR-14304
(cherry picked from commit 9659bc5)
2016-10-31 11:51:05 +01:00
Juergen Hoeller bf0df54136 Consistent instanceof/casting of Class references
(cherry picked from commit ac80ac6)
2016-10-31 11:50:59 +01:00
Juergen Hoeller 7e80d2de79 Exceptions thrown from @ExceptionHandler methods logged at warn level (instead of debug)
Issue: SPR-14861
(cherry picked from commit 7627c38)
2016-10-31 11:50:45 +01:00
Juergen Hoeller 144f687ee9 Polishing
(cherry picked from commit 2f9ed59)
2016-10-31 11:50:36 +01:00
Juergen Hoeller 0ee8322947 Revised NoSuchBeanDefinitionException message and ResolvableType handling
Includes consistent quoting of qualified type names in related classes.

Issue: SPR-14831
(cherry picked from commit dc080cb)
2016-10-31 11:50:15 +01:00
Juergen Hoeller 997fb5fb48 DefaultListableBeanFactory allows early type matching against ScopedProxyFactoryBean
Issue: SPR-14816
(cherry picked from commit 3633244)
2016-10-31 11:50:02 +01:00
Juergen Hoeller 2b459881bd ApplicationListener detection for inner beans behind post-processors
Issue: SPR-14783
(cherry picked from commit c946924)
2016-10-31 11:49:06 +01:00
Juergen Hoeller e18e7eca47 No external locking for singleton advice/aspect beans
Issue: SPR-14324
(cherry picked from commit 5ac5ec1)
2016-10-31 11:48:12 +01:00
Juergen Hoeller 1c80d2ac2f Avoid deadlock between SockJS heartbeat and XHR polling
Issue: SPR-14833
(cherry picked from commit 72e1f7e)
2016-10-31 11:47:23 +01:00
Juergen Hoeller 62918ca779 TypeDescriptor supports merged annotation lookups (for composable formatting annotations)
Issue: SPR-14844
(cherry picked from commit bf9083d)
2016-10-31 11:46:30 +01:00
Juergen Hoeller 3cca57a801 Local merged annotation lookup in SpringCacheAnnotationParser
Issue: SPR-14781
Issue: SPR-14801
(cherry picked from commit 08972ef)
2016-10-31 11:45:35 +01:00
Juergen Hoeller 5578a2e46d Test for multi-character delimiter
Issue: SPR-14808
(cherry picked from commit 71d8338)
2016-10-31 11:45:01 +01:00
Juergen Hoeller fe19cfde28 Tightened StringValueResolver contract
Issue: SPR-14842
(cherry picked from commit 20419d7)
2016-10-31 11:44:46 +01:00
Juergen Hoeller fbad637235 SimpleApplicationEventMulticaster just swallows event downcast exceptions
Issue: SPR-14846
(cherry picked from commit 13001b9)
2016-10-31 11:44:26 +01:00
Juergen Hoeller 01e9307fb7 DataSourceTransactionManager triggers flush callbacks on registered transaction synchronizations
Issue: SPR-14847
(cherry picked from commit 2874066)
2016-10-31 11:44:17 +01:00
Juergen Hoeller 5697cb6c95 AccessorLValue reliably downcasts to CompilablePropertyAccessor in concurrent scenarios
Issue: SPR-14850
(cherry picked from commit e2b1dcb)
2016-10-31 11:44:08 +01:00
Juergen Hoeller 05ff83f95a ResourceHttpRequestHandler initializes PathExtensionContentNegotiationStrategy in afterPropertiesSet
Issue: SPR-14851
(cherry picked from commit b7d3a96)
2016-10-31 11:43:57 +01:00
Stephane Nicoll 1e3012cb49 Allow to customize TestDispatcherServlet
This commit introduces the `DispatcherServletCustomizer` callback
interface that can be used to customize the `DispatcherServlet` that a
`MockMvc` is using.

Previously, only the `dispatchOptions` flag can be customized. This
commit allows to customize any property of `DispatcherServlet` before it
is initialized.

Issue: SPR-14277
2016-10-29 11:09:48 +02:00
Rossen Stoyanchev 45b8cf350e Better handling for AsyncRequestTimeoutException
Avoid call to sendError when response is committed and log a short
error message instead.

Issue: SPR-14739
2016-10-28 17:41:48 +03:00
Stephane Nicoll 2c2c6f8e02 Fix broken build
This commit fixes the direct use of Java8 API

Issue: SPR-14853
2016-10-27 10:30:54 +02:00
Stephane Nicoll 4e3a6b9404 Polish 2016-10-27 10:01:51 +02:00
Stephane Nicoll 76bbccb4dc Allow @Cacheable method to return Optional
This commit further refines 240f254 to also support java.util.Optional
for synchronized cache access (i.e. when the `sync` attribute on
`@Cacheable` is set to `true`).

Issue: SPR-14853
2016-10-27 10:00:34 +02:00
Stephane Nicoll 1c4433555a Move NoOpCache to a top-level public class
This commit moves `NoOpCache` to a top-level public class to allow reuse
in custom CacheManager arrangement.

Issue: SPR-14856
2016-10-27 09:09:51 +02:00
Eric Jain faaced1d86 Escape (( and )) to prevent asciidoc processing
See http://asciidoctor.org/docs/user-manual/#user-index

Closes gh-1225
2016-10-27 08:50:27 +02:00
Stephane Nicoll 1a1d17e13a LiveBeansView does not rely on application contexts order anymore
This commit makes sure that the `unregister` order of registered
application contexts has no incidence on the removal of the LiveBeansView
MBean.

Rather than using the last application context's name to compute the
identity of the MBean to remove, the identity is stored when the MBean is
created.

This commit also adds missing tests.

Issue: SPR-14848
2016-10-26 15:03:44 +02:00
Stephane Nicoll 4254b6d0e2 Polish contribution
Closes gh-1203
2016-10-26 09:50:48 +02:00
Vitalii a211c2a955 Fix javadoc syntax
See gh-1203
2016-10-26 09:50:36 +02:00
Stephane Nicoll 196200bcc0 Clarify SpEL usage on @EventListener
Issue: SPR-14812
2016-10-25 17:45:36 +02:00
Rossen Stoyanchev c062835702 Respect ModelAndView.status in @ExceptionHandler
Issue: SPR-14006
2016-10-24 16:36:44 +01:00
Juergen Hoeller 664ef756c2 Latest dependency updates (EhCache 2.10.3, Jackson 2.8.4, Jetty 9.3.13, Netty 4.1.6) 2016-10-21 13:00:11 +02:00
Juergen Hoeller 9de28d640e Polishing
(cherry picked from commit 3726c6f)
2016-10-21 12:59:59 +02:00
Juergen Hoeller adb9dc7ede ResolvableType equals/hashCode does not consider TypeProvider source
Issue: SPR-14826
(cherry picked from commit be187ba)
2016-10-21 12:59:54 +02:00
Juergen Hoeller f9fcd24315 ConversionService detects generic type declaration on target class behind proxy as well
Issue: SPR-14822
(cherry picked from commit f7d740f)
2016-10-21 12:59:48 +02:00
Juergen Hoeller 6d95b999ad DefaultTransactionAttribute stores descriptor (method identification)
Issue: SPR-14760
(cherry picked from commit 52b029d)
2016-10-21 12:59:43 +02:00
Sebastien Deleuze 6731e52280 Better encapsulation for CORS default permit configuration
This commit also improves CorsRegistration Javadoc.

Issue: SPR-14798
2016-10-20 17:06:12 +02:00
Rossen Stoyanchev 970358b2af Relax generic type detection for ResponseEntity
Before this change the getHttpEntityType method in
HttpEntityMethodProcessor raised an ISE if the generic type cannot be
detected. That made sense for resolving a controller method argument
where the target body type is crucial. However for a return value
the generic type should not be required since we either have an
actual body or no body at all in which case it doesn't even matter.

This change relaxes the checks and defaults to Object.class for the
ResponseEntity generic type on the return value side.

Issue: SPR-14799
2016-10-13 13:59:13 -04:00
Juergen Hoeller 3d68950037 Upgrade to Tomcat 8.5.6 and JRuby 1.7.26 2016-10-12 17:52:36 +02:00
Juergen Hoeller d50b2a4804 Documentation for InjectionPoint argument on @Bean method
Issue:  SPR-14797
(cherry picked from commit 69116c2)
2016-10-12 17:48:50 +02:00
Juergen Hoeller 29a946163b Polishing
(cherry picked from commit eafaaa5)
2016-10-12 17:48:33 +02:00
Juergen Hoeller 9472025da7 BindingResult does not hold on to ConversionService when serialized in session
Issue: SPR-8282
(cherry picked from commit 74b6a5b)
2016-10-12 17:48:08 +02:00
Juergen Hoeller f5cd5387da StompSubProtocolHandler does not insist on SimpMessageHeaderAccessor
Issue: SPR-14791
(cherry picked from commit 66722af)
2016-10-12 17:47:58 +02:00
Stephane Nicoll 7a8bf8e9a5 Polish EnableAsync javadoc
Issue: SPR-14793
(cherry picked from commit ab232a5)
2016-10-12 17:47:28 +02:00
Sebastien Deleuze f5ecdda400 Remove duplicated elements in CorsConfiguration#combine()
Issue: SPR-14792
2016-10-11 10:53:33 +02:00
Sebastien Deleuze c2031aa651 Polish CorsConfigurationTests 2016-10-11 10:41:14 +02:00
Brian Clozel 8751c9931e Fix NumberFormatException with X-Forwarded-Host
This commit fixes `NumberFormatException`s that were thrown when parsing
IPv6 host values in `X-Forwarded-Host` request headers.

Issue: SPR-14761
(cherry picked from ea5ff87f8e)
2016-10-07 23:19:01 +02:00
Brian Clozel adbf9922f4 Configure default SSL context in Netty RequestFactory
This commit configures a default SslContext if none has been provided.
This also enforces separate Netty bootstrap instances for cleartext and
TLS exchanges.

Issue: SPR-14744
(cherry picked from 53441f8)
2016-10-06 16:50:27 +02:00
Stephane Nicoll b3a1e5f9e9 Fix table layout 2016-10-06 15:27:25 +02:00
Juergen Hoeller 22f70f9ac9 Upgrade to EhCache 3.1.3 and Hibernate ORM 5.2.3 2016-10-06 00:16:29 +02:00
Juergen Hoeller d2079f32d8 SpringValidatorAdapter declares ResolvableAttribute as serializable
Issue: SPR-14778
(cherry picked from commit ebed7b7)
2016-10-06 00:16:00 +02:00
Juergen Hoeller f2ac416f66 Consistent final logger fields
(cherry picked from commit cfa0f6c)
2016-10-06 00:15:45 +02:00
Juergen Hoeller 642fbfba9f @Lookup reference documentation
Issue: SPR-14765
(cherry picked from commit 684d6ab)
2016-10-06 00:15:38 +02:00
Brian Clozel c98cdd4f4c Fix missing ETag/LastModified headers in responses
Prior to this commit, the `HttpEntityMethodProcessor` would avoid
writing ETag/Last-Modified response headers before calling
`ServletWebRequest` to process conditional requests. This was done to
avoid duplicate response header values due to headers being already
written to the underlying servlet response.

This is still necessary for GET/HEAD requests, since this is properly
handled by `ServletWebRequest` for those cases. But
`HttpEntityMethodProcessor` should not make that decision for
PUT/PATCH/POST responses since developers are adding response headers on
purpose and should be in control of the situation — whereas
`ServletWebRequest` does not write those headers in those cases.

Issue: SPR-14767
Cherry-picked from: ee17f5662
2016-10-04 13:54:02 +02:00
Juergen Hoeller d04567b99c Polishing 2016-09-26 18:19:04 +02:00
Juergen Hoeller f2e1e1b890 Efficient STOMP content-length header check
Issue: SPR-14747
(cherry picked from commit a6b0b6e)
2016-09-26 17:30:45 +02:00
Juergen Hoeller 6c764f6b8a StompEncoder performance improvement plus related polishing
Issue: SPR-14747
2016-09-26 16:33:29 +02:00
Juergen Hoeller 49929f1e56 Clarified that getResource never returns null
(cherry picked from commit 36f7c7a)
2016-09-26 16:21:44 +02:00
Juergen Hoeller acdf139137 DefaultPersistenceUnitManager extracts jar file from default persistence unit root URL
Issue: SPR-14749
(cherry picked from commit bb7d207)
2016-09-26 16:21:33 +02:00
Juergen Hoeller 3346c594e4 YamlPropertiesFactoryBean consistently exposes String values
Issue: SPR-14737
(cherry picked from commit 74c6188)
2016-09-26 16:21:03 +02:00
Juergen Hoeller 0bb2cfe440 Latest dependency updates (Jackson 2.8.3, JavaMail 1.5.6, Jetty 9.3.12, Undertow 1.3.25) 2016-09-22 14:25:44 +02:00
Josh Long 11573b4ea4 fix spelling of word 'recommendation'
this PR fixes the spelling error for the word 'recommendation'
(cherry picked from commit 9b87ea0)
2016-09-22 14:25:25 +02:00
Spring Buildmaster 5934959b62 Next Development Version 2016-09-19 15:11:46 +00:00
Rossen Stoyanchev 81f6c22e51 Reset connection before delegating to handler
Resetting the connection first before invoking a failure callback on
the application handler ensures that any checks to isConnected will
return false.

Issue: SPR-14721
2016-09-19 09:06:11 -04:00
Stephane Nicoll 78a8245f4a Polish 2016-09-19 15:04:52 +02:00
Krzysztof Kosmatka 049861afb4 Documentation formatting fix
Removed unnecessary quotation marks that caused improper rendering
of in-line code.

Closes gh-1180
2016-09-19 15:04:39 +02:00
Krzysztof Kosmatka 3df7083f69 Add missing quotation mark
Closes gh-1181
2016-09-19 15:04:31 +02:00
Juergen Hoeller ca17edd5ac Revised checkResource implementation
Issue: SPR-14729
2016-09-18 21:04:37 +02:00
Sam Brannen c26bf871b7 Clean up warnings related to forthcoming removals in Tomcat 9
(cherry picked from commit b521aa8)
2016-09-18 21:04:29 +02:00
Sam Brannen 15d3e8c3e1 Introduce 'value' alias for @Bean's 'name' attribute
In order to simplify configuration for use cases involving @Bean where
only a bean name or aliases are supplied as an attribute, this commit
introduces a new 'value' attribute that is an @AliasFor 'name' in @Bean.

Issue: SPR-14728
(cherry picked from commit 8f62b63)
2016-09-18 21:04:25 +02:00
Brian Clozel 66b370e103 Check template availability in ScriptTemplateView
This commit overrides the `checkResource` implementation in
`ScriptTemplateView` in order to check if the template file resource is
available and if the resolver can then proceed with rendering the
template.

Issue: SPR-14729
Cherry-picked from: 97c9b05c15
2016-09-17 22:30:29 +02:00
Juergen Hoeller 2bbfbb1d50 What's New updated for significant refinements in 4.3.3 2016-09-16 14:31:53 +02:00
Juergen Hoeller ace25d4987 Polishing
(cherry picked from commit ed19dc7)
2016-09-16 14:30:41 +02:00
Juergen Hoeller 59cb9a4e60 Latest dependency updates (EhCache 3.1.2, Caffeine 2.3.3, Rome 1.7, Woodstox 5.0.3, Jettison 1.3.8) 2016-09-16 11:02:22 +02:00
Stephane Nicoll 0dce570157 Add Qualified element on RootBeanDefinition
Improve RootBeanDefinition to specify an AnnotatedElement that holds
qualifier information. When such element is present, any qualifier that
it defines will be used to find a matching candidate.

Issue: SPR-14725
(cherry picked from commit 2b0bf9f)
2016-09-16 11:02:03 +02:00
Juergen Hoeller 7ddaf49eb2 StringUtils.parseLocaleString accepts Java 7 variants
Issue: SPR-14718
(cherry picked from commit f24ce76)
2016-09-16 10:58:51 +02:00
Juergen Hoeller e947363a11 Timeout exceptions as RuntimeExceptions
Issue: SPR-14669
(cherry picked from commit 6dc1898)
2016-09-15 09:05:14 +02:00
Rossen Stoyanchev 5dbfe48d24 Improve async request timeout handling
Rather than setting the status to 503 directly from the timeout
interceptor which no longer seems to work reliably with Servlet
containers like Jetty even performing an additional ERROR dispatch back
to the original URL, we know rather set the DeferredResult to an
AsyncTimeoutException, which results in a dispatch and standard
handling within Spring MVC. This should be a more reliable way of
dealing with timeouts.

Issue: SPR-14669
2016-09-14 21:31:30 -04:00
Rossen Stoyanchev 07d5f8b123 Check both connection and connected flag
Issue: SPR-14703
2016-09-14 17:23:36 -04:00
kosmaty be99603f1b Fix doc style
Closes gh-1172
2016-09-14 11:08:29 +02:00
Juergen Hoeller 54db496815 Polishing
(cherry picked from commit 404e7cd)
2016-09-13 23:43:58 +02:00
Juergen Hoeller fbe7ddb640 PropertySourcesPropertyResolver does not log retrieved value by default
Issue: SPR-14709
2016-09-13 23:43:52 +02:00
Juergen Hoeller 55c37d2a57 Upgrade to Tomcat 8.5.5 2016-09-13 22:34:19 +02:00
Juergen Hoeller 4b445531f5 HibernateExceptionTranslator avoids JPA IllegalState/ArgumentException translation
Issue: SPR-14681
2016-09-13 22:32:57 +02:00
Juergen Hoeller 12afc263a4 HibernateTemplate reflectively calls getNamedQuery (for runtime compatibility with Hibernate 5.0/5.1 vs 5.2)
Issue: SPR-14676
2016-09-13 22:32:36 +02:00
Juergen Hoeller 040d131284 Polishing
(cherry picked from commit ce42ed4)
2016-09-13 22:31:47 +02:00
Juergen Hoeller 73bbe0849a Revised IllegalArgumentException handling for Formatter parse calls
Issue: SPR-14661
(cherry picked from commit c69e6a3)
2016-09-13 22:31:01 +02:00
Juergen Hoeller 09a0615df0 Consistent callbacks for TypeFilters, ImportSelectors and ImportBeanDefinitionRegistrars
Issue: SPR-14686
(cherry picked from commit 0c2e8a6)
2016-09-13 22:30:29 +02:00
Juergen Hoeller 669d5815c9 Configuration class processing uses MetadataReaderFactory for current ResourceLoader
Issue: SPR-14684
(cherry picked from commit 5405c07)
2016-09-13 22:30:12 +02:00
Juergen Hoeller bd24b97bd3 IdentityHashMap for scheduled tasks (avoiding hashCode calls on bean instances)
Issue: SPR-14666
(cherry picked from commit 480cd2c)
2016-09-13 22:29:59 +02:00
Juergen Hoeller db196ce5d8 Correct ISO DateTime example
Issue: SPR-14675
(cherry picked from commit d5c9cc6)
2016-09-13 22:28:28 +02:00
Juergen Hoeller 4396b211ce Avoid outdated Tibco workaround in shouldCommitAfterNoMessageReceived
Issue: SPR-14697
(cherry picked from commit edbc1e9)
2016-09-13 22:28:07 +02:00
Juergen Hoeller 367949e914 PropertyValue stores source object in common superclass field
Issue: SPR-8337
(cherry picked from commit fa820bc)
2016-09-13 22:27:17 +02:00
Juergen Hoeller ae2bbe7f19 MappingJackson2MessageConverter adds message id and destination to type resolution exception
Issue: SPR-14672
(cherry picked from commit 8c56606)
2016-09-13 22:26:37 +02:00
nkjackzhang 819e14f91b Fix typo
There is no attribute named `path` in `@RequestParam`, so I change it to
`name`.

Closes gh-1165
2016-09-10 07:49:48 +02:00
Brian Clozel fcf3ccba98 Fix default encoding in CONTRIBUTING documentation
Sources should be using UTF-8.

Issue: SPR-14674
Cherry-picked from: d1f60e3de1
2016-09-07 10:48:16 +02:00
nkjackzhang 558a10b54f Fix typo
Closes gh-1158
2016-09-07 09:38:00 +02:00
Brian Clozel 43c60a02f7 Fix response status check in ServletWrbRequest
Issue: SPR-14659
2016-09-06 19:13:03 +02:00
Brian Clozel 6501bc5d32 Align MVC checkNotModified with reactive support
Since SPR-14522, the web reactive framework supports checkNotModified
features. This commit aligns the existing MVC infrastructure with
web reactive's behavior.

Code duplication has been removed from `HttpEntityMethodProcessor`
but the Servlet 2.5 baseline is still respected.

Issue: SPR-14659
Cherry-picked from: cc5300c4d5
2016-09-06 18:17:47 +02:00
Brian Clozel f3dae0c9ad Mention AntPathMatcher regexp support
This commit documents the regexp support in `AntPathMatcher` when
matching for URL patterns. This support is also mentioned in places
where developers can register patterns for ViewControllers or resource
handlers.

Issue: SPR-14652
Cherry-picked from: a8ba065a6e
2016-09-02 11:40:11 +02:00
sylvainlaurent dc2cafc888 Fix class literal in instanceof
Closes gh-1151
2016-09-01 16:23:32 +02:00
Juergen Hoeller 49fc4923be Upgrade to JSR-354 API 1.0.1 and Jackson 2.8 javadocs 2016-09-01 12:56:25 +02:00
Juergen Hoeller efb5f17a60 Documentation updates around configuration classes
(cherry picked from commit aff914c)
2016-09-01 12:52:11 +02:00
Juergen Hoeller 086e764845 ResolvableType.java.forRawClass(Class) supports isAssignableFrom(ResolvableType) as well
Issue: SPR-14648
(cherry picked from commit 1a30252)
2016-08-31 14:57:27 +02:00
Juergen Hoeller c30290b43c @PathVariable supports 'required' attribute (for model attribute methods)
Issue: SPR-14646
(cherry picked from commit e08b1b7)
2016-08-31 14:57:21 +02:00
Brian Clozel d26421fe3b Fix missing ResourceHttpRequestHandler init in registry
Issue: SPR-14577
Cherry-picked from: 7a88776329
2016-08-31 10:47:18 +02:00
Juergen Hoeller 37670924f6 Polishing 2016-08-31 01:53:03 +02:00
Juergen Hoeller ee5143b54b Upgrade to Jackson 2.8.2 and Netty 4.1.5 2016-08-31 00:45:34 +02:00
Juergen Hoeller acbb2544bf Polishing
(cherry picked from commit 4ef428d)
2016-08-31 00:45:25 +02:00
Juergen Hoeller d8f7347000 Consistent comma splitting without regex overhead
Issue: SPR-14635
(cherry picked from commit 03609c1)
2016-08-31 00:44:52 +02:00
Juergen Hoeller 3b91dec462 ApplicationListenerMethodAdapter resolves order on construction
Issue: SPR-14642
(cherry picked from commit 58fa63f)
2016-08-31 00:44:43 +02:00
Juergen Hoeller 05f74b4218 CommonsMultipartResolver explicitly converts FileSizeLimitExceededException
Issue: SPR-14638
(cherry picked from commit 58ffca7)
2016-08-31 00:44:19 +02:00
Juergen Hoeller 8e98177fb3 Avoid collection lookups in StompCommand
Issue: SPR-14636
(cherry picked from commit 899ebd8)
2016-08-31 00:44:14 +02:00
Rossen Stoyanchev 815a3ad0de Relax ServletContext check for resource handling
This is a follow-up on commit fe4046 relaxing the expectation that a
ServletContext is present. Instead we check defensively and fall back
on PathExtensionContentNegotiationStrategy which can use JAF.

Issue: SPR-14577
2016-08-30 12:57:35 -04:00
Rossen Stoyanchev 5075dd4dfa Harden synchronization around SockJS heartbeats
Create an explicit heartbeat task with an experiration flag so that
it can be cancelled reliably vs relying on the ScheduledFutureTask
cancel method which may return true even if the task is already
running.

Issue: SPR-14356
2016-08-30 09:20:07 -04:00
Rossen Stoyanchev ca09dcbe89 Polish media type change in ResourceHttpRequestHandler 2016-08-29 19:48:06 -04:00
Rossen Stoyanchev 198a74d793 Support receipt on DISCONNECT with simple broker
Issue: SPR-14568
2016-08-29 18:30:17 -04:00
Rossen Stoyanchev fe404628e9 Fix media type regression in resource handling
Issue: SPR-14577
2016-08-29 16:39:07 -04:00
Juergen Hoeller 5a004c3b2a LiveBeansView exposes aliases as well
Issue: SPR-14632
(cherry picked from commit 57cb7c7)
2016-08-26 20:18:39 +02:00
Juergen Hoeller 430180aa96 Polishing 2016-08-26 18:33:13 +02:00
Juergen Hoeller e828be96f0 Polishing 2016-08-26 17:29:16 +02:00
Juergen Hoeller 52447efb97 Avoid getParameterType use with Oracle 12c driver by default
Issue: SPR-14629
Issue: SPR-14574
Issue: SPR-14191
2016-08-26 17:29:00 +02:00
Rossen Stoyanchev d09b0fe83a Support target type in JsonPath assertions
This change adds support for a target type in JsonPath assertions in
Spring MVC Test.

The existing assertValue(String expression, Object expectedValue)
transparently falls back on using an alternative JsonPath API that
allows specifying the target type to coerce to.

There is also a new overloaded method
assertValue(String expression, Matcher<T> matcher, Class<T> targetType)
for use with Hamcrest matchers where the target type can be specified.

Issue: SPR-14498
(cherry picked from commit 7fdb892)
2016-08-26 17:28:37 +02:00
Brian Clozel 798d8668a4 Fix server errors for invalid If-None-Match request headers
HttpEntityMethodProcessor should not throw IllegalArgumentExceptions for
invalid If-None-Match headers.

For those cases, this commit makes sure that both
`HttpEntityMethodProcessor` and `ServletWebRequest` have a consistent
behavior and stop processing the request as conditional and leave the
handler handle it.

Issue: SPR-14559
2016-08-26 15:33:02 +02:00
Juergen Hoeller 2a82b8fed9 Consistent use of Charset.forName over JDK 7 StandardCharsets in 4.x line 2016-08-26 13:11:39 +02:00
Juergen Hoeller 696f687419 Moved encodeHttpHeaderFieldParam method to HttpHeaders itself (including tests)
This commit also sets the test source encoding to UTF-8.

Issue: SPR-14547
(cherry picked from commit a8f7f75)
2016-08-26 12:55:34 +02:00
Brian Clozel 9b91b9db8c 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
Cherry-picked from: f2faf84f31
2016-08-25 14:39:07 +02:00
Juergen Hoeller 026473280b Polishing 2016-08-25 00:10:06 +02:00
Juergen Hoeller a7849b2861 DefaultListableBeanFactory does not trigger early candidate creation ahead of primary bean selection
Issue: SPR-14611
(cherry picked from commit c4fcdb6)
2016-08-24 23:37:59 +02:00
Juergen Hoeller 74bf659c56 GenericApplicationContext picks up ClassLoader from custom ResourceLoader
Issue: SPR-14626
(cherry picked from commit 405e74b)
2016-08-24 23:36:33 +02:00
Juergen Hoeller c2feedb7a2 Revised assertions in StompHeaderAccessor
Issue: SPR-14625
(cherry picked from commit f3f691c)
2016-08-24 23:36:23 +02:00
Juergen Hoeller 0735e9ba98 Avoid unnecessary String concatenation in StompSubProtocolHandler
Issue: SPR-14624
(cherry picked from commit 56b197b)
2016-08-24 23:36:13 +02:00
Juergen Hoeller ab686732d0 Refined exception message
Issue: SPR-14609
2016-08-24 15:05:43 +02:00
Juergen Hoeller 6d86437369 TransactionAspectSupport stores given PlatformTransactionManager instance as strong reference
Issue: SPR-14609
(cherry picked from commit 951ac5e)
2016-08-24 14:39:19 +02:00
Juergen Hoeller 184285ab27 Polishing 2016-08-24 13:01:54 +02:00
Juergen Hoeller 1e8065d040 Unit test for empty Access-Control-Request-Headers (Chrome 52)
Includes optimized method/header resolution in CorsConfiguration.

Issue: SPR-14617
(cherry picked from commit d047174)
2016-08-24 11:53:44 +02:00
Juergen Hoeller f735d12247 UnsatisfiedDependencyException avoids duplicate nested exception message
Issue: SPR-14607
(cherry picked from commit 93d2287)
2016-08-24 11:53:36 +02:00
Juergen Hoeller 7135bc2dc2 Reintroduced MessageMethodArgumentResolver default constructor
Issue: SPR-14616
(cherry picked from commit c4fff6d)
2016-08-24 11:53:30 +02:00
Stephane Nicoll 9044706796 Remove reference to PayloadApplicationEvent
Issue: SPR-14594
2016-08-19 14:22:52 +02:00
Stephane Nicoll 5f68da3153 Document support for @ManagedBean
Issue: SPR-14600
2016-08-19 13:53:07 +02:00
Juergen Hoeller 5222489a01 Various @since tags (and varargs on setInterceptors)
(cherry picked from commit aac0e63)
2016-08-18 12:40:22 +02:00
Juergen Hoeller 27f830f345 Polishing 2016-08-18 10:28:31 +02:00
Juergen Hoeller 8d7db8e450 DelegatingWebMvcConfiguration properly delegates extendHandlerExceptionResolvers
Also fixes the declared visibility of configurePathMatch and configureAsyncSupport.

Issue: SPR-14599
(cherry picked from commit d2e3a1a)
2016-08-18 09:53:15 +02:00
Juergen Hoeller da56758054 Updated note on CompilationCustomizer and CompilerConfiguration
Issue: SPR-14585
2016-08-17 22:31:13 +02:00
Juergen Hoeller 66dcc4b6db Upgrade to Caffeine 2.3.2 2016-08-17 22:29:21 +02:00
Juergen Hoeller 6eab5622c7 Renamed setDefaultPersistenceUnitRootLocation to setPersistenceUnitRootLocation
(cherry picked from commit f1ab37c)
2016-08-17 22:18:19 +02:00
Juergen Hoeller af53f3d6cf Upgrade to Gradle 2.14.1
Issue: SPR-14570
2016-08-17 21:35:32 +02:00
Juergen Hoeller 188e5327ee Removed duplicate NoHandlerFoundException entry
Issue: SPR-14598
(cherry picked from commit e9f48a4)
2016-08-17 21:30:41 +02:00
Juergen Hoeller 1932a9d729 Polishing
(cherry picked from commit de91b1a)
2016-08-17 21:30:30 +02:00
Juergen Hoeller c926ec477a Polishing 2016-08-17 17:47:14 +02:00
Juergen Hoeller 7b11fa18a1 Revised NoSuchBeanDefinitionException message for proper array class names
Issue: SPR-14595
(cherry picked from commit 022b013)
2016-08-17 17:47:14 +02:00
Juergen Hoeller e6cefdca25 RootBeanDefinition accepts ResolvableType for target type hint
Issue: SPR-14580
(cherry picked from commit 4b06b60)
2016-08-17 17:47:14 +02:00
Juergen Hoeller fbeff475b3 Consistent support for CompilationCustomizers as well as custom CompilerConfiguration
Issue: SPR-14585
(cherry picked from commit 6a0d9d3)
2016-08-17 17:47:14 +02:00
Stephane Nicoll d057099c17 Add setter for defaultPersistenceUnitRootLocation
This commit adds a setter for the default persistence unit's
defaultPersistenceUnitRootLocation attribute.
2016-08-17 17:41:47 +02:00
Stephane Nicoll 411700d7e6 Clarify use of Ehcache
Since we have a dedicated section regarding Ehcache that is only
applicable to Ehcache 2.x, this commit clarifies that Ehcache 3.x is
JSR-107 compliant and the JCache support should be used with it
rather than attempting to configure the Ehcache 2.x support.
2016-08-16 14:03:26 +02:00
Stephane Nicoll b4e9d918f2 Better document #result semantic
Commit 240f254 has introduced support for `java.util.Optional` in the
cache abstraction. If such type is present, the contained value is cached
if it is present.

This new feature slightly changed the semantic of `#result` that was
documented up till this commit as the "return value of the method
invocation". This is no longer true as `#result` for `Optional<T>`
refers to the `T` instance and not the `Optional` instance.

This commit clarifies both the javadoc and the documentation.

Issue: SPR-14587
2016-08-16 13:45:46 +02:00
Igor Mukhin 2756c364d2 Add aditional example to CronSequenceGenerator
CronSequenceGenerator supports comma separated expressions but does not
provide an example for it. This commit adds such an example.

Closes gh-1132
2016-08-16 11:43:15 +02:00
Rob Winch 43faabd4cc Fix HtmlUnitRequestBuilder merge
Previously invoking HtmlUnitRequestBuilder merge caused the pathInfo of
the parent to be corrupted. This could additional invocations with the
same parent.

This fix ensures that the parent is no longer directly used. Instead,
we create a copy of the parent by merging the parent that was passed in
with the copy.

Fixes SPR-14584
2016-08-12 20:49:48 -05:00
Juergen Hoeller a4a71a8904 Polishing 2016-08-11 23:45:50 +02:00
Juergen Hoeller e23ac031ff Avoid stack overflow in case of chained factory-bean references to FactoryBean class
Issue: SPR-14551
(cherry picked from commit 8b5d355)
2016-08-11 23:25:41 +02:00
Juergen Hoeller 79a56967a1 PersistenceAnnotationBeanPostProcessor obtains default EntityManagerFactory via getBean(Class) algorithm
Issue: SPR-7549
(cherry picked from commit 6157fad)
2016-08-11 23:25:35 +02:00
Juergen Hoeller 0bc0453700 Polishing 2016-08-10 16:59:22 +02:00
Juergen Hoeller 35e247aa26 Polishing 2016-08-10 16:21:35 +02:00
Juergen Hoeller 67ba187b6f Polishing
(cherry picked from commit 59a24b4)
2016-08-10 14:57:50 +02:00
Juergen Hoeller 67f0b1986c Consistent spelling for StandaloneMockMvcBuilder's addPlaceholderValue
(cherry picked from commit a4b6682)
2016-08-10 14:57:43 +02:00
Stephane Nicoll 60e0177d00 Fix typo
See gh-1129
2016-08-10 10:46:43 +02:00
Juergen Hoeller 4543a28e51 MethodBasedEvaluationContext reliably exposes varargs
Issue: SPR-14554
(cherry picked from commit fae503d)
2016-08-09 21:31:29 +02:00
Juergen Hoeller aade2d1ec9 Polishing
(cherry picked from commit 9475c06)
2016-08-09 12:37:07 +02:00
Juergen Hoeller 4627545a3b Polishing
(cherry picked from commit eae079a)
2016-08-09 11:03:51 +02:00
Juergen Hoeller e2ba7c9b8c MockClientHttpResponse closes body stream on close()
Issue: SPR-14563
(cherry picked from commit 47e9360)
2016-08-09 11:03:46 +02:00
Juergen Hoeller 6f5596ac5c Upgrade to Hibernate ORM 5.2.2 and Undertow 1.3.24 2016-08-08 16:07:34 +02:00
Juergen Hoeller 7d1c2f191a Consistent default connection release mode with Hibernate 5.1
Issue: SPR-14548
2016-08-08 14:27:24 +02:00
Juergen Hoeller 4ada571384 PathEditor tries file system path in case of non-existing resource
Issue: SPR-14549
(cherry picked from commit d69afaa)
2016-08-08 14:22:46 +02:00
Juergen Hoeller ad8ebbaa05 Test injection for @Lookup-declaring bean
Issue: SPR-14550
(cherry picked from commit d128830)
2016-08-08 14:22:42 +02:00
Stephane Nicoll 4854989db4 Polish Javadoc
Issue: SPR-14552
2016-08-06 17:17:25 +02:00
Sebastien Deleuze 7c5050cf80 Prevent StackOverflowError in AbstractJackson2HttpMessageConverter
Issue: SPR-14520
2016-08-04 11:28:20 -07:00
Spring Buildmaster 14ae8be547 Next Development Version 2016-07-28 08:26:01 +00:00
Juergen Hoeller ff878ea9dc ConfigurationClassParser uses unified ImportStack with chained import analysis
Issue: SPR-14517
(cherry picked from commit d96a66a)
2016-07-28 00:13:05 +02:00
Juergen Hoeller 7021a4be44 JndiPropertySource defensively skips invalid JNDI lookup for property name with colon in resource-ref mode
Issue: SPR-14518
(cherry picked from commit 328e04f)
2016-07-28 00:12:50 +02:00
Juergen Hoeller 5c4737c3d0 Upgrade to Netty 4.1.4 2016-07-27 16:49:37 +02:00
Juergen Hoeller fbf3807af1 Polishing
(cherry picked from commit 5db4495)
2016-07-27 16:49:18 +02:00
Juergen Hoeller 703c37ec88 Isolated circular import detection for scanned configuration classes
Issue: SPR-14517
(cherry picked from commit 316244d)
2016-07-27 16:49:04 +02:00
Juergen Hoeller 96440878bb Polishing 2016-07-27 13:00:30 +02:00
Juergen Hoeller b5c11ffb1c Expose DefaultSubscriptionRegistry's cache limit through SimpleBrokerMessageHandler and MessageBrokerRegistry
Issue: SPR-14516
(cherry picked from commit 6d5af60)
2016-07-27 12:34:28 +02:00
Juergen Hoeller 7f5b323d50 Upgrade to Jetty 9.3.11 (includes fixed Quartz javadoc URL) 2016-07-26 22:19:56 +02:00
Juergen Hoeller 67176e2b75 TransactionAspectSupport avoids hard references to transaction manager beans
Issue: SPR-14511
(cherry picked from commit 02374d7)
2016-07-26 21:46:49 +02:00
Juergen Hoeller 79f3cf3263 Build against Undertow 1.3.x in 4.3.x branch (retaining runtime compatibility Undertow 1.4)
Issue: SPR-14328
2016-07-26 10:08:06 +02:00
Juergen Hoeller 9ee1dc79fd Deprecate JpaSystemException(PersistenceException) constructor to prepare for removal in Spring 5
Issue: SPR-13827
2016-07-26 01:29:51 +02:00
Juergen Hoeller 9e2c34dfa6 Fixed ConcurrentMap declaration
(cherry picked from commit 23135b1)
2016-07-26 00:28:40 +02:00
Juergen Hoeller cc93c2a559 Polishing 2016-07-26 00:03:21 +02:00
Juergen Hoeller 15c7044c4d Upgrade to EhCache 3.1.1 and OkHttp 3.4.1 2016-07-25 15:20:08 +02:00
Juergen Hoeller 0ef80d3579 JasperReportsMultiFormatViewTests does not check for CUSTOM_COMPILATION anymore
Issue: SPR-10423
2016-07-25 15:19:50 +02:00
Juergen Hoeller 95c2e0a996 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
(cherry picked from commit 01110f6)
2016-07-25 14:58:43 +02:00
Juergen Hoeller da3e8611e1 Upgrade JiBX (and BCEL) towards support of 1.8 bytecode level
Issue: SPR-10423
2016-07-25 13:08:46 +02:00
Juergen Hoeller 64595597f3 LinkedCaseInsensitiveMap properly overrides HashMap.clone()
Issue: SPR-14509
(cherry picked from commit dd65f7a)
2016-07-25 12:14:51 +02:00
Juergen Hoeller 82f2983cd4 Consistent throwing of BeanNotOfRequiredTypeException even for existing proxy
Issue: SPR-14504
(cherry picked from commit 4a85309)
2016-07-24 15:47:06 +02:00
Juergen Hoeller 9451177c35 Polishing
(cherry picked from commit 382a931)
2016-07-22 22:45:14 +02:00
Juergen Hoeller 9ed087d5da Consistent support for multiple Accept headers
Issue: SPR-14506
(cherry picked from commit e59a599)
2016-07-22 22:45:04 +02:00
Juergen Hoeller 77f22e9674 DataSource adapters expose setCatalog/setSchema next to setUsername/setPassword
Issue: SPR-14501
(cherry picked from commit 610bdf1)
2016-07-21 14:13:37 +02:00
Juergen Hoeller 8ccfdbbcf9 ResourcePatternUtils.getResourcePatternResolver actually accepts null argument
Issue: SPR-14500
(cherry picked from commit e756a5b)
2016-07-21 14:09:32 +02:00
Juergen Hoeller 5a92aa4e06 Polishing
(cherry picked from commit a39276a)
2016-07-20 23:23:30 +02:00
Juergen Hoeller 7b1010cf61 Polishing 2016-07-20 22:31:45 +02:00
Juergen Hoeller 45b2f5bac4 Upgrade to Jackson 2.8.1 2016-07-20 22:31:25 +02:00
Juergen Hoeller 36e1c82ef5 Backported refinements and polishing 2016-07-20 21:46:25 +02:00
Juergen Hoeller 503d65d570 Avoid JDK proxy against CGLIB Factory interface and assert required type when resolving dependency
Issue: SPR-14478
(cherry picked from commit 0e3f0bd)
2016-07-20 21:45:41 +02:00
Juergen Hoeller fe17f8da41 BeanWrapperImpl.setBeanInstance correctly exposes root object
Issue: SPR-14474
(cherry picked from commit 938b56c)
2016-07-20 21:44:46 +02:00
Juergen Hoeller b583aa1579 Avoid dependency on WebUtils for extracting file extension
Issue: SPR-14479
(cherry picked from commit adc595b)
2016-07-20 21:44:37 +02:00
Juergen Hoeller e0d81b97bb SerializableTypeWrapper reobtains type accessors from declaring interface
Issue: SPR-14487
(cherry picked from commit 8580483)
2016-07-20 21:41:42 +02:00
Juergen Hoeller 90752f9d87 Deprecate mock.staticmock package
Issue: SPR-14485
2016-07-20 21:41:30 +02:00
Juergen Hoeller 3663aa675a GenericSqlQuery configured with RowMapper instance
Issue: SPR-14489
(cherry picked from commit 7287bae)
2016-07-20 21:40:48 +02:00
Juergen Hoeller 1ca4b81856 Reinstated tests for implicit aliases
Issue: SPR-14437
(cherry picked from commit 5ea8c26)
2016-07-20 21:40:33 +02:00
Juergen Hoeller 4e7e06f549 Reliably pass CurrentTenantIdentifierResolver to SessionFactory
Issue: SPR-14476
2016-07-20 21:40:26 +02:00
Sebastien Deleuze b2f0bdb0f4 Polishing
Issue: SPR-14470
2016-07-20 09:16:50 +02:00
Rossen Stoyanchev d98bd34200 Remove isAsyncStarted assertion
Issue: SPR-14444
2016-07-19 16:44:46 -04:00
Sebastien Deleuze 940bdd878e Fix ParameterizedType + contextClass support in Jackson converter
Issue: SPR-14470
2016-07-19 18:10:51 +02:00
Vladimir L df556333a8 Add StreamingResponseBody MockMvc sample tests
Issue: SPR-14456
(cherry picked from 7da63c)
2016-07-19 10:48:29 -04:00
Stephane Nicoll 116f05eda6 Revert "Upgrade to EJB 3.1" 2016-07-18 13:37:43 +02:00
Stephane Nicoll b187bbeca3 Upgrade to EJB 3.1 2016-07-18 13:22:54 +02:00
Do Nhu Vy 479a83b628 Fix broken hyperlink
Closes gh-1114
2016-07-18 08:17:49 +02:00
Fredrik Sundberg 1c18100143 Fix javadoc reference
Method is called nextBackOff() and not nextBackOffMillis().

Closes gh-1115
2016-07-18 08:15:41 +02:00
Juergen Hoeller 5d3c0f33f6 Upgrade to Netty 4.1.3 and Tomcat 8.5.4 2016-07-15 22:47:22 +02:00
Juergen Hoeller afe106e254 Polishing 2016-07-15 22:47:12 +02:00
Juergen Hoeller 69dd40ec89 Javadoc fixes and pruning of deprecated references 2016-07-15 22:47:05 +02:00
Sam Brannen dee50d5e28 Polish annotation utils
(cherry picked from commit 177f4ec)
2016-07-15 22:21:23 +02:00
Juergen Hoeller 9e93403857 ConfigurationClassParser load annotations through source class loader
Issue: SPR-10343
2016-07-15 16:02:06 +02:00
Juergen Hoeller 12bff6b3a0 Velocity deprecation note in reference documentation
Issue: SPR-14460
2016-07-15 15:44:13 +02:00
Juergen Hoeller 70e666b4a3 MultipartResolutionDelegate's resolveMultipartArgument properly operates on Servlet 2.5
Issue: SPR-14461
2016-07-15 15:42:32 +02:00
Juergen Hoeller 29f980ec72 Unwrap JPA PersistenceException on flush failure (for Hibernate 5.2)
Issue: SPR-14457
2016-07-15 15:40:38 +02:00
Juergen Hoeller 1d39d762f0 HibernateExceptionTranslator converts JPA exceptions as well (for Hibernate 5.2)
Issue: SPR-14455
2016-07-15 15:40:26 +02:00
Juergen Hoeller 4d6d5e0ddd Consistent alias processing behind AnnotatedTypeMetadata abstraction (also for ASM)
Issue: SPR-14427
(cherry picked from commit 3d3407c)
2016-07-15 15:40:01 +02:00
Juergen Hoeller 4ea5f070a4 MessageHeaderAccessor properly removes header even in case of null value
Issue: SPR-14468
(cherry picked from commit b166358)
2016-07-15 15:39:33 +02:00
Juergen Hoeller da59b4da9b CronSequenceGenerator prevents stack overflow in case of inverted range
Issue: SPR-14462
(cherry picked from commit e431624)
2016-07-15 15:39:17 +02:00
Juergen Hoeller 0065a160cc StandardTypeConverter initializes default ConversionService against volatile field
Issue: SPR-14465
(cherry picked from commit 6d91d54)
2016-07-15 15:39:09 +02:00
Juergen Hoeller 52f46c7fea Aspect actually applies in PersistenceExceptionTranslationPostProcessorTests
Issue: SPR-14457
(cherry picked from commit 04e9c2b)
2016-07-15 15:38:44 +02:00
Juergen Hoeller f0a826ec0c AbstractHandlerMethodMapping adds type+method info to getMappingForMethod exceptions
Issue: SPR-14452
(cherry picked from commit 8ccd727)
2016-07-15 15:38:23 +02:00
Juergen Hoeller 5c3c0f73c1 Configurable UrlPathHelper in PathExtensionContentNegotiationStrategy
This commit also aligns ResourceUrlProvider's and RequestMappingInfo's UrlPathHelper setter/getter signatures.

Issue: SPR-14454
(cherry picked from commit 84afc60)
2016-07-15 15:37:56 +02:00
Juergen Hoeller be0b71ce31 Fixed typo: "occured"->"occurred"
(cherry picked from commit c43e749)
2016-07-15 15:37:11 +02:00
Juergen Hoeller f85d48dd31 Added PathEditor for NIO file system resolution
Issue: SPR-14436
(cherry picked from commit 23c2b6a)
2016-07-15 15:37:02 +02:00
Juergen Hoeller a1b58ee601 DigestUtils processes InputStream with buffered read instead of full copy
Issue: SPR-14427
(cherry picked from commit 61db8e9)
2016-07-15 15:34:36 +02:00
Juergen Hoeller e30429051d Polishing
(cherry picked from commit 6aa5931)
2016-07-15 15:34:27 +02:00
fisache 942ead75e2 Polish doc
Closes gh-1108
2016-07-14 19:16:20 +02:00
nkjackzhang 453688f6df Polish doc
Closes gh-1110
2016-07-14 11:57:41 +02:00
Stephane Nicoll 7d7a161102 Polish contribution
Closes gh-1070
2016-07-14 11:26:31 +02:00
spodgurskiy aaa223ae66 Fix MethodBasedEvaluationContext.lazyLoadArguments
This commit fix a potential `ArrayIndexOutOfBoundsException` if
`lazyLoadArguments` is called with an empty variable argument.

See gh-1070
2016-07-14 11:26:20 +02:00
Brian Clozel d11c624fb0 Polish AntPathMatcher.setTrimTokens javadoc
Issue: SPR-14247
Cherry-picked from 147a35f
2016-07-12 14:50:00 +02:00
nkjackzhang 275e51b19d Polish doc
Closes gh-1107
2016-07-12 08:51:35 +02:00
Stephane Nicoll ab62edeeaa Fix NoOpCache handling of get(key,callable)
This commit fixes the method that takes a Callable to actually always
invoke it rather than returning null.

Issue: SPR-14445
2016-07-11 10:36:51 +02:00
Sam Brannen 813108a928 Ensure TestContextManager always tracks after-class exception
This commit fixes a minor bug introduced in 0adc4921ed.

Issue: SPR-14447
2016-07-10 16:00:30 +02:00
Juergen Hoeller 3c14911401 Polishing 2016-07-06 17:59:49 +02:00
Juergen Hoeller 4337f14627 Upgrade to Jackson 2.8 GA 2016-07-06 17:42:10 +02:00
Juergen Hoeller 92d78c10a2 Polishing (backported from master) 2016-07-06 17:13:18 +02:00
Juergen Hoeller 16d5ba9b3a Restored binary compatibility with Hibernate 5.0/5.1's Query type
Issue: SPR-14425
2016-07-06 16:11:15 +02:00
Juergen Hoeller 52065a736b Avoid canonicalName call for already-seen bean name
Issue: SPR-14433
(cherry picked from commit 5890758)
2016-07-06 16:09:32 +02:00
Stephane Nicoll 11cb109114 Upgrade copyright 2016-07-04 12:45:34 +02:00
Stephane Nicoll d7eadd41d6 Switch to 4.3.2.BUILD-SNAPSHOT 2016-07-04 12:28:13 +02:00
Juergen Hoeller 080dcad218 Add missing package-info file for new test.context.web.socket package
Issue: SPR-14420
2016-07-02 15:46:21 +02:00
Juergen Hoeller a6e4b64c23 PropertySourcesPropertyResolver provides logKeyFound template method
Issue: SPR-14370
2016-07-02 15:43:40 +02:00
Juergen Hoeller f6334fc62b Aligned default Map capacity 2016-07-02 15:17:34 +02:00
Juergen Hoeller c6752e6023 Explicit note on self references
Issue: SPR-14402
2016-07-02 14:58:54 +02:00
Juergen Hoeller b204437cef Polishing 2016-07-02 14:48:15 +02:00
Juergen Hoeller e5122d084a Avoid wrapping in plain RuntimeException in favor of IllegalStateException 2016-07-02 13:03:33 +02:00
Juergen Hoeller e7a53e37fb Avoid stateful MethodParameter nesting level changes in MVC processing 2016-07-02 13:02:22 +02:00
Juergen Hoeller e5de7d5455 @MessageExceptionHandler matches cause as well (analogous to @ExceptionHandler)
Issue: SPR-14424
2016-07-02 12:56:37 +02:00
Juergen Hoeller cfc560c4c4 Leniently accept custom DeferredResult etc subclasses for null values
Issue: SPR-14423
2016-07-02 12:55:30 +02:00
Juergen Hoeller 498d896ef0 Upgrade to WebJars Locator 0.32 2016-07-01 15:16:19 +02:00
Stephane Nicoll 037746da44 Polish
Closes gh-1097
2016-07-01 14:26:48 +02:00
Juergen Hoeller d7184d1ad8 Latest dependency updates (HttpAsyncClient 4.1.2, HtmlUnit 2.22, Selenium 2.53.1, JOpt Simple 5.0.2) 2016-07-01 14:12:46 +02:00
Juergen Hoeller 1c73664c40 Defensively access deprecated AbstractHttpClient class from Apache HttpComponents
Issue: SPR-14422
2016-07-01 14:11:26 +02:00
Sam Brannen 8389e3fc35 Suppress warnings in Gradle build 2016-07-01 13:08:39 +02:00
Juergen Hoeller a530a1c7f2 Upgrade to Hibernate ORM 5.2.1
Issue: SPR-14327
2016-07-01 12:57:24 +02:00
Stephane Nicoll 716273df47 Polish
Closes gh-967
2016-07-01 11:15:32 +02:00
Stephane Nicoll 49d78b4835 Merge pull request #1089 from nkjackzhang:patch-2
* pr/1089:
  Polish
  Fix typo in asciidoc
2016-07-01 11:00:08 +02:00
Stephane Nicoll cac58738c9 Polish
Closes gh-1089
2016-07-01 10:58:15 +02:00
nkjackzhang 66fd86be33 Fix typo in asciidoc
See gh-1089
2016-07-01 10:47:06 +02:00
Stephane Nicoll d9993243b6 Polish
Closes gh-1096
2016-07-01 10:43:54 +02:00
Stephane Nicoll d35709dfbc Merge pull request #1095 from nkjackzhang:patch-4
* pr/1095:
  Polish contribution
  Fix typo in javadoc
2016-07-01 10:41:07 +02:00
Stephane Nicoll 2b822d5053 Polish contribution
Closes gh-1095
2016-07-01 10:40:54 +02:00
nkjackzhang 60123b6ca3 Fix typo in javadoc
See gh-1095
2016-07-01 10:40:15 +02:00
Juergen Hoeller 5c6f57ba78 Upgrade to EhCache 3.1 and Jetty 9.3.10 2016-06-30 22:25:18 +02:00
Juergen Hoeller dda0942c78 Polishing 2016-06-30 21:39:51 +02:00
Juergen Hoeller 66ec1c1618 Add missing package-info files for common packages
Issue: SPR-14420
2016-06-30 21:39:06 +02:00
Rossen Stoyanchev 9c29ed75f8 Suppress OPTIONS handling for an ERROR dispatch
Issue: SPR-14410
2016-06-30 12:34:54 -04:00
Juergen Hoeller 16949941f8 MatchableHandlerMapping extends HandlerMapping and lives in web.servlet.handler now
Issue: SPR-14321
2016-06-30 14:38:26 +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
Rossen Stoyanchev 89396ff01f Refactor handleNoMatch for @RequestMapping
Originally handleNoMatch looked for partial matches based on URL
pattern, HTTP method, consumes, produces, and params in that order
but without narrowing down the set of partial matches resulting in
potentially inaccruate response status codes

Commit 473de0 added an improvement to narrow the set with partial
matches for URL pattern and HTTP method matches.

This commit overhauls handleNoMatch so that the narrowing down of
matches happens at each stage resulting in more accurate error
reporting for request mappings with fine-grained conditions.

Issue: SPR-14397
2016-06-29 15:59:00 -04:00
Stephane Nicoll eba873067c Better hide lazy resolution of JMS payloads
This commit fixes MessagingMessageConverter to no longer expose the lazy
message resolution algorithm. This restores proper behaviour for
converters used outside of that context.

Instead, such arrangement is now private to
AbstractAdaptableMessageListener (as it should).

Issue: SPR-14389
2016-06-29 18:10:34 +02:00
Juergen Hoeller 2d5496df2b Polishing 2016-06-29 15:53:46 +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 37e42e68e8 Refined AspectJ caching tests
Issue: SPR-14413
2016-06-29 10:43:54 +02:00
Juergen Hoeller 772bc030ee BasicAuthorizationInterceptor belongs to http.client.support
Issue: SPR-14412
2016-06-29 10:41:18 +02:00
Stephane Nicoll 6cd85ddde7 Align caching AspectJ configuration
The `CacheResolver` and `ErrorHandler` features introduced in 4.1 were
not properly enabled in AspectJ mode. This commit adds more tests from
the regular proxy-based mode and align the AspectJ caching configuration.

Issue: SPR-14413
2016-06-29 09:21:59 +02:00
Rossen Stoyanchev 775ffbe10b Improve static resource path check 2016-06-28 16:46:51 -04:00
Sam Brannen 1a7c6d3b10 Update @since tags in HandlerMappingIntrospector & Co. 2016-06-28 19:04:03 +02:00
Stephane Nicoll db963bc556 Add BasicAuthorizationInterceptor
This commit adds a `ClientHttpRequestInterceptor` that applies a BASIC
authorization header for each request.

It can be used as follows:

```
BasicAuthorizationInterceptor basicAuthorization =
    new BasicAuthorizationInterceptor("user", "secret");
restTemplate.getInterceptors().add(basicAuthorization);
```

Issue: SPR-14412
2016-06-28 17:29:04 +02:00
Sebastien Deleuze 64628dc8cb Add CorsFilter documentation 2016-06-28 14:51:09 +02:00
Stephane Nicoll 52387cac9a Merge pull request #1092 from nkjackzhang:patch-3
* pr/1092:
  Fix typo in asciidoc
2016-06-28 11:21:16 +02:00
nkjackzhang 5657283071 Fix typo in asciidoc
Closes gh-1092
2016-06-28 11:20:50 +02:00
Rossen Stoyanchev ebdc770ed3 Use appropriate message id header for STOMP 1.1 vs 1.2
Issue: SPR-14391
2016-06-27 16:12:59 -04:00
Rossen Stoyanchev 2cdcf752ba MvcUriComponentsBuilder respects optional params
Issue: SPR-14405
2016-06-27 16:02:54 -04:00
Rossen Stoyanchev e38623df87 Fix MediaType lookup for ResourceHttpRequestHandler
As of 4.3 ResourceHttpRequestHandler delegates to the configured
ContentNegotiationManager, or one created internally, to look up
the media type for are resource.

This commit ensures the internally created ContentNegotiationManager is
correctly injected with the ServletContext through which it can perform
lookups as before.

Also the ServletPathContentNegotiationStrategy now checks the
ServletContext first and then delegates to its parent the
PathContentNegotiationStrategy and not vice versa. This is
consistent with how handleNoMatch (also in the same class) works
and also matches how ResourceHttpRequestHandler worked before 4.3.

Issue: SPR-14368
2016-06-27 14:56:55 -04:00
Rossen Stoyanchev a30ab30e4e Introduce HandlerMapping introspection API
Issue: SPR-14321
2016-06-27 14:23:02 -04:00
Brian Clozel a25c43f695 Enforce UTF-8 response encoding in SseEmitter
This commit sets the response content type to
"text/event-stream;charset=UTF-8". Even if the SSE spec says that the
encoding should always be UTF-8 and that specifying the charset is
optional, we're setting it in all cases, since some containers might use
the default encoding "ISO-8859-1" and confuse HTTP clients.

Issue: SPR-14407
2016-06-27 17:05:31 +02:00
Juergen Hoeller 15c96b8efd ServletResponseHttpHeaders consistently overrides HttpHeaders again
Issue: SPR-14406
2016-06-27 15:33:53 +02:00
Juergen Hoeller ea5baeb05a Upgrade to CGLIB 3.2.4
Issue: SPR-14385
2016-06-26 21:03:05 +02:00
Juergen Hoeller e15f7efff8 InjectionPoint propagated for shortcut bean name resolution as well
Issue: SPR-14400
2016-06-26 00:18:54 +02:00
Juergen Hoeller 4102c62734 Fixed ambiguous sentence in conditional cache documentation
Issue: SPR-14399
2016-06-26 00:13:53 +02:00
Juergen Hoeller 351a729317 Explicit javadoc reference to Hibernate 5.2
Issue: SPR-14393
2016-06-24 12:55:58 +02:00
Juergen Hoeller 711eb99812 HibernateJpaVendorAdapter and LocalSessionFactoryBuilder enforce Hibernate 5.2's connection handling mode DELAYED_ACQUISITION_AND_HOLD
Issue: SPR-14393
2016-06-24 12:37:31 +02:00
Juergen Hoeller 5e08598a2a HibernateJpaDialect accepts equivalent connection for proper reset as well
Issue: SPR-14393
2016-06-23 18:24:09 +02:00
Juergen Hoeller f5282bc1e3 PayloadArgumentResolver's MessageConversionException includes original payload type
Issue: SPR-14394
2016-06-23 17:32:30 +02:00
Brian Clozel 0345d734e6 Improve exception logging in HandlerExceptionResolvers
This commit updates AbstractHandlerExceptionResolver to only log at the
WARN level exceptions that are actually resolved by the
ExceptionResolver.

In case developers wish to log each time an ExceptionResolver is called,
a DEBUG level log is still available.

Issue: SPR-14392
2016-06-23 14:12:37 +02:00
Sam Brannen 3dbf25e018 Implement equals() & hashCode() in MockServerContainerContextCustomizer
Issue: SPR-14367
2016-06-23 13:22:10 +02:00
Sam Brannen f7dd757593 Support WebSocket ServletServerContainerFB in the TCF
Prior to this commit, any attempt to include a bean of type
ServletServerContainerFactoryBean in the WebApplicationContext for an
integration test class annotated with @WebAppConfiguration in
conjunction the Spring TestContext Framework (TCF) would have resulted
in an IllegalStateException stating that "A ServletContext is required
to access the javax.websocket.server.ServerContainer instance."

In such scenarios, the MockServletContext was in fact present in the
WebApplicationContext; however there was no WebSocket ServerContainer
stored in the ServletContext.

This commit addresses this issue by introducing the following.

- MockServerContainer: a private mock implementation of the
  javax.websocket.server.ServerContainer interface.

- MockServerContainerContextCustomizer: a ContextCustomizer that
  instantiates a new MockServerContainer and stores it in the
  ServletContext under the attribute named
  "javax.websocket.server.ServerContainer".

- MockServerContainerContextCustomizerFactory: a
  ContextCustomizerFactory which creates a
  MockServerContainerContextCustomizer if WebSocket support is present
  in the classpath and the test class is annotated with
  @WebAppConfiguration. This factory is registered by default via the
  spring.factories mechanism.

Issue: SPR-14367
2016-06-22 22:10:16 +02:00
Sam Brannen 7f16bdaf74 Polish error messages in ServletServerContainerFactoryBean
Issue: SPR-14367
2016-06-22 19:30:23 +02:00
Juergen Hoeller fd9d518c36 Avoid potential deadlock in AbstractBeanFactoryPointcutAdvisor
Issue: SPR-14388
2016-06-22 14:41:20 +02:00
Juergen Hoeller a2aa82eb31 Polishing 2016-06-22 11:55:33 +02:00
Juergen Hoeller 981d4494c6 AspectJWeavingEnabler registered with well-defined bean name (and therefore once only)
Issue: SPR-14373
2016-06-22 11:55:24 +02:00
Juergen Hoeller 0de85e3a73 Upgrade to Undertow 1.4 CR2
Issue: SPR-14328
2016-06-22 11:15:24 +02:00
Rossen Stoyanchev 058279bc7e HEAD mapping has higher priority over other conditions
When comparing multiple matching @RequestMapping's, the HTTP method
condition has the lowest precedence. It's mainly about ensuring an
explicit mapping wins over an implicit (i.e. no method) one.

As of 4.3 HTTP HEAD is handled automatically for controller methods
that match to GET. However an explicit mapping HTTP HEAD allows an
application to take control.

This commit ensures that for HTTP HEAD requests the HTTP method
condition is checked first which means that an explicit HEAD mapping
now trumps all other conditions.

Normally we look for the most specific matching @RequestMapping.
For HTTP HEAD we now look for the most specific match among
@RequestMapping methods with a HEAD mapping first.

Issue: SPR-14383
2016-06-21 13:32:40 -04:00
Rossen Stoyanchev db1092f119 Polish RequestMappingInfoTests 2016-06-21 10:43:08 -04:00
Juergen Hoeller 848562d68a Upgrade to CGLIB 3.2.3
Issue: SPR-14385
2016-06-21 10:13:42 +02:00
Juergen Hoeller 56db1af11d No tomcat-embed-logging-juli on Tomcat 8.5.3 anymore 2016-06-20 14:24:16 +02:00
Juergen Hoeller 8cb9d5ebae EnableAspectJAutoProxy features exposeProxy flag (analogous to XML namespace)
Issue: SPR-10454
2016-06-20 13:50:04 +02:00
Juergen Hoeller 01f115869b Bootstrap SessionFactory implements InfrastructureProxy interface for resource key unwrapping
Issue: SPR-14379
2016-06-20 13:42:42 +02:00
Juergen Hoeller f9fec73f1d Latest dependency updates (Gson 2.7, Jackson 2.8 RC2, Tomcat 8.5.3, Caffeine 2.3.1) 2016-06-20 13:41:04 +02:00
Rossen Stoyanchev ba885f3d0b Add heartbeat lock to SockJS server sessions
Even before this change SockJS sessions always cancelled the heartbeat
task first prior to sending messages. However when the heartbeat task
is already in progress, cancellation of it is not enough and we must
wait until the heartbeat is sent.

This commit adds a heartbeat write lock which is obtained and held
during the sending of a heartbeat. Now when sessions send a message
they still cancel the heartbeat task but if that fails they also wait
for the heartbeat write lock.

Issue: SPR-14356
2016-06-17 16:54:54 -04:00
Rossen Stoyanchev 919f6c96f9 ForwardedHeaderFilter is case-insensitive
Issue: SPR-14372
2016-06-17 14:20:42 -04:00
nkjackzhang 981a748dcc Fix ambiguous static import in TestPropertySourceUtilsTests 2016-06-17 17:18:36 +02:00
Stephane Nicoll 6f9fb31bf9 Merge pull request #1082 from nkjackzhang:patch-2
* pr/1082:
  Move <a> out of @code
2016-06-17 08:08:02 +02:00
nkjackzhang c145ceebf3 Move <a> out of @code
Closes gh-1082
2016-06-17 08:06:21 +02:00
Stephane Nicoll bcfc09a93c Document sync attribute of Cacheable
Closes gh-14366
2016-06-16 13:14:53 +02:00
Stephane Nicoll b92576d8d9 Merge pull request #1080 from nkjackzhang:patch-2
* pr/1080:
  Polish contribution
  Fix typo in javadoc
2016-06-16 12:13:01 +02:00
Stephane Nicoll d41178c75a Polish contribution
Closes gh-1080
2016-06-16 12:12:42 +02:00
nkjackzhang 9656015d26 Fix typo in javadoc
See gh-1080
2016-06-16 12:11:14 +02:00
Juergen Hoeller 7d39957ec9 SessionFactoryUtils defensively accesses getProperties method via reflection
Issue: SPR-14365
2016-06-15 16:48:34 +02:00
Sam Brannen 9001af7efb Revert build to Gradle 2.13
Issue: SPR-14362
2016-06-15 13:00:40 +02:00
Juergen Hoeller b5364d5f1a SpringSessionSynchronization uses SessionFactoryUtils.getFlushMode for Hibernate 5.1/5.2 adaptation
Issue: SPR-14364
2016-06-14 22:55:31 +02:00
Juergen Hoeller dcb2c73102 MultipartResolutionDelegate skips Part parameter checks on Servlet 2.5
Issue: SPR-14358
2016-06-14 22:48:51 +02:00
Sam Brannen 045ee52232 Invoke target.toString() safely in ReflectionTestUtils
ReflectionTestUtils invokes toString() on target objects in order to
build exception and logging messages, and prior to this commit problems
could occur if the invocation of toString() threw an exception.

This commit addresses this issue by ensuring that all invocations of
toString() on target objects within ReflectionTestUtils are performed
safely within try-catch blocks.

Issue: SPR-14363
2016-06-14 20:08:26 +02:00
Sam Brannen 2fd4462268 Upgrade build to Gradle 2.14
In the process of upgrading the build to use Gradle 2.14, the
setFieldOnLegacyEntityWithSideEffectsInToString() test method in
ReflectionTestUtilsTests began to fail. The reason is that the log
level for ReflectionTestUtils is now DEBUG by default with Gradle 2.14.
The apparent cause is that log4j was present on the test runtime
classpath for the spring-test module with all previous versions of
Gradle (via a transitive optional dependency from another project that
spring-test depends on). Thus the configuration in log4j.properties in
spring-test was previously honored, but with Gradle 2.14 a different
commons logging implementation is picked up.

Thus, in addition to upgrading the build to Gradle 2.14, this commit
introduces an explicit test runtime dependency on log4j in the
spring-test module.

The discovered bug in ReflectionTestUtils regarding DEBUG log level
will be addressed separately.

Issue: SPR-14362
2016-06-14 18:40:01 +02:00
Sam Brannen 0815560c85 Migrate to Asciidoctor 1.5 syntax
Issue: SPR-14355
2016-06-11 12:51:38 +02:00
Spring Buildmaster d60028caf1 Next Development Version 2016-06-10 08:59:53 +00: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
Sam Brannen 57ca8f5347 Document TestContext bootstrapping in the reference manual
Issue: SPR-11683
2016-06-09 21:50:57 +02:00
Juergen Hoeller 7c96059ca3 BeanPropertyRowMapper uses ConversionService for date-time support
Issue: SPR-13888
2016-06-09 19:19:08 +02:00
Sam Brannen f0451294de Improve formatting for test annotations in reference manual 2016-06-09 17:09:15 +02:00
Sam Brannen 53909a5333 Polish key abstractions section for the TCF 2016-06-09 17:09:15 +02:00
Juergen Hoeller 1dfc0ffd43 SpringHandlerInstantiator supports all HandlerInstantiator-provided factory methods
Issue: SPR-14347
2016-06-09 17:02:39 +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
Stephane Nicoll 8432c62b50 Merge pull request #1073 from fisache:master
* pr/1073:
  Polish contribution
  Polish doc
2016-06-09 10:38:38 +02:00
Stephane Nicoll f7dd8e34b3 Polish contribution
Closes gh-1073
2016-06-09 10:38:16 +02:00
fisache 4465e4ff6c Polish doc
See gh-1073
2016-06-09 10:35:06 +02:00
Juergen Hoeller c6f63bdb30 Assertions for error codes in case of formatting failures
Issue: SPR-14345
2016-06-08 15:54:00 +02:00
Juergen Hoeller d1d29cf699 Documented support for new library and server generations 2016-06-08 15:23:06 +02:00
Juergen Hoeller a211d1472e Polishing 2016-06-08 15:22:01 +02:00
Sam Brannen da051b87e6 Polish documentation for stereotype names 2016-06-08 14:38:58 +02:00
Sam Brannen c9de6f23ef Document web scope annotations in the reference manual
Issue: SPR-13994
2016-06-08 14:38:58 +02:00
Juergen Hoeller cc7781ecf3 FormHttpMessageConverter's charset (and its UTF-8 default) applies to part converters as well
Issue: SPR-14338
2016-06-08 13:58:44 +02:00
Juergen Hoeller 8fc84e2d6f Upgrade to Jackson 2.8 RC1, Undertow 1.4 CR1, Netty 4.1.1
Issue: SPR-14340
Issue: SPR-14328
Issue: SPR-14143
2016-06-08 09:47:51 +02:00
Juergen Hoeller 981c894acf @ExceptionHandler matches against cause type as well
Issue: SPR-14291
2016-06-07 21:22:01 +02:00
Sam Brannen 99ae7e3bcb Document web scope annotations in the reference manual
Issue: SPR-13994
2016-06-07 20:17:34 +02:00
Sam Brannen 47d77252d3 Document web scope annotations in the reference manual
Issue: SPR-13994
2016-06-07 19:07:38 +02:00
Sam Brannen 6804aad06f Update reference manual regarding supported web scopes 2016-06-07 19:07:38 +02:00
Sam Brannen e2810904b0 Fix Javadoc formatting 2016-06-07 19:07:38 +02:00
Juergen Hoeller f5a9d5e076 Upgrade to Groovy 2.4.7 2016-06-07 18:09:02 +02:00
Sam Brannen 01d234f9f3 Use composed @RequestMapping variants in the reference manual
Issue: SPR-13995
2016-06-07 18:06:14 +02:00
Sam Brannen c121f460b1 Document composed @RequestMapping variants in the reference manual
Issue: SPR-13995
2016-06-07 17:26:57 +02:00
Juergen Hoeller 31aed61d15 CorsFilter asserts presence of CorsConfigurationSource 2016-06-07 16:49:23 +02:00
Sam Brannen 4432da3659 Update testing improvements in "What's New" 2016-06-07 16:32:42 +02:00
Sam Brannen de78f05707 Polishing 2016-06-07 16:24:50 +02:00
Sam Brannen eaa9511921 Avoid ClassCastException in HandlerResultMatchers.methodCall() 2016-06-07 16:13:42 +02:00
Sam Brannen 5a0100111e Polish HandlerAssertionTests 2016-06-07 16:13:42 +02:00
Juergen Hoeller 8c4bc3656b Polishing 2016-06-07 15:42:16 +02:00
Juergen Hoeller 6807bcb863 Fixed @since references after SPR-14080 backport
Issue: SPR-14305
(cherry picked from commit 9a41774)
2016-06-07 13:38:17 +02:00
Juergen Hoeller c412eabb00 Jackson2ObjectMapperBuilder/FactoryBean accepts deserializers by handled type
Issue: SPR-14337
2016-06-07 12:50:00 +02:00
Juergen Hoeller abcfffdde9 Allow JAXB to be registered next to plain Jackson
Issue: SPR-14336
2016-06-07 12:36:17 +02:00
Juergen Hoeller 3c987b179d Upgrade to EhCache 3.0.2 and Castor 1.4.1 2016-06-06 22:22:23 +02:00
Sam Brannen c19740a020 Clean up warnings in spring-test 2016-06-06 18:54:16 +02:00
Rossen Stoyanchev c2a50ad1bf Fine-tune X-Forwarded header in ForwardedHeaderFilter
The contextPathOverride property is now gone.
X-Forwarded-Header (if present) is used instead of the contextPath.

Issue: SPR-14270
2016-06-06 12:37:22 -04:00
Juergen Hoeller 9131ebbea6 Synchronized access to method overrides (in particular for @Lookup)
Issue: SPR-14333
2016-06-06 17:15:56 +02:00
Juergen Hoeller e7561b1d7c Updated @Autowired documentation in terms of collection/map/array matching
Issue: SPR-14332
2016-06-06 17:14:10 +02:00
Rossen Stoyanchev 998b83ce8c Fix hardcoded value MockRestServiceServerBuilder 2016-06-06 08:46:50 -04:00
Juergen Hoeller d7320f41c0 Upgrade to Undertow 1.4 Beta 1
Issue: SPR-14328
2016-06-04 11:27:37 +02:00
Juergen Hoeller a9fda3e7e2 Defensive catching of any Throwable subclasses instead of just Error
Issue: SPR-14329
2016-06-04 00:17:20 +02:00
Juergen Hoeller f657952cee EventListenerMethodProcessor defensively handles unresolvable method signatures
Issue: SPR-14330
2016-06-04 00:15:52 +02:00
Juergen Hoeller 9394616f8f Support for Hibernate ORM 5.2
Issue: SPR-14327
2016-06-02 23:35:31 +02:00
Juergen Hoeller 521c41d75e Polishing 2016-06-02 17:02:44 +02:00
Juergen Hoeller ae11387b4a Removal of @Ignore'd tests
Issue: SPR-6310
Issue: SPR-6327
2016-06-02 11:47:22 +02:00
Juergen Hoeller 7de61f80a7 AbstractRequestLoggingFilter supports logging of request headers
Issue: SPR-14245
2016-06-02 11:41:24 +02:00
Juergen Hoeller ca9ffa2012 Convenience constructors for CompositeDatabasePopulator
Issue: SPR-14313
2016-06-01 22:02:31 +02:00
Juergen Hoeller ea728b15c8 Polishing 2016-06-01 22:01:32 +02:00
Rossen Stoyanchev c74d979735 Rename contextPath method in ForwardedHeaderFilter 2016-06-01 15:45:44 -04:00
Rossen Stoyanchev b7f589547d Merge pull request #1071 from eddumelendez/SPR-14270 2016-06-01 15:34:25 -04:00
Rossen Stoyanchev 1f3ac340fa Polish X-Forwarded-Prefix handling
Issue: SPR-14270
2016-06-01 15:33:19 -04:00
Eddú Meléndez 7ee687c798 Support X-Forwarded-Prefix in ForwardedHeaderFilter
See SPR-14270
2016-06-01 14:28:19 -04:00
youmoo 9975f02e4d Method comment is wrong 2016-06-01 17:00:42 +02:00
Kamil Szymanski 5a81727180 MVC docs polishing 2016-06-01 16:58:20 +02:00
Juergen Hoeller 39f143563d Latest dependency updates (Commons FileUpload 1.3.2, OkHttp 3.3.1, HSQLDB 2.3.4, H2 1.4.192) 2016-06-01 15:10:57 +02:00
Juergen Hoeller 37de0e45f6 Polishing 2016-06-01 11:39:08 +02:00
Juergen Hoeller e4976a2c6d ExecutorSubscribableChannel consistently rethrows Error as MessageDeliveryException
Issue: SPR-14323
2016-06-01 11:38:56 +02:00
Rossen Stoyanchev fc40643033 Optimize Consumes/ProducesRequestCondition
Before this change Consumes/ProducesRequestCondition shared a common
match method in the package private AbstractMediaTypeExpression. The
benefit, two lines of code, was negligible but was forcing each
condition into parsing the content type of the request body or
evaluating the content type for the response respectively.

This change removes the shared match method and brings it down into
each sub-class resulting in a performance improvement as well as in
simpler code including exception handling.

Issue: SPR-14299
2016-05-31 14:55:50 -04:00
Rossen Stoyanchev 27215b5061 Negated produces works with no Accept header present
Issue: SPR-14299
2016-05-31 14:44:27 -04:00
Rossen Stoyanchev 8343ce9e44 Add defaultLocale to AcceptHeaderLocaleResolver
Issue: SPR-14312
2016-05-31 13:55:11 -04:00
Rossen Stoyanchev e2fa282e14 Merge pull request #1055 from rwinch/SPR-14265 2016-05-31 12:57:17 -04:00
Rossen Stoyanchev d10134b5a5 Polish 2016-05-31 12:56:17 -04:00
Rob Winch 54f84cbd97 MockMvcWebConnection stores cookies from response
Previously MockMvcWebConnection did not update the cookie manager with the
cookies from MockHttpServletResponse. This meant that newly added cookies
are not saved to the cookie manager and thus are not presented in the next
request.

This commit ensures that MockMvcWebConnection stores the response cookies
in the cookie manager.

Issue: SPR-14265
2016-05-31 12:43:58 -04:00
Rossen Stoyanchev 92f1b69e8c Update MultipartFilter documentations
Issue: SPR-11373
2016-05-31 12:42:32 -04:00
Rossen Stoyanchev 22c260f3fe Merge pull request #1069 from zhoulifu/SPR-14315 2016-05-31 09:35:49 -04:00
Rossen Stoyanchev f20f6c952a Flush headers after null ResponseBodyEmitter
Issue: SPR-14315
2016-05-31 09:35:02 -04:00
Rossen Stoyanchev 431a50823f Polish 2016-05-31 09:35:01 -04:00
Lifu Zhou 7e95cd8b4e Flush headers after null StreamingResponseBody
Issue: SPR-14315
2016-05-31 09:34:51 -04:00
Juergen Hoeller 71463fb399 AbstractBeanFactory consistently guards add/remove operations against alreadyCreated Set
Issue: SPR-14269
2016-05-31 14:12:06 +02:00
Juergen Hoeller 9064d38e4c AbstractBeanFactory.markBeanAsCreated() reliably clears merged bean definition only once
Issue: SPR-14269
2016-05-31 11:05:29 +02:00
Juergen Hoeller bff8259fb0 Upgrade to Objenesis 2.4 (and EhCache 3.0.1)
Issue: SPR-14292
2016-05-31 10:11:46 +02:00
Juergen Hoeller 3576ff051c ScheduledAnnotationBeanPostProcessor properly registers multiple tasks per bean
Issue: SPR-14286
2016-05-30 22:47:31 +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 822e40e24f AssertionErrors.assertEquals exposes readable array representation
Issue: SPR-14281
2016-05-30 17:16:03 +02:00
Juergen Hoeller 86557f25af ConcurrentMapCacheManager recreates caches when initializing ClassLoader
Issue: SPR-14314
2016-05-30 17:13:45 +02:00
Juergen Hoeller cf0a0cd5d8 BeanWrapper avoids StringIndexOutOfBoundsException for incompletely quoted keys
Issue: SPR-14293
2016-05-30 15:15:27 +02:00
Juergen Hoeller a1e9459a43 @SafeVarargs for header(String, Matcher...) method
Issue: SPR-14278
2016-05-30 15:06:55 +02:00
Juergen Hoeller d6284202f1 Reference documentation updates
Issue: SPR-14087
Issue: SPR-14272
Issue: SPR-13535
Issue: SPR-13843
Issue: SPR-14164
Issue: SPR-14167
2016-05-30 15:04:57 +02:00
Brian Clozel 250d82768f Merge pull request #1050 from fj/patch-1
Remove potential XSS vulnerability in Freemarker documentation
2016-05-30 09:44:18 +02:00
Juergen Hoeller 6efa058917 AbstractBeanFactory.markBeanAsCreated() reliably clears merged bean definition first
Issue: SPR-14269
2016-05-29 13:25:16 +02:00
Juergen Hoeller f7f2327f60 ServletServerHttpRequest.getHeaders() ignores invalid content type
Issue: SPR-14309
2016-05-29 13:22:00 +02:00
Juergen Hoeller 98eaf05c8f @Bean's "autowire" attribute does not affect annotation-driven autowiring
Issue: SPR-14282
2016-05-29 13:19:09 +02:00
Juergen Hoeller 42bf007604 Latest dependency updates (Joda-Time 2.9.4, Jetty 9.3.9, Netty 4.1 GA, Tomcat 8.5.2) 2016-05-27 23:46:15 +02:00
Juergen Hoeller 03affa02db ConfigurationClassParser detects @Bean methods in interface hierarchies as well
Issue: SPR-14288
2016-05-27 22:34:09 +02:00
Juergen Hoeller 2d85accb83 SpringTilesContainerFactory uses Tiles 3's createDecoratedContainer
Issue: SPR-14311
2016-05-27 18:24:49 +02:00
Sam Brannen 31a93792b2 Delete unused imports 2016-05-27 16:33:43 +02:00
Sam Brannen 49bc2a9a02 Clean up warnings in PersistenceXmlParsingTests 2016-05-27 16:30:50 +02:00
Stephane Nicoll 917948deac Polish SpEL documentation
Issue: SPR-14243
2016-05-27 10:30:38 +02:00
Juergen Hoeller abfe3f209d DefaultPersistenceUnitManager can determine persistence unit root from orm.xml location
Issue: SPR-14246
2016-05-26 23:57:49 +02:00
Juergen Hoeller a979885d17 SettableListenableFuture properly rethrows Error
Issue: SPR-14298
2016-05-26 19:39:22 +02:00
Juergen Hoeller dacc31e3d3 For attribute is not actually required
Issue: SPR-14287
2016-05-26 19:18:30 +02:00
Juergen Hoeller 65f6ea320a Upgrade to Objenesis 2.3 and Moneta 1.1
Issue: SPR-14292
Issue: SPR-14296
2016-05-26 19:17:40 +02:00
Rossen Stoyanchev 4e8754ea87 Add reset() to MockRestServiceServer
Issue: SPR-14306
2016-05-26 11:44:40 -04:00
Rossen Stoyanchev f4ab6d8d52 MockRestServiceServerBuilder can be re-used
Issue: SPR-14306
2016-05-26 09:48:16 -04:00
Stephane Nicoll a1851845ad Merge pull request #1065 from benelog:fix-comment
* pr/1065:
  Polish javadoc in TableMetaDataContext
2016-05-26 07:51:01 +02:00
Sanghyuk Jung 06e3ee6820 Polish javadoc in TableMetaDataContext
Closes gh-1065
2016-05-26 07:50:17 +02:00
Stephane Nicoll aa3b04c937 Merge pull request #1064 from izeye:patch-6
* pr/1064:
  Polish Javadoc in MediaType
2016-05-25 09:23:52 +02:00
Johnny Lim ace624a01a Polish Javadoc in MediaType
Closes gh-1064
2016-05-25 09:23:27 +02:00
Stephane Nicoll 7d4d3db0dd Add alternative database name for HANA
Issue: SPR-14261
2016-05-23 07:43:49 +02:00
Rossen Stoyanchev c2625f968c Properly handle single-value map with @MatrixVariable
Issue: SPR-14294
2016-05-22 09:53:42 -04:00
Rossen Stoyanchev 400206a2fe Update @RestController javadoc
Issue: SPR-13945
2016-05-22 09:06:23 -04:00
Rossen Stoyanchev a9217d51c2 Safe InetSocketAddress init for WebSocket and SockJS
Issue: SPR-14295
2016-05-22 06:36:42 -04:00
Stephane Nicoll 9c02a99d38 Polish doc
SPR-14290
2016-05-20 09:57:41 +02:00
Rossen Stoyanchev 3fb58cda8e Wrap Jetty WebSocketException
Issue: SPR-14267
2016-05-18 11:05:09 -04:00
Rossen Stoyanchev 1e003a1c90 Remove unnecessary assertion
Issue: SPR-14279
2016-05-18 10:57:54 -04:00
Rossen Stoyanchev 4a81aaba6c Fix STOMP connect failure related memory leak
Normally heartbeats keep connections from hanging. However in some
cases a connection may hang before a CONNECTED frame is received
and heartbeats are put in place. This commit adds a change to enforce
a 60 limit on receiving the CONNECTED frame.

Issue: SPR-14266
2016-05-12 11:24:50 -04:00
Stephane Nicoll 8c79f23175 Merge pull request #1052 from ferstl:fix-javadoc-example
* pr/1052:
  Fix CacheManager example in Javadoc
2016-05-12 15:24:03 +02:00
Stefan Ferstl d651ebfd2d Fix CacheManager example in Javadoc
Closes gh-1052
2016-05-12 15:23:40 +02:00
Juergen Hoeller c15f27cfa8 Avoid package import cycle through explicit javadoc reference 2016-05-06 13:41:02 +02:00
Stephane Nicoll 66bab2a9fc Revert "Manage asynchronous EventListener with replies"
This reverts commit bee1b77af5.
2016-05-06 13:38:03 +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 e5dbe12e85 ResourceHttpRequestHandler sets "Accept-Ranges" header only once
Issue: SPR-14221
2016-05-06 11:50:47 +02:00
Juergen Hoeller 1b1aac9172 Unit tests for AsyncResult callback behavior
Issue: SPR-14249
2016-05-05 20:40:30 +02:00
Juergen Hoeller 5400bb9110 ListenableFutureAdapter keeps propagating onSuccess/onFailure exceptions
Issue: SPR-13785
2016-05-05 20:39:53 +02:00
Juergen Hoeller 7dc181261e Polishing 2016-05-05 20:35:34 +02:00
John Feminella 2367f52aaf Remove potential XSS attack in Freemarker example
Since the user controls the value of `spring.status.value`, you wouldn't want to echo unescaped values here in this form. Otherwise one could submit a value of, say, `"/> <script>alert("pwned")</script>`.
2016-05-05 14:23:14 -04:00
Sam Brannen a1a87679da Support test annotations on interfaces
Prior to Java 8 it never really made much sense to author integration
tests using interfaces. Consequently, the Spring TestContext Framework
has never supported finding test-related annotations on interfaces in
its search algorithms.

However, Java 8's support for interface default methods introduces new
testing use cases for which it makes sense to declare test
configuration (e.g., @ContextConfiguration, etc.) on an interface
containing default methods instead of on an abstract base class.

This commit ensures that all non-repeatable, class-level test
annotations in the Spring TestContext Framework can now be declared on
test interfaces. The only test annotations that cannot be declared on
interfaces are therefore @Sql and @SqlGroup.

Issue: SPR-14184
2016-05-05 19:54:44 +02:00
Andy Clement a31f0bb3c0 Fix compilation of expressions using instanceof and primitives
Prior to this commit the SpEL compiler would generate bad bytecode
if the left hand operand of an instanceof was a primitive or
if the right hand operand was a primitive type reference.
With the fixes primitives on the left hand side are now
correctly boxed and special handling is in place for when the
right hand side is a primitive type reference. Using a primitive
type reference on the right always causes the instanceof
check to return false.

Additionally a guard has been added such that compilation is
not allowed when the right hand side of an expression
is not a type reference. If it is, for example, a variable
reference that evaluates to a type reference then that
cannot be expressed in bytecode so compilation is not performed.

Issue: SPR-14250
2016-05-05 09:57:15 -07: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
Juergen Hoeller 3f85efe107 Latest dependency updates (EhCache 2.10.2, HtmlUnit 2.21, JOpt Simple 5.0.1, JRuby 1.7.25, Quartz 2.2.3, Undertow 1.3.22) 2016-05-04 18:17:16 +02:00
Juergen Hoeller 08ddd1b3bc AbstractRequestLoggingFilter ignores non-available query string
Issue: SPR-14244
2016-05-04 18:17:06 +02:00
Juergen Hoeller 8c139ef444 Polishing 2016-05-04 17:37:30 +02:00
Juergen Hoeller ab478d14fa ScheduledAnnotationBeanPostProcessor tracks individual bean instances of any scope
Issue: SPR-12216
Issue: SPR-12872
2016-05-04 17:06:08 +02:00
Juergen Hoeller 162aedccbe Polishing 2016-05-04 17:02:16 +02:00
Sam Brannen f09c7868d8 Polishing 2016-05-04 16:04:37 +02:00
Juergen Hoeller e6e3ca3e96 LazySingletonAspectInstanceFactoryDecorator uses shared singleton mutex
Issue: SPR-14241
2016-05-04 09:03:28 +02:00
Sam Brannen e26478e3de Polish Javadoc regarding @Commit support 2016-05-03 20:26:11 +02:00
Sam Brannen 7b13311f03 Delete unused imports 2016-05-03 20:12:37 +02:00
Sam Brannen 6b3eba0500 Suppress warnings in Gradle build 2016-05-03 19:56:33 +02:00
Sam Brannen 64c388d524 Properly document avoiding false positives when testing with JPA
Prior to this commit, information regarding avoiding false positives
when testing with JPA had already been added to the Testing chapter of
the reference manual. However, the example did not work properly and
the accompanying text mixed concepts from Hibernate and JPA.

This commit fixes the @Autowired/@PersistenceContext bug, updates the
text, and marks each test as @Transactional in order to avoid any
misinterpretation.

Issue: SPR-9032
2016-05-03 19:33:32 +02:00
Sam Brannen 0f6711fe3b Support @[Before|After]Transaction on default methods
Prior to this commit, @BeforeTransaction and @AfterTransaction could
only be declared on methods within test classes. However, JUnit 5 as
well as some existing third-party Runner implementations for JUnit 4
already support Java 8 based interface default methods in various
scenarios -- for example, @Test, @BeforeEach, etc.

This commit brings the Spring TestContext Framework up to date by
supporting the declaration of @BeforeTransaction and @AfterTransaction
on interface default methods.

Issue: SPR-14183
2016-05-03 18:57:31 +02:00
Sam Brannen 7ce5ba4a3f Refer explicitly to JUnit 4 in the testing chapter
This commit updates the Testing chapter in the reference manual to
refer explicitly to JUnit 4 instead of just "JUnit" (where appropriate)
in order to avoid confusion with forthcoming support for JUnit 5.
2016-05-03 18:57:31 +02:00
Sam Brannen 3433fe35df Fix assertion failure messages in TransactionalTestExecutionListenerTests 2016-05-03 18:57:31 +02:00
Juergen Hoeller 52e5b4a6ff Polishing 2016-05-03 18:55:39 +02:00
Juergen Hoeller 76964e16ef Explicit note on Java deserialization 2016-05-03 18:44:37 +02:00
Rossen Stoyanchev 46e41a9d94 Consolidate SendTo vs SendToUser detection
SendTo and SendToUser are treated as mutually exclusive. The addition of
type-level support in 4.3. RC1 however did not consider the possibility
to mix and match of the two betwee type and method level.

This commit consolidates the detection of SendTo and SendToUser
annotations and considers them all together.

Issue: SPR-14238
2016-05-03 12:34:19 -04:00
Brian Clozel 05b29a4a17 Add convenient getters for force*Encoding attributes
Issue: SPR-14240
2016-05-03 16:14:09 +02:00
Brian Clozel 76ee46847a Selectively force encoding in CharacterEncodingFilter
Prior to this commit, setting the `forceEncoding` option would force
encoding on both requests and responses.

This commit adds two new setters and a new constructor to differentiate
both options: forcing the encoding on the request and/or on the
response.

You can now define this filter programmatically using those options or
update your servlet XML configuration like:

```
<filter>
  <filter-name>characterEncodingFilter</filter-name>
  <filter-class>o.sf.web.filter.CharacterEncodingFilter</filter-class>
  <init-param>
     <param-name>encoding</param-name>
     <param-value>UTF-8</param-value>
  </init-param>
  <init-param>
    <param-name>forceRequestEncoding</param-name>
    <param-value>true</param-value>
  </init-param>
  <init-param>
    <param-name>forceResponseEncoding</param-name>
    <param-value>false</param-value>
  </init-param>
</filter>

```

Issue: SPR-14240
2016-05-03 14:47:22 +02:00
Juergen Hoeller 1be544f8fa JtaTransactionManager explicitly resets transaction timeout after completion
Issue: SPR-14239
2016-05-03 13:30:51 +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
Juergen Hoeller 7737c3c7e5 Warn about non-static BeanDefinitionRegistryPostProcessor declarations on @Configuration classes
Issue: SPR-14234
2016-05-02 15:19:05 +02:00
Juergen Hoeller cbc46760b7 Upgrade to Jackson 2.7.4 2016-05-02 13:54:57 +02:00
Juergen Hoeller 07ea3745c4 Polishing 2016-05-02 13:54:47 +02:00
Stephane Nicoll 09b45d2c0f Validate callback is always invoked in DMLC#stop
The underlying issue has been fixed in e45d33f and this commit is merely
adding a test of the expected behaviour.

Issue: SPR-14233
2016-05-02 13:33:05 +02:00
Juergen Hoeller f83cbff543 Consistent SmartLifecycle implementations
Issue: SPR-14233
2016-05-02 13:01:44 +02:00
Juergen Hoeller e45d33f9de DefaultMessageListenerContainer immediately invokes stop callback when not running
Issue: SPR-14233
2016-05-02 12:57:30 +02:00
Brian Clozel 29da44c8dc Support ETags with special chars in ServletWebRequest
This commit makes sure that HTTP request headers containing ETag values
are properly parsed and not simply tokenized using a "," separator.
Indeed, ETags can legally contain separator characters such as " " and
",".

Issue: SPR-14216
2016-04-29 11:20:29 +02:00
Juergen Hoeller fdb31cd715 Check actual cache value for unwrapped Optional
Issue: SPR-14230
2016-04-29 10:56:26 +02:00
Rossen Stoyanchev bd40a93604 Ensure Environment.shutdown() in Reactor2TcpClient
Issue: SPR-14229
2016-04-28 17:47:59 -04:00
Juergen Hoeller 240f254bfc Allow @Cacheable method to return java.util.Optional variant of cached value
Includes renaming of internal delegate to CacheOperationExpressionEvaluator.

Issue: SPR-14230
2016-04-28 23:16:43 +02:00
Rossen Stoyanchev 220711d45b Reactor2TcpClient cleans up TcpClient instances
Issue: SPR-14231
2016-04-28 15:27:53 -04:00
Brian Clozel 977840884b Allow custom instances of WebJarAssetLocator
This commit allows to configure a custom WebJarAssetLocator in
WebJarResourceResolvers.

Issue: SPR-14092
2016-04-28 19:02:04 +02:00
Brian Clozel 55dae618a6 Improve multi-valued HTTP headers support
Prior to this change, getting header values with `HttpHeaders` when
headers are multi-valued would cause issues.
For example, for a given HTTP message with headers:
    Cache-Control: public, s-maxage=50
    Cache-Control: max-age=42

Getting a `List` of all values would return <"public", "s-maxage=50">
and getting the header value would return "public, s-maxage=50".

This commit takes now into account multi-valued HTTP headers and adds
new getters/setters for "If-Match" and "If-Unmodified-Since" headers.

Note that for ETag-related headers such as "If-Match" and
"If-None-Match", a special parser has been implemented since ETag values
can contain separator characters.

Issue: SPR-14223, SPR-14228
2016-04-28 18:48:47 +02:00
Sebastien Deleuze 15138ed96f Revisit ScriptTemplateView resource loading
Resources are now retrieved using the application context in order to
support natively non-classpath locations like /WEB-INF/...

As a consequence of this refactoring, ScriptTemplateView#createClassLoader()
protected method as been removed, since it did not make sense anymore with
this new resource loading implementation.

Issue: SPR-14210
2016-04-28 15:40:14 +02:00
Juergen Hoeller 9412f7a094 InstantFormatter accepts RFC-1123 values as well
Issue: SPR-14201
2016-04-28 14:35:33 +02:00
Stephane Nicoll 777767c7ee Merge pull request #1046 from panchenko/ReflectionUtils-static-final
* pr/1046:
  "final" for public static fields in ReflectionUtils
2016-04-28 08:34:35 +02:00
Alex Panchenko 8d36332268 "final" for public static fields in ReflectionUtils
Closes gh-1046
2016-04-28 08:34:10 +02:00
Juergen Hoeller cd6b203c88 Upgrade to Caffeine 2.3 2016-04-27 22:10:49 +02:00
Juergen Hoeller 8ddb432694 Polishing 2016-04-27 21:35:26 +02:00
Juergen Hoeller e0734aede8 ApplicationListenerDetector explicitly prevents serialization of its ApplicationContext reference
Issue: SPR-14214
2016-04-27 21:30:46 +02:00
Juergen Hoeller 6ab8d36ed0 DefaultMessageListenerContainer's recovery phase uses wait instead of sleep
Issue: SPR-14200
2016-04-27 21:27:21 +02:00
Juergen Hoeller b331ad5b2a Explicit note on scheduled methods with a return value
Issue: SPR-14195
2016-04-27 15:45:30 +02:00
Juergen Hoeller ce2f28da49 CachedIntrospectionResults explicitly introspects implemented interfaces (for Java 8 default methods)
Issue: SPR-14198
2016-04-27 15:39:00 +02:00
Rossen Stoyanchev 335d968f85 Polish DefaultUrlTemplateHandler 2016-04-27 08:55:52 -04:00
Brian Clozel a50ea80e4e Handle multiple conditional request headers
Prior to this change, setting both "If-None-Match" and
"If-Unmodified-Since" conditional request headers would check for both
conditions to be met.

This commit fixes this behavior to follow the RFC7232 Section 6:
> entity tags are presumed to be more accurate than date validators

So in case both conditions are present, the "If-None-Match" condition
takes precedence.

Issue: SPR-14224
2016-04-27 12:02:33 +02:00
Sam Brannen 1838d7e97f Update Javadoc for ReflectionUtils re: exception handling 2016-04-27 12:44:09 +03:00
Rossen Stoyanchev 8f0f5faf4d XML config properly initialize WS message broker stats
Issue: SPR-14190
2016-04-26 17:24:22 -04:00
Juergen Hoeller d06188ed4d ResponseEntity allows for setting non-standard status code
Issue: SPR-14205
2016-04-26 23:06:10 +02:00
Juergen Hoeller e5d52a96a7 HttpSessionRequiredException programmatically exposes name of expected attribute
Issue: SPR-14206
2016-04-26 23:06:10 +02:00
Rossen Stoyanchev 9798912557 Add missing @since tag 2016-04-26 16:48:45 -04:00
Rossen Stoyanchev 06b2d2b89e STOMP client session supports sending ack/nack
Issue: SPR-14208
2016-04-26 16:44:58 -04:00
Rossen Stoyanchev 538c582342 Extract AbstractUriTemplateHandler base class
Issue: SPR-14147
2016-04-26 13:32:35 -04:00
Juergen Hoeller bb1a0311d8 Upgrade to Gradle 2.13
Issue: SPR-14215
2016-04-26 17:09:57 +02:00
Juergen Hoeller 87b93a7ae9 Aligned JmsTemplate and DefaultMessageListenerContainer receiveTimeout values
Issue: SPR-14212
2016-04-26 17:09:57 +02:00
Juergen Hoeller 65a8f5ed64 PathMatchingResourcePatternResolver reuses resolved root dir URL
Issue: SPR-14202
2016-04-26 17:09:57 +02:00
Juergen Hoeller f73df2e138 SpringServletContainerInitializer does not log WebApplicationInitializer class names
Issue: SPR-14213
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
Rob Winch 9ec0873604 MockWebResponseBuilder defaults cookie domain
Previously MockWebResponseBuilder would use the cookie domain of the cookie
received from MockMvc response. This caused problems because the cookie
domain can be null, but HtmlUnit forbids a null domain.

This commit defaults the domain of the cookie to the domain of the
WebRequest.

Issues SPR-14169
2016-04-25 16:35:56 -05:00
Venil Noronha b2c9c8abcf Add text/markdown MediaType constant
Issue: SPR-14192
2016-04-25 09:57:30 -04:00
Sam Brannen c84c1cfd1b Update Javadoc for TestContextBootstrapper
@WebAppConfiguration is no longer meta-annotated with @BootstrapWith.
2016-04-25 15:44:15 +02:00
Sam Brannen 67a9f40c95 Polish Javadoc for TestContextManager 2016-04-23 18:23:25 +02:00
Sam Brannen 4a4cd5bde8 Polish CronSequenceGenerator and tests 2016-04-23 18:05:54 +02:00
Sam Brannen 151530b93b Merge pull request #1042 from Enigo/cron-validation
Introduce cron expression validation method for CronSequenceGenerator
2016-04-23 17:49:00 +02:00
Ruslan Sibgatullin 31d634e6bf Added cron expression validation method for CronSequenceGenerator
It's handy to know in advance whether or not expression that is
passed to CronSequenceGenerator or CronTrigger constructor would
not results in IllegalArgumentException. The only way to do it
now is to try\catch an instance creation but it's kinda ugly.
2016-04-23 17:56:29 +03:00
Sam Brannen 920eba79f8 Polish Javadoc for DefaultUriTemplateHandler 2016-04-23 16:49:04 +02:00
Rossen Stoyanchev 065b7968a3 Add defaultUriVariables property to RestTemplate
Issue: SPR-14147
2016-04-22 16:21:23 -04:00
Rossen Stoyanchev 0d007a328b Polish DefaultUriTemplateHandler 2016-04-22 16:21:18 -04:00
Rossen Stoyanchev 5ec6206e3f Update spring-mvc-3.2.xsd
The backport in commit cf39078 changed the spring-mvc-3.2.xsd.
This change updates the same in the master branch.

Issue: SPR-14186
2016-04-21 14:11:49 -04:00
Rossen Stoyanchev 6e4e52b23a Upgrade to Reactor 2.0.8 2016-04-21 09:21:52 -04:00
Stephane Nicoll fee2533825 Merge pull request #1039 from izeye/polish-20160419
* pr/1039:
  Remove duplicate words
2016-04-19 08:24:37 +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
Venil Noronha aafd46aeb3 Remove isOpen assertion when sending WebSocket message
Issue: SPR-14138
2016-04-18 09:46:05 -04:00
Venil Noronha 28f2f4a431 Delegate sendMessage
Issue: SPR-14139
2016-04-18 09:30:48 -04:00
Juergen Hoeller f8720e256d Upgrade to EhCache 3.0 GA
Issue: SPR-14185
2016-04-18 14:41:01 +02:00
Rossen Stoyanchev 7cdcc102a9 Explicit HEAD sorted higher than implicit GET match
Issue: SPR-14182
2016-04-17 15:12:43 -04:00
Sam Brannen ff38224da6 Introduce tests for @[Before|After]Transaction on default methods
This commit introduces @Ignore'd tests for future support for declaring
@BeforeTransaction and @AfterTransaction on interface default methods.

Issue: SPR-14183
2016-04-17 16:01:07 +02:00
Stephane Nicoll b1bc920e72 Merge pull request #1037 from izeye/patch-6
* pr/1037:
  Use the defined constant in MergedContextConfiguration
2016-04-16 10:33:19 +02:00
Johnny Lim c402932ba1 Use the defined constant in MergedContextConfiguration
Closes gh-1037
2016-04-16 10:32:41 +02: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 e38bfb1a68 Consistent public constructors in ast package
Issue: SPR-14181
2016-04-15 22:26:58 +02:00
Rob Winch 970dc4ae11 Add --no-daemon to Gradle import
Previously using the Gradle Daemon with import eclipse scripts would cause
issues with the merge plugin. Specifically, projects would randomly not
be associated to the classpath.

This change explicitly adds --no-daemon in the import scripts to ensure
that the problem does not occur.

Issue SPR-14102
2016-04-15 11:50:17 -05:00
Rob Winch 6489a7670c Change Eclipse Settings to allow forbidden references
Spring uses lots of forbidden references. The current Eclipse settings
set forbiddenReference=error This was not ideal because there were lots of
errors in the workspace.

This commit changes forbiddenReference=warning since we nee to allow
forbidden references.
2016-04-15 10:54:37 -05:00
Rob Winch 87ed8e939c HtmlUnitRequestBuilder decodes parameter names
Previously HtmlUnitRequestBuilder did not decode parameter names. This
means if a parameter like row[0] was submittted it would be encoded as
row%5B0%5D When the HttpServletRequest was created the parameter name would
not be decoded so the parameter name row[0] would not be found.

This commit ensures that HTTP parameter names are decoded.

Issue SPR-14177
2016-04-15 10:23:00 -05:00
Stephane Nicoll 64d4e91b6e Polish 2016-04-15 16:38:18 +02:00
Stephane Nicoll bee1b77af5 Manage asynchronous EventListener with replies
This commit makes sure to reject an `@EventListener` annotated method
that also uses `@Async`. In such scenario, the method is invoked in a
separate thread and the infrastructure has no handle on the actual reply,
if any.

The documentation has been improved to refer to that scenario.

Issue: SPR-14113
2016-04-15 13:22:11 +02:00
Juergen Hoeller 44a9c495ab Strong Hibernate 5.1 recommendation
Issue: SPR-13480
Issue: SPR-14176
2016-04-15 12:07:31 +02:00
Juergen Hoeller b28d96af7d ScheduledAnnotationBeanPostProcessor accepts non-void methods as well
Issue: SPR-14175
2016-04-14 21:59:02 +02:00
Juergen Hoeller 999112216d AopUtils.canApply properly matches package-visible methods (aligned with advice matching within proxies)
Also, AbstractAutoProxyCreator considers Pointcut as infrastructure class, analogous to Advice and Advisor.

Issue: SPR-14174
2016-04-14 21:46:25 +02:00
Juergen Hoeller 3b44c47dcd Polishing 2016-04-14 16:39:36 +02:00
Juergen Hoeller f1cb793ccb Rename MimeType's getCharSet() to getCharset()
Issue: SPR-14172
2016-04-14 16:38:59 +02:00
Juergen Hoeller 977734cc59 Upgrade to Protobuf Java Format 1.4
Issue: SPR-14171
2016-04-14 15:44:53 +02:00
Juergen Hoeller 62ce9afe3a Jackson-based message converters consistently check media type first
Issue: SPR-14163
2016-04-14 14:26:05 +02:00
Juergen Hoeller 5f4e838f41 Jackson-based message converters do not log warning for serializer not found
Issue: SPR-14163
2016-04-14 14:13:13 +02:00
Juergen Hoeller 7e55b0822f BeanInstantiationException preserves Constructor/Method if available
Issue: SPR-14166
2016-04-14 12:27:47 +02:00
Juergen Hoeller 3222664024 Avoid unnecessary GenericHttpMessageConverter re-declaration 2016-04-13 19:03:59 +02:00
Juergen Hoeller 96875fe015 Avoid unnecessary GenericHttpMessageConverter re-declaration 2016-04-13 18:52:52 +02:00
Juergen Hoeller 570851e8e4 Consistent headers.getContentLength() checks
(cherry picked from commit 7f438dc)
2016-04-13 18:50:15 +02:00
Juergen Hoeller e3667467f6 AbstractJackson2HttpMessageConverter's canRead/canWrite checks media type first before delegating to Jackson
Issue: SPR-14163
2016-04-13 18:34:22 +02:00
Juergen Hoeller ee31617ebe Drop outdated support for building on JDK 9 (not compatible with JDK 9 b111+) 2016-04-13 13:56:43 +02:00
Juergen Hoeller dcfa4740ee Polishing
(cherry picked from commit 09b7735)
2016-04-13 13:56:37 +02:00
Juergen Hoeller 88b5b12baf Latest dependency updates (AspectJ 1.8.9, Rhino 1.7.7.1, WebJars Locator 0.30) 2016-04-13 12:57:46 +02:00
Juergen Hoeller da112611a5 SpringCacheAnnotationParser properly accepts empty @Caching annotation
Issue: SPR-14162
2016-04-12 23:19:51 +02:00
Juergen Hoeller 836a321ab2 JPA ClassFileTransformerAdapter defensively backs out when called from within a transform call
Issue: SPR-13886
2016-04-12 21:44:17 +02:00
Juergen Hoeller 74608e6b49 Polishing 2016-04-12 16:03:57 +02:00
Juergen Hoeller 831f09cf48 SimpleTransactionScope properly suspends and resumes scoped objects
Issue: SPR-14148
2016-04-12 16:02:36 +02:00
Stephane Nicoll 10554a85c9 Polish 2016-04-12 08:34:38 +02:00
Stephane Nicoll 454165f4c8 Merge pull request #1013 from tokuhirom/patch-1
* pr/1013:
  Fix typo
2016-04-12 08:17:43 +02:00
Tokuhiro Matsuno 741fbcd6fe Fix typo
Closes gh-1013
2016-04-12 08:17:24 +02:00
Stephane Nicoll 1e7be7be3f Merge pull request #1030 from izeye/patch-6
* pr/1030:
  Fix typo
2016-04-12 08:15:05 +02:00
Johnny Lim f4b7da9a3e Fix typo
Closes gh-1030
2016-04-12 08:14:53 +02:00
Stephane Nicoll 7d7d1c365a Merge pull request #1028 from michael-simons/fix-appendix-typo
* pr/1028:
  Fix copy & paste error for cache schema
2016-04-12 08:14:13 +02:00
Michael Simons 82778e1746 Fix copy & paste error for cache schema
This replaces the prefix "jdbc" with "cache" and fixes the schema URL.

Closes gh-1028
2016-04-12 08:12:50 +02:00
Juergen Hoeller bdb94738ec Refined default excluded packages
Issue: SPR-13886
2016-04-12 05:14:14 +02:00
Juergen Hoeller b6f1afd471 Polishing 2016-04-11 21:20:31 +02:00
Juergen Hoeller 537193a4e0 Consistent license header 2016-04-11 20:49:38 +02:00
Juergen Hoeller d695f65e7c Upgrade to HtmlUnit-aligned Selenium Driver 2.20
Issue: SPR-14146
2016-04-11 20:49:09 +02:00
Juergen Hoeller 550a3209f7 Fixed XML example for setup of scheduled tasks
Issue: SPR-14145
2016-04-11 19:27:06 +02:00
Juergen Hoeller b82df144e4 LoadTimeWeaver.getThrowawayClassLoader() decorated for exclude support (if necessary)
Issue: SPR-13886
2016-04-11 19:19:37 +02:00
Juergen Hoeller 448621ac58 HttpHeaders consistently ignores invalid date header values
Issue: SPR-14144
2016-04-11 17:45:49 +02:00
Juergen Hoeller 437ffa6067 Detect LoadTimeWeaver bean when declared through @Bean method as well
Issue: SPR-10856
2016-04-11 17:43:23 +02:00
Juergen Hoeller 21e4ac1aa2 Upgrade to Netty 4.1
Issue: SPR-14143
2016-04-11 12:20:13 +02:00
Juergen Hoeller 4407bd794d Polishing 2016-04-10 05:40:35 +02:00
Juergen Hoeller dc7ec44188 Upgrade to CGLIB 3.2.2
Issue: SPR-13934
2016-04-09 23:12:13 +02:00
Juergen Hoeller cb9549655c AbstractApplicationContext registers default embedded value resolver
Issue: SPR-14140
2016-04-09 20:49:22 +02:00
Sam Brannen 572e535fba Update Eclipse code template to Spring 4.3 2016-04-09 19:19:26 +02:00
Juergen Hoeller 4ae065996b Polishing
(cherry picked from commit aa5c12c)
2016-04-08 23:06:25 +02:00
Rossen Stoyanchev 3abe75b254 Remove section on spring-framework-contrib group 2016-04-08 15:43:51 -04:00
Brian Clozel f3b09464f3 Polish reference documentation
`@InitBinder` annotated methods are not meant to be part of the public
contract of Controller and should be package protected.
2016-04-08 16:47:11 +02:00
Juergen Hoeller e365ffb67a Latest dependency updates (EhCache 3.0 RC3, Undertow 1.3.21) 2016-04-08 16:16:29 +02:00
Juergen Hoeller 37bd51cf6d Handle Resources beyond int length through Servlet 3.1's setContentLengthLong
Issue: SPR-14135
2016-04-08 15:54:24 +02:00
Sam Brannen 463c8f149d Add properties files directly to environment in TestPropertySourceUtils
This commit introduces a new method in TestPropertySourceUtils that
allows properties files to be added directly to the environment without
the need for a ConfigurableApplicationContext upfront; however, a
ResourceLoader is still necessary.

Issue: SPR-14131
2016-04-07 17:02:37 +02:00
Juergen Hoeller 157dcab56c Cleanup of remaining direct BeanWrapper usage
Issue: SPR-14121
2016-04-07 14:27:22 +02:00
Juergen Hoeller 5c1d3fca15 BeanFactory does not unwrap java.util.Optional for top-level bean
Issue: SPR-14121
2016-04-07 14:18:30 +02:00
Juergen Hoeller 042d8d0b4c FacesRequestAttributes falls back to ExternalContext as session mutex
Issue: SPR-12402
2016-04-07 11:41:32 +02:00
Juergen Hoeller ed14ae60e5 Consistent deprecation of outdated MVC infrastructure classes
Issue: SPR-14128
2016-04-07 11:37:34 +02:00
Juergen Hoeller 4ea4257e3c BeanDefinitionBuilder keeps providing addConstructorArg(Object) for Spring Security 2.x compatibility
Issue: SPR-14123
2016-04-07 11:35:43 +02:00
Sam Brannen 8213df817e Clean up warnings in spring-web 2016-04-06 15:21:07 +02:00
Sam Brannen ebeba43830 Document context cache size control in the TCF in reference manual
Issue: SPR-8055
2016-04-06 15:06:10 +02:00
Sam Brannen 5bd5c74e7c Polish TCF key abstractions section in reference manual 2016-04-06 14:56:08 +02:00
Sam Brannen b6f99e38ae Polish wording regarding previous release versions in reference manual 2016-04-06 14:45:28 +02:00
Sam Brannen 0c0c904837 Consistently refer to Groovy alongside XML in reference manual 2016-04-06 14:36:36 +02:00
Sam Brannen f752e050bc Fix grammar in the reference manual 2016-04-06 14:20:05 +02:00
Sam Brannen 6d7f497ab3 Fix single quote formatting issues in the reference manual 2016-04-06 14:14:51 +02:00
Sam Brannen 5a0a88c039 Fix typo in reference manual regarding JSR 330 2016-04-06 13:56:57 +02:00
Sam Brannen a9aa85c6c0 Document DirtiesContextBeforeModesTEL in the reference manual 2016-04-06 13:55:19 +02:00
Juergen Hoeller 4024b2fd4b DefaultListableBeanFactory leniently deserializes into dummy factory if serialization id not resolvable
Issue: SPR-14117
2016-04-05 15:49:30 +02:00
Juergen Hoeller 6db6f23a04 Quartz ResourceLoaderClassLoadHelper explicitly falls back to classpath lookup
Issue: SPR-13706
2016-04-05 12:18:48 +02:00
Juergen Hoeller 6573e9142c Polishing 2016-04-05 12:17:21 +02:00
Juergen Hoeller 797f5dbba6 StatementCreatorUtils handles Types.BOOLEAN through PreparedStatement.setBoolean
Issue: SPR-14116
2016-04-05 11:12:36 +02:00
Juergen Hoeller 7c450fad3b Latest dependency updates (Caffeine 2.2.6, EhCache 3.0 RC2, Joda-Time 2.9.3, Netty 4.0.36, Rome 1.6, SLF4J 1.7.21, Tomcat 8.0.33, Undertow 1.3.20, Woodstox 5.0.2, JOpt-Simple 5.0) 2016-04-05 10:13:10 +02:00
Juergen Hoeller d2d528dc05 Polishing 2016-04-05 09:42:41 +02:00
Rossen Stoyanchev cfdb683449 Call resetRequest after writeFrame for polling sessions
Previous refactoring (fcf6ae and also 43d937) in the SockJsSession
hierarchy consolidated access to the request and response in the
base class AbstractHttpSockJsSession in order to keep synchronization
concerns there. However that also unintentionally removed the call to
resetRequest() after sending a heartbeat for any of the
PollingSockJsSession classes. In general a polling session should call
resetRequest after every frame written.

This commit brings back the writeFrame override in PollingSockJsSession
with an extra call to resetRequest().

Issue: SPR-14107
2016-04-04 19:30:05 -04:00
Sam Brannen 6c0cae87b4 Clean up warnings in spring-test 2016-04-04 21:30:01 +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
Rossen Stoyanchev d554229981 Fix incomplete log message
Commit 48236b from 2014 introduced a logging improvement to avoid
logging each removed session per line and instead log one line at
the end with all removed sessions ids. However that list of removed
session ids wasn't populated. This commit fixes that.

Issue: SPR-14111
2016-04-04 14:01:27 -04:00
Stephane Nicoll 996c1cc0a6 Fix Auto-Startup for @JmsListener
Ignore container's auto-startup once the context is refreshed.

Issue: SPR-14015
2016-04-04 18:21:10 +02:00
Stephane Nicoll ad7285df0b Merge pull request #1027 from Youmoo/patch-2
* pr/1027:
  Fix typo
2016-04-04 17:36:36 +02:00
youmoo 1bccc8f1cd Fix typo
Closes gh-1027
2016-04-04 17:36:17 +02:00
Sebastien Deleuze 1f9a9cf404 Auto-detect Kotlin Jackson module
Issue: SPR-14108
2016-04-04 16:49:40 +02:00
Juergen Hoeller edea66a967 Further tests for getBeanNamesForType(ResolvableType)
Issue: SPR-14097
2016-04-04 14:58:30 +02:00
Juergen Hoeller 8bfba6a07a EhCacheManagerFactoryBean logs cache manager name
Issue: SPR-14110
2016-04-04 14:56:08 +02:00
Juergen Hoeller 13f889e914 SimpleApplicationEventMulticaster leniently handles ClassCastException
Issue: SPR-14109
2016-04-04 14:54:38 +02:00
Juergen Hoeller 696dcb72a5 SpringValidatorAdapter allows for custom field name resolution
Issue: SPR-14104
2016-04-01 10:29:56 +02:00
Juergen Hoeller 739ae8c045 LocalValidatorFactoryBean supports custom ValidationProviderResolver
Issue: SPR-14100
2016-03-31 16:52:26 +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 f6cb30b165 @ExceptionHandler is able to process Error thrown from handler method
Issue: SPR-11106
2016-03-31 11:52:36 +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
Juergen Hoeller b7819e6ec8 AnnotationTransactionAttributeSource applies class-level metadata to user-level methods only
Issue: SPR-14095
2016-03-30 10:21:22 +02:00
Sam Brannen ea09e578b9 Document support for @Cache* as merged composed annotations
Issue: SPR-13475
2016-03-29 20:04:43 +02:00
Sam Brannen 2ed3382a60 Document composed support for @Scheduled, @JmsListener, & @Sql
Issue: SPR-13973
2016-03-29 19:53:58 +02:00
Roy Clarkson f35ec5353a Add support for OkHttp3
OkHttp3 introduces a new package and API that is incompatible with
previous versions. This commit adds a new
OkHttp3ClientHttpRequestFactory and supporting classes.
2016-03-29 18:15:04 +02:00
Sam Brannen d40d2ffe5e Polishing 2016-03-29 18:04:26 +02:00
Sam Brannen 3597879608 Revert merged support for @ManagedNotification & @ManagedOperationParameter
This commit reverts the recently added merged annotation support for
Spring's JMX annotations by once again using the simpler searches for
repeatable annotations in AnnotationUtils.

Issue: SPR-13973
2016-03-29 17:51:47 +02:00
Brian Clozel eec22f5072 Avoid duplicate flush when closing outputstream
Prior to this commit, the `HttpInvokerServiceExporter` would close
its `ObjectOutputStream`, which itself issues duplicate flushes on the
underlying `OutputStream`. Duplicate flushes can lead to multiple,
separate TCP packets where those should be gathered writes.

This commit wraps the underying stream with a decorator that guards
against flush calls that are duplicated with the one done in `close`.

Issue: SPR-14040
2016-03-29 17:31:42 +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 6298292523 AsyncRestTemplate triggers no-output HTTP requests immediately as well
Issue: SPR-14093
2016-03-29 15:22:32 +02:00
Juergen Hoeller 2dae4d8134 Deprecated FormTag's "commandName" in favor of "modelAttribute"
Issue: SPR-14094
2016-03-29 12:09:16 +02:00
Sam Brannen 26bbb6e767 Polishing 2016-03-28 16:17:47 +02:00
Juergen Hoeller b2a17ba537 RequestHeaderMapMethodArgumentResolver defensively checks for non-existing header values
Issue: SPR-14091
2016-03-27 14:07:25 +02:00
Sam Brannen 4fa11e334f Test @ManagedNotification as a merged, composed annotation
Issue: SPR-13973
2016-03-26 20:10:20 +01: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 a8b5ea1c51 Polishing 2016-03-26 01:27:37 +01:00
Sam Brannen 4742aa0bfe Test @JmsListener as a merged composed annotation
Issue: SPR-13973
2016-03-26 01:09:35 +01:00
Sam Brannen 2353f39ee4 Clean up warnings 2016-03-26 01:08:58 +01:00
Sam Brannen 4836d06704 Test @Scheduled as a merged composable annotation
Issue: SPR-13973
2016-03-26 00:47:02 +01:00
Juergen Hoeller c6ff0951fc Polishing 2016-03-25 23:46:18 +01:00
Juergen Hoeller 94cb7786c8 Polishing 2016-03-25 23:28:45 +01:00
Brian Clozel 862d10c128 Support new default values in WebDataBinder
Prior to this commit, binding a `@ModelAttribute` object as a Controller
handler paramater would instantiate the object and set all its
properties, fetching data from the request. When no data is available,
the WebDataBinder tries to bind default "empty" values:
* Boolean.FALSE for boolean types
* empty arrays for array types
* null by default

This commit adds the new default empty values:
* empty Collections for Collection types
* empty Maps for Map types

Rather than using empty implementations provided by `Collections.empty`
(which are not mutable), we're using the closest possible target type
and real implementations, provided by the `CollectionFactory`.

Issue: SPR-13502
2016-03-25 21:37:08 +01:00
Sam Brannen b0c6357540 Test @Sql as a merged composed annotation
Issue: SPR-13973
2016-03-25 20:47:16 +01:00
Phillip Webb fc839331a7 Refine TestPropertySourceUtils for direct use
Update methods in TestPropertySourceUtils to accept var-args and allow
addInlinedProperties to be called more than once.

Issue: SPR-14088
2016-03-25 11:12:27 -07: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 c6f6e192c0 Support @Sql as a merged composed annotation
Issue: SPR-13973
2016-03-25 00:51:42 +01:00
Sam Brannen d572b022cc Support @JmsListener as a merged composed annotation
Issue: SPR-13973
2016-03-25 00:51:24 +01:00
Sam Brannen c6b1f38651 Support @Scheduled as a merged composable annotation
Issue: SPR-13973
2016-03-25 00:49:59 +01:00
Sam Brannen b6d9fd39e6 Support @ManagedNotification & @ManagedOperationParameter as merged annotations
Issue: SPR-13973
2016-03-25 00:49:21 +01:00
Sam Brannen 6b7731cc89 Cross reference getMergedRepeatableAnnotations() in AnnotationUtils 2016-03-25 00:47:44 +01:00
Juergen Hoeller 775bcccd10 Polishing 2016-03-24 21:44:16 +01:00
Juergen Hoeller 852212d0c5 Polishing 2016-03-24 19:57:54 +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
Brian Clozel 2cdb0cf690 Temporarily comment quartz-scheduler external API 2016-03-24 17:52:54 +01:00
Juergen Hoeller 06db5aa43f Polishing 2016-03-24 15:34:17 +01:00
Juergen Hoeller 9a52c81443 UriComponentsBuilder allows more efficient (and less restrictive) CORS origin comparison
Also introduces a specifically narrowed cloneBuilder() method for UriComponentsBuilders.

Issue: SPR-14080
2016-03-24 15:33:44 +01:00
Juergen Hoeller abe7345008 DefaultCorsProcessor checks for existing CORS response before attempting to compare origin
Issue: SPR-14080
2016-03-24 15:08:19 +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
Juergen Hoeller 3eff478c45 RequestMethodsRequestCondition uses common HttpMethod resolution
Issue: SPR-13776
2016-03-24 13:54:00 +01:00
Juergen Hoeller 86d5c5c0f7 Avoid putIfAbsent call in HttpEntityMethodProcessor
Issue: SPR-14086
2016-03-24 13:51:48 +01:00
Juergen Hoeller 7e4563a825 Upgrade to XStream 1.4.9
Issue: SPR-14084
2016-03-24 13:51:03 +01:00
Sam Brannen 2453edbb10 Reorganize methods in AnnotatedElementUtils 2016-03-24 13:18:54 +01:00
Brian Clozel 38714b35e7 Update Javadoc external links 2016-03-24 11:40:27 +01:00
Brian Clozel 20bb25647f Polish 2016-03-24 10:56:46 +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
Juergen Hoeller 311d4c95a3 Revised newline handling tests pass on Windows now
Issue: SPR-13503
2016-03-23 18:35:26 +01:00
Juergen Hoeller 3c18a4533a Ignored test removed (not intended to work)
Issue: SPR-14058
2016-03-23 18:15:29 +01:00
Brian Clozel e079a726f8 Polish 2016-03-23 16:40:12 +01:00
Brian Clozel c7bd3b8440 Support HTTP range requests in Controllers
Prior to this commit, HTTP Range requests were only supported by the
ResourceHttpRequestHandler when serving static resources.

This commit improves the ResourceHttpMessageConverter that
now supports partial writes of Resources.
For this, the `HttpEntityMethodProcessor` and
`RequestResponseBodyMethodProcessor` now wrap resources with HTTP
range information in a `HttpRangeResource`, if necessary. The
message converter handle those types and knows how to handle partial
writes.

Controller methods can now handle Range requests for
return types that extend Resource or HttpEntity:

    @RequestMapping("/example/video.mp4")
    public Resource handler() { }

    @RequestMapping("/example/video.mp4")
    public HttpEntity<Resource> handler() { }

Issue: SPR-13834
2016-03-23 16:40:12 +01:00
Brian Clozel 15fe8279e6 Reset Expires HTTP header when caching configured
Just like SPR-13252 addressed this issue for the "Pragma" header, this
issue resets the HTTP 1.0 "Expires" header.
When such a header has been set (by a filter, for example) and HTTP
caching has been configured at the WebContentGenerator, this header
value is reset to "". In this case, "Cache-Control" and "Expires" might
have inconsistent values and we consider that the HTTP caching
configuration should take precedence.

Depending on the servlet container chosen to deploy the application,
this might result in empty "" header values or no header set at all.

Issue: SPR-14053
2016-03-23 16:35:13 +01:00
Kazuki Shimizu 9b2023111d Add newline at the beginning of textarea macro for FreeMarker and Velocity
Issue: SPR-13503
2016-03-23 11:31:16 +01:00
Rossen Stoyanchev 7a5e93ff16 Add support for setting the "Vary" response header
Issue: SPR-14070
2016-03-22 21:47:55 -04:00
Rossen Stoyanchev 6bfe0c050d Polish 2016-03-22 20:59:16 -04:00
Sam Brannen 59c88eb3c0 Support @Cache* as merged composed annotations
Prior to this commit, @Cacheable, @CacheEvict, @CachePut, and @Caching
could be used to create custom stereotype annotations with hardcoded
values for their attributes; however, it was not possible to create
composed annotations with attribute overrides.

This commit addresses this issue by refactoring
SpringCacheAnnotationParser to use the newly introduced
findAllMergedAnnotations() method in AnnotatedElementUtils. As a
result, @Cacheable, @CacheEvict, @CachePut, and @Caching can now be
used to create custom composed annotations with attribute overrides
configured via @AliasFor.

Issue: SPR-13475
2016-03-21 12:54:09 +01:00
Stephane Nicoll 2a715e9c61 Fix escaping of #
This commit disables the "quotes" substitutions on specific XML
examples that require to use the reserved `#` character.

Issue: SPR-14074
2016-03-21 12:51:14 +01:00
Sam Brannen 532ed0a4cf Clean up warnings in the spring-test module 2016-03-20 19:37:54 +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 799736c571 Fix typos in Javadoc for AutowireCapableBeanFactory 2016-03-20 15:26:37 +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
Sam Brannen 4cd7ba12bb Polishing 2016-03-19 14:39:01 +01:00
Juergen Hoeller 5f6406430f LocalSessionFactoryBuilder/Bean supports setMultiTenantConnectionProvider
Issue: SPR-14072
2016-03-19 13:48:54 +01:00
Juergen Hoeller a1a06cd665 @EnableScheduling tests do not expect exception in case of scheduler ambiguity anymore
Issue: SPR-14030
2016-03-19 13:18:24 +01:00
Sam Brannen 5045579028 Revise EnableSchedulingTests
- Fast tests now always run (i.e., are no longer limited to the
  performance build
- Failing tests have been @Ignore'd

Issue: SPR-14030
2016-03-19 12:38:47 +01:00
Juergen Hoeller a905412514 Allow @Autowired to be declared on parameters
Issue: SPR-14057
2016-03-18 22:12:22 +01:00
Juergen Hoeller 6e3fac85f3 AnnotationAwareOrderComparator uses DecoratingProxy interface for target class introspection
Issue: SPR-13884
2016-03-18 22:12:10 +01:00
Rossen Stoyanchev 9ac9135c24 Update reference on StompClient
Issue: SPR-13664
2016-03-18 16:59:24 -04:00
Sam Brannen c5200978b0 Polishing 2016-03-18 19:44:20 +01:00
Sam Brannen 11221f5ccb Fix Javadoc errors in AnnotatedElementUtils 2016-03-18 19:31:05 +01:00
Rob Winch 411ff8450f Refine tests for SPR-14066
Explicitly define the response type as text/plain to avoid content type
confusion.

Issue SPR-14066
2016-03-18 13:24:10 -05:00
Sam Brannen e2ba477405 Upgrade Gradle Wrapper version to Gradle 2.12
Issue: SPR-14048
2016-03-18 19:06:10 +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 431ca9314a Leniently allow constructor argument matches if required name is not resolvable
Issue: SPR-13987
2016-03-18 18:51:33 +01:00
Sam Brannen 455bf45fa4 Fix test that failed due to upgrade to HtmlUnit 2.20 2016-03-18 18:43:46 +01:00
Markus Malkusch 160410c148 Be explicit about the time unit in WebRequest
This commit adds the timeunit to the interface documentation
of WebRequest.checkNotModified().
2016-03-18 18:23:15 +01:00
Brian Clozel 7ae44c2565 Allow skipping JSON prefix in MockMvc result matchers
JSON payloads are sometimes prepended with a static string prefix
to prevent Cross Site Scripting Inclusion attacks (XSSI).
Prior to this commit, doing so would fail the MockMvc
`JsonPathResultMatchers` since they're considering the whole response as
the JSON payload.

This commit adds a new `JsonPathResultMatchers.prefix` method that
configures the matchers to check for the presence of that string (i.e.
fail if it's not there) and only consider the rest of the response body
as the JSON payload for other assertions.

Issue: SPR-13577
2016-03-18 18:13:42 +01:00
Rossen Stoyanchev 4a6c2dbb15 Merge pull request #1009 from rwinch/SPR-14066 2016-03-18 12:01:55 -04:00
Rossen Stoyanchev d3822c8d19 Polish 2016-03-18 12:01:09 -04:00
Rob Winch 7d96ad1f6e MockMvc HtmlUnit support shares CookieManager
Previously MockMvc builders failed to share the WebConnection used for
managing cookies in the MockMvcWebConnection. This meant that the various
CookieManagers would have different states.

This commit ensures that the WebConnection is set on the
MockMvcWebConnection.

Fixes SPR-14066
2016-03-18 12:01:09 -04:00
Juergen Hoeller 8246fe4534 Latest dependency updates: EhCache 3.0 RC1, HtmlUnit 2.20, Apache HttpClient 4.5.2, Jackson 2.7.3, JasperReports 6.2.1, Jetty 9.3.8, JRuby 1.7.24, JsonAssert 1.3, JsonPath 2.2, POI 3.14, Selenium 2.52, SLF4J 1.7.19, Animal Sniffer 1.15, Undertow 1.3.19, H2 1.4.191 2016-03-18 16:16:54 +01:00
Juergen Hoeller ec7c3aa349 Correct RFC 4648 references in method-level javadoc
Issue: SPR-14067
2016-03-18 15:30:33 +01:00
Juergen Hoeller a95bf6e0fc Current InjectionPoint/DependencyDescriptor as factory method argument
Issue: SPR-14033
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 43661ededb Verify inlined props override files in @TestPropertySource
This commit introduces a test to demonstrate that inlined properties
override properties loaded from Properties files in
@TestPropertySource.

Issue: SPR-14068
2016-03-18 15:04:14 +01:00
Sam Brannen 856da8e395 Introduce tests for transitive aliases with implied attribute names 2016-03-17 20:53:52 +01:00
Sam Brannen 7a3bc2e473 Polishing 2016-03-17 14:08:13 +01:00
Rossen Stoyanchev f5a5a81e95 Support response cookies in HtmlUnit integration
Issue: SPR-14051
2016-03-16 15:26:06 -04:00
Rossen Stoyanchev 92dd4eb3ef Fix NPE in ResponseBodyEmitterReturnValueHandler
The possibility of NPE was introduced in the previous commit:
https://github.com/spring-projects/spring-framework/commit/971ccab038ad8e549d515a80e2d64c5d4c80c86b

Issue: SPR-14046
2016-03-16 13:40:35 -04:00
Sam Brannen 9439a008d7 Merge pull request #1006 from mdeinum/SPR-14050
* SPR-14050:
  Fully test proxy support in ReflectionTestUtils
  Polishing
  Document proxy support in ReflectionTestUtils
  Fix bugs in ReflectionTestUtils related to proxies
  Polishing
  Support proxied objects in ReflectionTestUtils
2016-03-16 18:34:14 +01:00
Sam Brannen d9025ddaa7 Fully test proxy support in ReflectionTestUtils
This commit adds a test for JDK dynamic proxies and fleshes out the
test for CGLIB proxies.

Issue: SPR-14050
2016-03-16 18:34:07 +01:00
Sam Brannen 7beff7b40a Polishing 2016-03-16 18:34:07 +01:00
Sam Brannen b1ca18e0dc Document proxy support in ReflectionTestUtils
Issue: SPR-14050
2016-03-16 18:34:07 +01:00
Sam Brannen 2d565c7944 Fix bugs in ReflectionTestUtils related to proxies
Issue: SPR-14050
2016-03-16 18:34:07 +01:00
Sam Brannen 7c7e7865bf Polishing 2016-03-16 18:34:07 +01:00
Marten Deinum 8d3ec50e87 Support proxied objects in ReflectionTestUtils
This commit adds support for unwrapping proxies in the setField() and
getField() methods in ReflectionTestUtils.

Instead of always accessing fields directly on the supplied
targetObject (which may be a proxy), AopTestUtils is now used to obtain
the potential ultimateTargetObject which is then used for accessing
fields.

Issue: SPR-14050
2016-03-16 18:34:07 +01:00
Juergen Hoeller d2c0885e29 StandardServletEnvironment supports "spring.jndi.ignore" flag for efficient property lookups
Issue: SPR-14026
2016-03-16 18:14:44 +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 b1121fba70 Polish 2016-03-16 17:14:03 +01:00
Stephane Nicoll 30d457c622 Deprecate addCache 2016-03-16 17:13:06 +01:00
Stephane Nicoll 1c3c88f81e Merge pull request #998 from quaff/SPR-14039
* pr/998:
  Polish contribution
  Add converters between Enum and Integer
2016-03-16 17:01: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
Rossen Stoyanchev 183594207f Support user destinations without leading slash
Before this commit the DefaultUserDestinationResolver did not support
well broker destinations that use dot as separator with a built in
assumptions that the destinations it resolves must start with slash.

This change adds PathMatcher property that is used to determine if
an alternative path separator is in use and if so the leading slash is
left out.

Issue: SPR-14044
2016-03-15 17:50:13 -04:00
Sam Brannen e904ce4ead Polish QualifierAnnotationAutowireContextTests 2016-03-15 18:17:50 +01:00
Sam Brannen e83e3ec9de Add failing test for @Qualifier as composed annotation
Issue: SPR-14058
2016-03-15 18:13:59 +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
Stephane Nicoll 2a9b2ca5fd Polish doc
Issue: SPR-14012
2016-03-15 16:12:35 +01:00
Stephane Nicoll 33a4e9e57f Prevent non public bean to be exposed to JMX
Previously, a package private `@ManagedResource` annotated bean was
registered to the JMX domain even if any attempt to invoke an operation
on it will fail since it has to be public.

This commit validates that any `@ManagedResource` annotated bean is
public and throws an InvalidMetadataException otherwise. Note that the
actual bean type does not have to be public as long as the class
annotated with `@ManagedResource` in the hierarchy is pubic and no extra
operations or attributes are defined on the child.

Issue: SPR-14042
2016-03-15 09:51:20 +01:00
Rossen Stoyanchev 582864802e Ensure RedirectModel is initialized
This commit fixes an old bug in ModelAndViewContainer where getModel
returns a new ModelMap instance that isn't saved and re-used.

Issue: SPR-14045
2016-03-14 23:00:19 -04:00
Rossen Stoyanchev 971ccab038 DeferredResult/ResponseBodyEmitter adapter mechanism
The DeferredResult~ and the ResponseBodyEmitterReturnValueHandler now
each expose an adapter mechanism for plugging in other async return
value types. As a result the ListenableFutureReturnValueHandler and
CompletionStageReturnValueHandler are no longer needed and are now
deprecated.

Issue: SPR-14046
2016-03-14 12:20:02 -04:00
Stephane Nicoll 2152f436f9 Upgrade to Gradle 2.12
Issue: SPR-14048
2016-03-14 15:00:00 +01:00
Sam Brannen c41c5dd5c9 Polishing 2016-03-12 14:58:06 +01:00
Sam Brannen 92e715ed93 Update "What's New" regarding new testing features 2016-03-12 14:46:36 +01:00
Juergen Hoeller f2f87ff1e0 Explicit javadoc references to BeanFactory-based default executor lookup
Issue: SPR-14030
2016-03-11 23:52:31 +01:00
Juergen Hoeller 155fa3754b Consistent lazy resolution of default executor/scheduler for Async/ScheduledAnnotationBeanPostProcessor
Issue: SPR-14030
2016-03-11 23:23:58 +01:00
Phillip Webb 094cf6cafb Support *Aware for @ComponentScan custom filters
Support a limited set of *Aware interfaces for TypeFilters created
via the @ComponentScan annotation.

Issue: SPR-14009
2016-03-11 12:40:42 -08:00
Sam Brannen beb01e674e Merge pull request #991 from philwebb/SPR-13998
* SPR-13998:
  Polish ContextCustomizer support in the TCF
  Introduce ContextCustomizer API in the TestContext Framework
2016-03-11 21:23:26 +01:00
Sam Brannen cbd1342fbb Polish ContextCustomizer support in the TCF
Issue: SPR-13998
2016-03-11 21:22:08 +01:00
Phillip Webb 87a3a5cb3b Introduce ContextCustomizer API in the TestContext Framework
Allow third-parties to contribute ContextCustomizers that can customize
ApplicationContexts created by the Spring TestContext Framework (TCF)
before they are refreshed.

A customizer may be provided via a ContextCustomizerFactory which is
registered with `spring.factories`. Each factory is consulted whenever
a new ApplicationContext needs to be created by the TCF. Factories may
inspect various details about the test and either return a new
ContextCustomizer or null.

ContextCustomizers are similar to ApplicationContextInitializers and
may perform any number of tasks, including bean registration, setting
of active profiles, etc.

Issue: SPR-13998
2016-03-11 20:53:06 +01:00
Juergen Hoeller 406d06118d Latest dependency updates (Caffeine 2.2.2, Gson 2.6.2, Jackson 2.7.2, OkHttp 2.7.5, OpenJPA 2.4.1) 2016-03-11 15:12:14 +01:00
Juergen Hoeller 71294df238 Upgrade to ASM 5.1
Issue: SPR-14037
2016-03-11 15:09:03 +01:00
Juergen Hoeller d124a13eb4 Consistent use of empty enumerations 2016-03-11 15:07:59 +01:00
Juergen Hoeller 8852a5e178 Support for placeholders in @CrossOrigin attributes
Issue: SPR-14010
2016-03-11 15:04:16 +01:00
Juergen Hoeller b4de66ff9a Test for placeholder-specified default value within @Value
Issue: SPR-14025
2016-03-11 15:00:01 +01:00
Juergen Hoeller 0b1639d963 JdbcTemplate passes negative values other than -1 on to the driver (for MySQL's special values)
Issue: SPR-14028
2016-03-11 14:59:00 +01:00
Juergen Hoeller 100f3c5eeb Removed invalid quoting of message arguments from MessageSource examples
Issue: SPR-14003
2016-03-11 12:57:41 +01:00
Juergen Hoeller 0597ff109e Bsh/GroovyScriptFactory reset script cache in case of compilation error
Issue: SPR-14007
2016-03-11 12:55:20 +01:00
Juergen Hoeller b944283354 ConstructorResolver exposes parameter signature from user-declared class (in case of a CGLIB-generated subclass)
Issue: SPR-14015
2016-03-11 12:52:40 +01:00
Juergen Hoeller b6f69492a3 NoUniqueBeanDefinitionException exposes beanNamesFound collection
Issue: SPR-13968
2016-03-11 12:49:57 +01:00
Rossen Stoyanchev 68f6cf9d3a Support same user connected to multiple servers
The MultiServerUserRegistry now supports scenarios where the same user
is connected to multiple servers. For such cases the SimpUser returned
from the registry exposes all sessions across all servers.

Issue: SPR-13800
2016-03-10 14:37:22 -05:00
Rossen Stoyanchev 6aa216afb6 Polish SimpUserRegistry related classes
Issue: SPR-13800
2016-03-10 14:37:22 -05:00
Sam Brannen 8222ff465d Merge pull request #996 from philwebb/SPR-14035
* SPR-14035:
  Polish ServletTestExecutionListener[Tests]
  Support servlet listener activate attribute
2016-03-10 17:20:50 +01:00
Sam Brannen 51eccf552f Polish ServletTestExecutionListener[Tests] 2016-03-10 17:20:02 +01:00
Phillip Webb bb590db396 Support servlet listener activate attribute
Add a ServletTestExecutionListener.ACTIVATE_LISTENER attribute which
can be set on the TestContext to trigger activation of the listener
even if a `@WebAppConfiguration` is not present.

Issue: SPR-14035
2016-03-10 16:54:14 +01:00
Brian Clozel 8ca6a18dae Allow Validator config in XML websocket namespace
This commit adds a new "validator" XML attribute to the
`<websocket:message-broker/>` element. This allows configuring a
specific Validator to be used for payload validation.

Issue: SPR-13996
2016-03-10 16:35:20 +01:00
Stephane Nicoll 8e24a4153c Support ResolvableTypeProvider on simple event pojo
Previously, the generic type of a simple pojo event implementing
ResolvableTypeProvider wasn't detected properly. This commit fixes the
logic when the generic type is not provided to reuse what
PayloadApplicationEvent is already doing anyway.

Issue: SPR-14029
2016-03-09 11:55:20 +01:00
Stephane Nicoll ed341695a8 Merge pull request #992 from coryfklein/master
* pr/992:
  Fix typo
2016-03-09 08:54:03 +01:00
Cory Klein 71cf7b4053 Fix typo
Closes gh-992
2016-03-09 08:53:47 +01:00
Phillip Webb 2244461778 Allow @ContextConfiguration to be omitted
Prior to this commit, the @ContextConfiguration annotation was required
to be present even if default XML files, Groovy scripts, or
@Configuration classes were detected; however, in such cases the
@ContextConfiguration was typically declared empty and therefore
seemingly unnecessary boilerplate.

This commit permits @ContextConfiguration to be omitted whenever it can
be reasonably deduced. Consequently, integration tests such as the
following are now supported.

    @RunWith(SpringRunner.class)
    public class MyTest {

        @Autowired String myBean;

        @Test public void example() { /* ... */ }

        @Configuration
        static class Config {

            @Bean String myBean() {
                return "Hello";
            }
        }
    }

Issue: SPR-13955
2016-03-08 19:36:49 +01:00
Brian Clozel 0a56667093 Fix SpringUrl Velocity macro URI encoding
Prior to this commit, the springUrl Velocity macro would only prepend
the context to the given URL; this means that the
ServletHttpResponse.encodeUri method is not called and neither the
ResourceUrlProvider.

This commit changes this macro to use RequestContext.getContextUrl which
prepends the context and encodes the URI.

Issue: SPR-14027
2016-03-08 17:07:59 +01:00
Sam Brannen 89cf4772d5 Fix malformed HTML in Javadoc 2016-03-08 15:27:35 +01:00
Sam Brannen e85a06234b Partial merge of pull request #983 from philwebb/testcontext
* philwebb-testcontext:
  Polishing
  Remove @BootstrapWith from @WebAppConfiguration
2016-03-08 15:19:55 +01:00
Sam Brannen 93fb7be783 Polishing 2016-03-08 15:18:21 +01:00
Phillip Webb 504779e210 Remove @BootstrapWith from @WebAppConfiguration
Update @WebAppConfiguration so that it no longer directly specifies
a TestContextBootstrapper. This allows third parties to use the
annotation in combination with their own bootstrapper.

BootstrapUtils now provides the detection logic for when
WebTestContextBootstrapper should be used.

Issue: SPR-13991
2016-03-08 14:31:06 +01:00
Sam Brannen 0d12b84022 Document single element annotation attribute overrides in "What's New"
Issue: SPR-13972
2016-03-08 14:00:12 +01:00
Sam Brannen 4bead6e542 Polish Javadoc for @GetMapping
Issue: SPR-13992
2016-03-07 18:18:46 +01:00
Sam Brannen cbcc9998f1 Support 'produces' and 'consumes' attributes in @DeleteMapping
Issue: SPR-13992
2016-03-07 18:13:40 +01:00
Sam Brannen bea26413b4 Support 'produces' attribute in @[Post|Put|Patch]Mapping
Issue: SPR-13992
2016-03-07 18:13:40 +01:00
Sam Brannen 78690a24fb Add headers & name attributes to composed @RequestMapping annotations
Issue: SPR-13992
2016-03-07 18:13:40 +01:00
Sam Brannen ca8acc8758 Suppress warnings Gradle build 2016-03-07 15:36:46 +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
Stephane Nicoll e086a5d58b Polish
Add period unit in the description so that it shows up in the summary
description.
2016-03-06 09:04:59 +01:00
Stephane Nicoll 1772278053 Merge pull request #985 from verydapeng/master
* pr/985:
  Add table title for @Transactional settings
2016-03-04 22:42:59 +01:00
Dapeng 9d4c6e4d06 Add table title for @Transactional settings
Closes gh-985
2016-03-04 22:41:34 +01:00
Rossen Stoyanchev dfa1938ac1 Update what's new 2016-03-04 16:09:08 -05:00
Rossen Stoyanchev ff2a911baa Update MVC config to use CNM for static resources
The MVC config now plugs the configured ContentNegotiationManager into
resource request handling.

Issue: SPR-13658
2016-03-04 16:06:01 -05:00
Rossen Stoyanchev f162256906 Use ContentNegotiationManager for static resources
The ResourceHttpRequestHandler now relies on the conifgured
ContentNegotiationManager to determine the content type for resource
requests rather than implementing that internally.

First we check against the matched resource based on the resource file
extension. Then we expand the check against the request with any
configured content negotiation strategy.

Issue: SPR-13658
2016-03-04 16:06:01 -05:00
Rossen Stoyanchev 1a76f7e9c2 Polish static resource handling 2016-03-04 16:05:49 -05:00
Brian Clozel 5067f00228 Polish
Issue: SPR-14018
2016-03-04 11:38:25 +01:00
Ruben Dijkstra 41da04d386 Remove duplicate slash from resolved WebJar locations
This commit updates the WEBJARS_LOCATION in WebJarResourceResolver to
avoid getting duplicate slashes in resolved resources locations such
as `/webjars//bootstrap/3.3.2/js/bootstrap.min.js`.

Issue: SPR-14018
2016-03-04 11:36:30 +01:00
Rossen Stoyanchev 9e167045fc Update what's new 2016-03-03 14:48:50 -05:00
Rossen Stoyanchev 6f2c968925 Support strict URI variable encoding
The DefaulUriTemplateHandler now provides a strictEncoding property
which if turned on encodes everything outside the reserved char set.

This is in contrast to the default policy of encoding only illegal
charaters depending on the URI component type.

Issue: SPR-11652
2016-03-03 14:37:48 -05:00
Rossen Stoyanchev e98738d8ba Polish UriTemplateHandler related classes 2016-03-03 13:33:45 -05:00
Brian Clozel 44c32128dc Add newline at the beginning of textarea JSP tags
This commit adds a newline char at the beginning of textarea tags
values. As per the HTML 4.01 spec (and browsers behavior), a line break
following a start tag is ignored.

This can lead to Spring's textarea tag to ignore a line break char at
the beginning of a tag value.

See https://www.w3.org/TR/html401/appendix/notes.html#notes-line-breaks

Issue: SPR-13503
2016-03-03 16:48:17 +01:00
Rossen Stoyanchev 36e2dd90a7 Support contextPath override in ForwardedHeaderFilter
Issue: SPR-13614
2016-03-02 18:38:25 -05:00
Rossen Stoyanchev 6fcc869338 Polish ForwardedHeaderFilter
Issue: SPR-13614
2016-03-02 18:38:25 -05:00
Sam Brannen 067994712d Make TestContextManager.getTestContext() public
This commit changes the visibility of the getTestContext() method in
TestContextManager from 'protected' to 'public' in order to support
test method injection in JUnit 5 and similar use cases.

Issue: SPR-14011
2016-03-02 20:19:25 +01:00
Brian Clozel 50bcd67fb6 Relax SPR-13867 changes for ResourceHttpRequestHandler
Prior to this change, SPR-13867 made sure that any class extending
WebContentGenerator would not overwrite existing HTTP "Cache-Control"
response headers - set by a filter, a Controller handler, etc.

This caused issues with resource handling, since specifying a cache
configuration there would not overwrite default headers set by filters,
for example by Spring Security.

This commit restricts the previous changes to the
RequestMappingHandlerAdapter, in order to avoid overwriting header set
by a filter or a Controller handler in those cases.

Issue: SPR-14005
2016-03-02 17:42:44 +01:00
Sam Brannen 18e9699a2b Demo @ContextConfiguration as composed annotation with ACI
This commit demonstrates how to register one or more @Configuration
classes via an ApplicationContextInitializer in a composed annotation so
that certain @Configuration classes are always registered whenever the
composed annotation is used, even if the composed annotation is used to
declare additional @Configuration classes.
2016-03-02 14:07:15 +01:00
Rossen Stoyanchev 4cf0b59e00 Add ForwardedHeaderFilter
The new Filter is simply a new way of packaging the ability to extract
X-Forwarded-* headers already available via UriComponentsBuilder.

The Filter wraps the request and the effect is that anything using the
request will see the original schem, host, and port.

Issue: SPR-13614
2016-03-01 23:33:36 -05:00
Sebastien Deleuze 7b861c9a8a Add defaultUseWrapper support to Jackson builder
Issue: SPR-13975
2016-03-02 00:03:25 +01:00
Phillip Webb ffbf264976 Polish Javadoc 2016-03-01 13:34:25 -08:00
Stephane Nicoll b3b3fc5a7e Polish 2016-03-01 19:10:39 +01:00
Brian Clozel 3df66d023c Polish documentation on WebApplicationInitializer
Issue: SPR-13978
2016-03-01 17:38:52 +01:00
Brian Clozel 0d6f80052d Support conditional updates in ServletWebRequest
Prior to this commit, `ServletWebRequest.checkNotModified` would only
support conditional GET/HEAD requests with "If-Modified-Since" and/or
"If-None-Match" request headers. In those cases, the server would return
"HTTP 304 Not Modified" responses if the resource didn't change.

This commit adds support for conditional update requests, such as
POST/PUT/DELETE requests with "If-Unmodified-Since" request headers.
If the underlying resource has been modified since the specified date,
the server will return a "409 Precondition failed" response status
to prevent concurrent updates.

Even if the modification status of the resource is reversed here
(modified vs. not modified), we're keeping here the same intent for the
return value, which signals if the response requires more processing or
if the handler method can return immediately:

```
if (request.checkNotModified(lastModified)) {
  // shortcut exit - no further processing necessary
  return null;
}
```

Issue: SPR-13863
2016-03-01 14:37:29 +01:00
Sebastien Deleuze b3abd3b809 Fix HeaderResultMatchers#string(String, String) assert order
Issue: SPR-14004
2016-03-01 14:18:29 +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
Sam Brannen 61824b1ade Remove trailing whitespace from source code 2016-02-29 18:52:57 +01:00
Sam Brannen 2bb2657483 Merge pull request #981 from sbrannen/SPR-13992
* SPR-13992:
  Introduce composed annotations for @RequestMapping
2016-02-29 18:25:57 +01:00
Sam Brannen 467b5f3f28 Introduce composed annotations for @RequestMapping
This commit introduces the following common composed annotations for
@RequestMapping in Spring MVC and Spring MVC REST.

- @GetMapping
- @PostMapping
- @PutMapping
- @DeleteMapping
- @PatchMapping

Issue: SPR-13992
2016-02-29 18:22:30 +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
Sam Brannen 161ec15a46 Merge pull request #982 from sbrannen/SPR-13993
* SPR-13993:
  Introduce composed annotations for web scopes
2016-02-29 17:41:43 +01:00
Sam Brannen b423596b2e Introduce composed annotations for web scopes
This commit introduces the following common composed annotations for
web scopes.

- @RequestScope
- @SessionScope
- @ApplicationScope

Issue: SPR-13993
2016-02-29 17:38:46 +01:00
Sam Brannen df7b24b8e7 Allow non-public @Transactional test methods
Prior to this commit, the TransactionalTestExecutionListener required
@Transactional test methods to be public; however, neither TestNG nor
JUnit 5 require that @Test methods are public. Consequently, non-public
transactional test methods silently run *without* a transaction.

This commit removes the 'public' restriction on transactional test
methods by setting the 'publicMethodsOnly' flag in
AnnotationTransactionAttributeSource to false.

Issue: SPR-14000
2016-02-29 15:30:22 +01:00
Sam Brannen 197434b3ec Polish TestNG integration tests 2016-02-29 15:30:22 +01:00
Sam Brannen 816185233d Polish TransactionalTestExecutionListener 2016-02-29 15:30:22 +01:00
Juergen Hoeller a02fd7c995 RequestMappingHandlerAdapter properly invokes handler method in case of no session as well
Issue: SPR-13999
2016-02-29 15:05:50 +01:00
Juergen Hoeller 9c0f99c0b5 Polishing 2016-02-29 12:57:09 +01:00
Juergen Hoeller 8e5e384de7 Test for constructor with unresolvable parameter name
Issue: SPR-13987
2016-02-29 11:18:23 +01:00
Juergen Hoeller 1815a6a7eb RequestMappingHandlerAdapter properly invokes handler method in synchronizeOnSession mode again
Issue: SPR-13999
2016-02-29 11:12:11 +01:00
Sam Brannen a2bfe86630 Support @[Before|After]Transaction on non-public methods
In order to align with the relaxed programming models of TestNG and the
upcoming JUnit 5 (with regard to method visibility), this commit
removes the requirement that @BeforeTransaction and @AfterTransaction
methods must be 'public'.

Issue: SPR-13997
2016-02-29 00:42:47 +01:00
Sam Brannen 31e0386bcb Stop referencing deprecated @TransactionConfiguration in Javadoc 2016-02-27 23:50:00 +01:00
Sam Brannen 9d3dd1bc13 Introduce SpringRunner 'alias' for SpringJUnit4ClassRunner
This commit introduces a SpringRunner extension of
SpringJUnit4ClassRunner that is intended to be used as an 'alias' for
SpringJUnit4ClassRunner, primarily in order to simplify configuration
of JUnit 4 based integration tests.

Developers can use this alias as follows:

    @RunWith(SpringRunner.class)
    public class MySpringIntegrationTests { ... }

Issue: SPR-13954
2016-02-27 23:02:55 +01:00
Sam Brannen 0c66838268 Polish Javadoc for @RequestMapping 2016-02-26 22:35:51 +01:00
Sam Brannen 6fcb6630d7 Clean up warnings in SampleAsyncTests 2016-02-26 22:35:51 +01:00
Juergen Hoeller ab16053ed4 Redistribute AOP Alliance interfaces in spring-aop again (as in Spring 2.x)
Issue: SPR-13984
2016-02-26 12:40:00 +01:00
Juergen Hoeller 8a83af55b8 Consistent resolution of factory method exceptions
Issue: SPR-13985
2016-02-26 12:31:03 +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
Rossen Stoyanchev 1bc1df2d0f Polish client-side REST updates
Issue: SPR-11365
2016-02-24 15:24:13 -05:00
Juergen Hoeller ca19920d74 Refined ApplicationContextInitializer assignability exception 2016-02-24 17:50:14 +01:00
Juergen Hoeller a68b910b7c TimerScheduledFuture correctly calculates getDelay result
Issue: SPR-13977
2016-02-24 17:11:36 +01:00
Rossen Stoyanchev 46189b48fc Merge client REST test support updates
Includes support to declare expecations should occur multiple
times as well as in any order.

Issue: SPR-11365
2016-02-23 23:33:59 -05:00
Rossen Stoyanchev 91872b0d74 Add ExpectedCount
MockRestServicesServer now supports an expect variant that accepts
a range of expected count of executions.

Issue: SPR-11365
2016-02-23 23:31:34 -05:00
Rossen Stoyanchev 08a08725be Allow plugging in custom RequestExpectationManager
The MockRestServiceServer builder now has an option to plug in a
custom RequestExpectationManager.

Issue: SPR-11365
2016-02-23 23:31:33 -05:00
Rossen Stoyanchev a56c69c9ca Introduce MockRestServiceServer builder
MockRestServiceServer now provides static methods for builder-style
creation of MockRestServiceServer. This includes an option ignore
the order of declaration expected requests.

Issue: SPR-11365
2016-02-23 23:31:33 -05:00
Rossen Stoyanchev f58ef24efd Introduce RequestExpectationManager
This commit factors out the logic to declare and manage expectations
including matching them to requests and verifying at the end behind
a commong abstraction.

MockRestServiceServer delegates to the new abstraction and is no longer
aware of how that's done. There are two implementations, one for
ordered and another for unordered expectation.

Issue: SPR-11365
2016-02-23 23:31:33 -05:00
Rossen Stoyanchev 37a3fa96d1 Separate ResponseActions from ClientHttpRequest
Before this commit RequestMatcherClientHttpRequest served both as
API to define request expectations, i.e. ResponseActions, as well as
the implementation of ClientHttpRequest representing actual requests.

DefaultResponseActions replaces this class as a simple holder of
expected requests and mock responses. MockRestServiceServer is then
responsible to match request expectations and create a mock response.

Issue: SPR-11365
2016-02-23 23:31:33 -05:00
Sebastien Deleuze 3329abffc8 Allow to specify request body type in RestTemplate
This commit allows to specify the request body type in order to
serialize generic types with a GenericHttpMessageConverter if
needed.

Issue: SPR-13154
2016-02-23 16:15:38 +01:00
Juergen Hoeller 7b1fcfc7c3 Consistently strict parsing of date overflows (using java.time's strict resolution style)
Issue: SPR-13567
2016-02-23 16:12:26 +01:00
Juergen Hoeller 028a690100 Polishing 2016-02-23 14:31:09 +01:00
Juergen Hoeller ed98393fb2 SmartObjectFactory renamed to ObjectProvider (extends ObjectFactory)
Issue: SPR-13943
Issue: SPR-13956
2016-02-23 14:30:30 +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
Juergen Hoeller b9fe6d89da Avoid NPE in case of @Lazy @Autowired(required=false)
Issue: SPR-13967
2016-02-22 23:21:59 +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
Juergen Hoeller 2ca11029f2 Latest dependency updates (Caffeine 2.2, EhCache 3.0 M5, Groovy 2.4.6, Gson 2.6.1, Hibernate Validator 5.2.4, SLF4J 1.7.16, SnakeYAML 1.17) 2016-02-22 17:42:50 +01:00
Stephane Nicoll f4cbd98459 Upgrade to Undertow 1.3.18.Final 2016-02-22 16:48:29 +01:00
Rossen Stoyanchev b3d67b928b Check supported locales in AcceptHeaderLocaleResolver
Issue: SPR-13330
2016-02-22 09:44:06 -05:00
Stephane Nicoll a94ffbb17a Fix typo 2016-02-22 10:03:27 +01:00
Stephane Nicoll 963fea0e3f Merge pull request #934 from mnhock/Remove-unused-third-argument
* pr/934:
  Fix Format-string method arguments
2016-02-20 09:04:21 +01:00
mnhock e98977cbc8 Fix Format-string method arguments
Closes gh-934
2016-02-20 09:01:54 +01:00
Rossen Stoyanchev f32aded27a Consolidate CORS/OPTIONS request mapping
The CORS pre-flight request matching logic for all request conditions
was added (in 4.2) to RequestMappingInfo. However the logic for
default handling of all HTTP OPTIONS requests for 4.3 unintentionally
overrode some of the pre-flight request handling thus causing issues.

This commit moves CORS pre-flight matching logic into each respective
RequestMethodCondition implementations so each has to consider in one
place what happens for pre-flight and for all other requests.

Issue: SPR-13130
2016-02-19 13:56:52 -05:00
Rossen Stoyanchev 26575148a5 Polish test class 2016-02-19 13:56:52 -05:00
Juergen Hoeller 700ab2fc98 DataBinder test for java.util.Optional property
Issue: SPR-13933
2016-02-19 19:21:09 +01:00
Juergen Hoeller a7ad49adcf Placeholder configurers allow for trimming of property values
Issue: SPR-5839
2016-02-19 19:19:39 +01:00
Juergen Hoeller 890819f886 SmartObjectFactory provides getObject(args) variant as well
Issue: SPR-13956
2016-02-19 14:39:55 +01:00
Juergen Hoeller 5ed9046886 BeanMethodInterceptor does not pass on null arguments for singleton beans
Issue: SPR-13887
2016-02-19 14:00:52 +01:00
Stephane Nicoll d6700b7a10 Merge pull request #970 from wilkinsona/consistent-descriptions
* pr/970:
  Consistent descriptions for ConfigurationClass
2016-02-19 09:09:10 +01:00
Andy Wilkinson 65d144b1e5 Consistent descriptions for ConfigurationClass
Previously, a ConfigurationClass created from AnnotationMetadata
and a ConfigurationClass created from a class would have subtly
different descriptions. Given a class named com.example.Foo, the
former’s description would be “com.example.Foo”, whereas the latter’s
description would be “class com.example.Foo”.

This commit updates ConfigurationClass to make the description
consistent, preferring the description without “class” in it.

Closes gh-970
2016-02-19 09:08:55 +01:00
Rossen Stoyanchev f33578ef0f Fix failing test and warings
The test failure was caused by the previous commit. The Message
resolver now supports payload conversion so it can raise a
MessageConversionException, not MethodArgumentTypeMismatchException.
2016-02-18 22:37:57 -05: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 48ee9b52d4 Consistent check for Collection/Map beans
Issue: SPR-13963
2016-02-19 02:30:58 +01:00
Rossen Stoyanchev 18a59dad52 Minor Javadoc update 2016-02-18 18:11:59 -05:00
Rossen Stoyanchev 416966d943 Support Message argument with payload conversion
The MessageMethodArgumentResolver now also supports applying a
MessageConverter to the payload.

This is effectively a shortcut for declaring a method with an @Payload
argument + MessageHeaders and then creating a new message from the two.

Issue: SPR-13288
2016-02-18 18:09:16 -05:00
Rossen Stoyanchev ec3571fd4d Polish 2016-02-18 18:09:16 -05:00
Juergen Hoeller 1b53edfc5e DefaultListableBeanFactory skips fallback match attempt for Collection/Map beans
Issue: SPR-13963
2016-02-19 00:05:28 +01:00
Juergen Hoeller 0adc4921ed TestContextManager consistently handles Errors from listener invocations
Issue: SPR-13961
2016-02-18 21:07:32 +01:00
Rossen Stoyanchev 08eb623c41 Fix regression introduced in 4.3 snapshot
Commit ccd17d introduced a regression where a custom HTTP method
would no longer match for an empty @RequestMapping condition.

The previous behavior should now be restored. Effectively
RequestMethodRequestCondition as before will now match to any HTTP
method (even unknown/custom ones) if the methods condition is empty.
The only exception is HTTP OPTIONS for which we provide default
handling as a fallback (i.e. when not mapped explicitly).

Issue: SPR-13130
2016-02-18 14:37:36 -05:00
Brian Clozel 1c2ac49f2a Add weak ETag support in ShallowEtagHeaderFilter
This commit adds weak ETag support in ShallowEtagHeaderFilter.
This improves the behavior of the filter in tow ways:

* weak ETags in request headers such as `W/"0badc0ffee"` will be
compared with a "weak comparison" (matching both weak and strong ETags
of the same value)
* when enabled with the "writeWeakETag" init param, the filter will
write weak Etags in its HTTP responses

Issue: SPR-13778
2016-02-18 18:05:48 +01:00
Juergen Hoeller 923534595c ScriptUtils.executeSqlScript logs SQLWarnings at debug level
Issue: SPR-13959
2016-02-18 17:37:22 +01:00
Juergen Hoeller 8495fcf109 Avoid accessing the session if no session attributes need to be updated
Issue: SPR-13950
2016-02-18 17:33:39 +01:00
Juergen Hoeller 7fcb277de9 Consistent behavior for unwrap(null) on JPA and Bean Validation wrappers
Includes a fix for Query unwrapping before passing it to addNamedQuery.

Issue: SPR-13960
Issue: SPR-13957
2016-02-18 16:19:09 +01:00
Juergen Hoeller ea4a766df7 Consistent support for SpEL next to placeholders in annotation attributes
Issue: SPR-13625
2016-02-17 23:00:07 +01:00
Juergen Hoeller e0d7c6be00 Name attributes in method argument annotations allow for placeholders and expressions
Issue: SPR-13952
2016-02-17 22:59:12 +01:00
Sam Brannen c2f704717e Polish Javadoc for DefaultRequestToViewNameTranslator 2016-02-17 17:30:57 +00:00
Juergen Hoeller 25be5e060c TaskDecorator callback supported by common TaskExecutor implementations
Issue: SPR-13930
2016-02-17 16:58:02 +01:00
Juergen Hoeller ac44f9edd9 Consistent equals implementations across class hierarchies
Issue: SPR-13951
2016-02-17 16:57:29 +01:00
Brian Clozel ac3847bf4a Clarify Javadoc for CacheControl.noCache,noStore
This change makes clear that this is the intent of the CacheControl API
not to provide a way to configure both "no-cache" and "no-store"
directives for the "Cache-Control" header.

Issue: SPR-13780
2016-02-17 16:48:28 +01:00
Stephane Nicoll 513c1ea3d9 Update @author tag 2016-02-17 14:50:29 +01:00
Rossen Stoyanchev 43d72871bd Merge pull request #962 from matthew-pearson/master 2016-02-17 08:23:59 -05:00
Rossen Stoyanchev 024bd6e604 Polish 2016-02-17 08:23:18 -05:00
matthew-pearson 57b466fdfc 404 rather than 405 or 200
Check that the path is valid and resolvable before checking that the
http method is supported. For invalid or unresolvable paths, always
respond with a 404.
2016-02-17 08:23:18 -05:00
Stephane Nicoll a6d31d5212 Merge pull request #957 from soldierkam/cache-alloc
* pr/957:
  Polish contribution
  Decrease allocation rate for CacheOperation
2016-02-17 13:31:19 +01:00
Stephane Nicoll 37b3b24578 Polish contribution
Closes gh-957
2016-02-17 13:30:48 +01:00
soldierkam c73e52412a Decrease allocation rate for CacheOperation 2016-02-17 13:15:05 +01:00
Stephane Nicoll 7dac2e3256 Merge pull request #960 from logicg8/master
* pr/960:
  Polish doc
2016-02-17 13:12:23 +01:00
logicg8 6ce76314e7 Polish doc
Closes gh-960
2016-02-17 13:12:00 +01:00
Juergen Hoeller 5c87afc51d Polishing 2016-02-16 22:28:46 +01:00
Juergen Hoeller 1253b451f5 DefaultMessageListenerContainer stops if recovery failed after interrupt signal
Issue: SPR-11787
2016-02-16 22:28:10 +01:00
Juergen Hoeller 51c35bf81c SpringValidatorAdapter exposes String attributes as MessageSourceResolvable
Issue: SPR-13406
2016-02-16 22:16:19 +01:00
Juergen Hoeller a9d62372bf Upgrade to Hibernate ORM 5.1
Issue: SPR-13480
2016-02-16 13:58:05 +01:00
Juergen Hoeller 5e5bf7f518 Polishing 2016-02-16 13:57:08 +01:00
Juergen Hoeller e36b7531d8 Merge pull request #963 from poutsma/SPR-13942
Use synchonous API for synchonous OkHttp requests
2016-02-16 13:35:02 +01:00
Arjen Poutsma 37b32d38bc Use synchonous API for synchonous OkHttp requests
This commit changes the OkHttpClientHttpRequestFactory to use the
synchronous OkHttp API for non-async requests, as opposed to
synchronizing the async API (which it used to do).

Issue: SPR-13942
2016-02-16 12:16:10 +01:00
Juergen Hoeller 343bb2f130 Support for SmartObjectFactory injection points with programmatic optionality and lenient not-unique handling
Issue: SPR-13943
2016-02-12 17:45:25 +01:00
Juergen Hoeller b79e8a5cbc Support for Common Annotations 1.1 Resource.lookup() attribute
Issue: SPR-13941
2016-02-12 17:41:10 +01:00
Stephane Nicoll 268ebd7e89 Merge pull request #961 from gregturn/SPR-13940
* pr/961:
  Remove duplicate method from reference docs
2016-02-12 09:03:14 +01:00
Greg Turnquist 8cb35197ef Remove duplicate method from reference docs
Closes gh-681
Issue: SPR-13940
2016-02-12 09:02:31 +01:00
Juergen Hoeller 0dff782402 Fixed addProtocolResolver signature in ConfigurableApplicationContext
Issue: SPR-12857
Issue: SPR-13905
2016-02-11 22:47:41 +01:00
Juergen Hoeller f6ebc4ce97 Polishing 2016-02-11 22:24:50 +01:00
Juergen Hoeller 27c1280949 Consider negative contentLength() result as not resolvable
Issue: SPR-13571
2016-02-11 22:24:13 +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
Rossen Stoyanchev a1e9e6f53e Polish MVC Java config tests 2016-02-10 15:29:56 -05:00
Rossen Stoyanchev d53c04b4df Add option to extend exception resolvers
Issue: SPR-13931
2016-02-10 15:26:40 -05:00
Rossen Stoyanchev c45ad3022b Add "hosts" property to RedirectView
Issue: SPR-13693
2016-02-10 14:21:27 -05:00
Rossen Stoyanchev aba04d576f Polish RedirectViewTests 2016-02-10 14:21:27 -05:00
Juergen Hoeller 8558cbc9bf Polishing 2016-02-10 19:40:47 +01:00
Rossen Stoyanchev b11d345c0d Common base class for [Unknown]HttpStatusCodeException
Issue: SPR-13928
2016-02-10 11:21:59 -05:00
Juergen Hoeller 901c2d5f74 Consistent API between spring-web and spring-messaging HandlerMethod infrastructure
Issue: SPR-13929
2016-02-10 16:23:11 +01:00
Juergen Hoeller f61b998447 AbstractMarshaller defensively uses DocumentBuilderFactory within synchronized block
Issue: SPR-13935
2016-02-10 16:22:13 +01:00
Juergen Hoeller c788a8a260 Latest dependency updates (Joda-Time 2.9.2, OkHttp 2.7.4, SLF4J 1.7.15) 2016-02-10 16:20:28 +01:00
Brian Clozel 0ab3f6092c Fix failing tests
Issue: SPR-13913
2016-02-10 13:48:49 +01:00
Stephane Nicoll a4a3cda29f Upgrade to undertow 1.3.17 2016-02-10 13:02:22 +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
Rossen Stoyanchev cdfcc23b6f Reduce log level for @ExceptionHandler failure
Issue: SPR-13932
2016-02-09 12:57:02 -05:00
Rossen Stoyanchev 29cd1808b7 Upgrade to Tomcat 8.0.32 2016-02-08 10:57:42 -05:00
Juergen Hoeller 43bcab9c1a ReflectiveMethodResolver lets local static methods override java.lang.Class methods
Issue: SPR-13918
2016-02-08 13:23:02 +01:00
Juergen Hoeller 903ae48382 DisposableBeanAdapter ignores bridge method conflicts
Issue: SPR-13922
2016-02-08 13:20:48 +01:00
Juergen Hoeller 449f704650 PathMatchingResourcePatternResolver consistently logs retrieval results
Issue: SPR-13923
2016-02-08 13:18:43 +01:00
Juergen Hoeller afe7bf2695 Latest dependency updates (Hibernate Validator 5.2.3, OkHttp 2.7.2, Netty 4.0.34, Undertow 1.3.16) 2016-02-05 17:17:00 +01:00
Rossen Stoyanchev e4539d9f40 Add protected method for required RequestBody 2016-02-05 02:24:03 -05:00
Rossen Stoyanchev 7756feacd8 Polish 2016-02-05 00:04:59 -05:00
Rossen Stoyanchev 1291d6e1bd Support CharSequence for response body
Issue: SPR-13423
2016-02-04 23:55:48 -05:00
Rossen Stoyanchev 902a7287f7 Fix NPE in InvocableHandlerMethod
Issue: SPR-13917
2016-02-04 23:32:22 -05:00
Rossen Stoyanchev 09a40b8a08 Improve close in ConcurrentWebSocketSessionDecorator
Before this commit the concurrent session wrapper mainly protected the
sending of messages. The close itself however may also cause a message
to be sent as is the case of the SockJS protocol.

This change protects the close and checks if the session has exceeded
send time or buffer limits in which case the close status is changed
to SESSION_NOT_RELIABLE (introduced in commit cbd5af3a) which in turn
signals that extra care should be exercised when closing the session.

Issue: SPR-13904
2016-02-04 17:23:16 -05:00
Rossen Stoyanchev 7ed2b8fd81 Polish WebSocket session decorator and tests 2016-02-04 17:23:16 -05:00
Sam Brannen 26edc674ed Polish Javadoc for resource-based MessageSources 2016-02-04 21:32:37 +01:00
Rossen Stoyanchev b49235ac59 BufferedImage converter writes Content-Type again
Issue: SPR-13906
2016-02-04 14:59:13 -05:00
Juergen Hoeller e90310612f Polishing 2016-02-04 20:00:00 +01:00
Juergen Hoeller f108deb114 (Reloadable)ResourceBundleMessageSource allows for adding resources
This turned into the extraction of a common AbstractResourceBasedMessageSource base class which not only features addBasenames but also getBasenameSet and setCacheMillis.

Issue: SPR-10314
2016-02-04 19:57:40 +01:00
Juergen Hoeller 28e8af2e2e AbstractXlsView does not explicitly flush (for compatibility with WebSphere Liberty)
Issue: SPR-13910
2016-02-04 19:48:05 +01:00
Sam Brannen 81f68463ec Clean up warnings in Gradle build 2016-02-03 18:42:30 +01:00
Sam Brannen 677a321571 Support primary TxMgrs and DataSources in the TCF
Prior to this commit, the transaction manager and data source look-up
algorithms in the Spring TestContext Framework were not capable of
retrieving 'primary' beans of those types, even though 'primary' beans
are supported in production as well as for injecting dependencies into
test instances. Specifically, if there was more than one transaction
manager or data source bean and one of them was flagged as 'primary',
the retrieveTransactionManager() and retrieveDataSource() methods in
TestContextTransactionUtils would simply return null for such beans.

This commit updates TestContextTransactionUtils by adding support for
looking up primary transaction managers and data sources.

Issue: SPR-13891
2016-02-03 17:58:33 +01:00
Sam Brannen 6d2b9a0136 Throw exception if TxMgr cannot be retrieved for @Transactional test
Prior to this commit, a @Transactional integration test would silently
be executed without a transaction if the transaction manager could not
be retrieved from the application context -- for example, it no such
bean was defined or if multiple beans were present but none satisfied
the qualifier.

This commit addresses this issue by throwing an IllegalStateException
if the PlatformTransactionManager cannot be retrieved for a
@Transactional test.

Issue: SPR-13895
2016-02-03 14:56:27 +01:00
Rob Winch d6648a06c9 Add Code of Conduct 2016-02-01 14:37:35 -06:00
Rossen Stoyanchev e81c7dfc4c Polish SendToMethodReturnValueHandlerTests 2016-01-29 16:16:21 -05:00
Rossen Stoyanchev 03e3ef53ab @SendToUser supported on the class level
Issue: SPR-12047
2016-01-29 16:10:02 -05:00
Rossen Stoyanchev bedf1a9bd0 Polish UriTemplateTests 2016-01-29 15:39:02 -05:00
Rossen Stoyanchev f5aa011722 UriComponents support for array query params
Issue: SPR-9712
2016-01-29 15:32:42 -05:00
Rossen Stoyanchev aa064d7653 Polish MVC config tests 2016-01-29 14:58:32 -05:00
Rossen Stoyanchev 1cf0fb8174 Shared custom argument resolvers
Custom argument resolvers configured in the MVC Java config or the
MVC namespace are now injected in both the RequestMappingHandlerAdapter
as well as in the ExceptionHandlerExceptionResolver.

Issue: SPR-12058
2016-01-29 14:49:25 -05:00
Sam Brannen ea46ad8022 Clean up warnings in spring-test 2016-01-28 19:27:53 +01:00
Sam Brannen 3cf5cfd672 Fix Javadoc 2016-01-28 19:00:37 +01:00
Sam Brannen 468f083ab0 Use proper syntax highlighting for XML examples 2016-01-28 19:00:37 +01:00
Brian Clozel d157ce598b Upgrade to undertow 1.3.15.Final 2016-01-28 18:52:40 +01:00
Stephane Nicoll aed56ea732 Upgrade to Caffeine 2.1.0 2016-01-28 16:50:29 +01:00
Stephane Nicoll ccbfd44862 Merge pull request #949 from bclozel/sonarplugin
* pr/949:
  Use the official SonarQube Gradle plugin
2016-01-27 10:32:30 +01:00
Brian Clozel 0ecede028c Use the official SonarQube Gradle plugin
Since the build has been upgraded to Gradle 2.10, it's showing the
following message:
"The 'sonar-runner' plugin has been deprecated and is scheduled to be
removed in Gradle 3.0. please use the official plugin from SonarQube"

This commit makes use of the "org.sonarqube" Gradle plugin and uprgrades
the Jacoco agent version to 0.7.5.

See: https://sonar.spring.io/updatecenter/updates
See: https://jira.sonarsource.com/browse/SONARJAVA-1091

Closes gh-949
2016-01-27 10:25:14 +01:00
Rossen Stoyanchev 2e7470b27f Allow binding=false on @ModelAttribute
Issue: SPR-13402
2016-01-26 23:51:18 -05:00
Rossen Stoyanchev 806e79b14b Polish 2016-01-26 23:20:58 -05:00
Rossen Stoyanchev e62ada898b Add @RequestAttribute with servlet-based support
Issue: SPR-13894
2016-01-26 16:37:50 -05:00
Rossen Stoyanchev 698f923fc3 Add @SessionAttribute with Servlet-based support
Issue: SPR-13894
2016-01-26 16:37:44 -05:00
Juergen Hoeller 7df3a327f6 Polishing 2016-01-26 22:29:48 +01:00
Juergen Hoeller 3779fe9bf6 @UsesJava8 declaration on inner class
Issue: SPR-13850
2016-01-26 18:18:27 +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 a3a5a03ee3 PropertySource annotation allows for custom encoding
Issue: SPR-13874
2016-01-26 18:00:05 +01:00
Rossen Stoyanchev 2607a22537 HTTP OPTIONS lists all HTTP methods except TRACE
This is in line with the current behavior of HttpServlet that would
have been in used with dispatchOptionsRequest on the DispatcherSerlvet
set to false (the default prior to 4.3).

Issue: SPR-13130
2016-01-25 16:35:23 -05:00
Rossen Stoyanchev 319e8e2c2f Add allowHeader property to WebContentGenerator
The WebContentGenerator now maintains an additional property that
sub-classes can use for an "Allow" header in response to an HTTP
OPTIONS request. This property is pre-initialized once at startup
and does not have to rely on getSupportedMethods in addition to
adding HTTP OPTIONS if not explicitly listed.

Issue: SPR-13130
2016-01-25 16:35:15 -05:00
Juergen Hoeller 4a0fa69ce4 Injection support for Collection/Map beans and self references
Issue: SPR-13585
Issue: SPR-12180
Issue: SPR-7915
Issue: SPR-8450
2016-01-25 21:25:48 +01:00
Juergen Hoeller 64e77de23b LocalSessionFactoryBuilder provides ClassLoader to Hibernate BootstrapServiceRegistry
Issue: SPR-13879
2016-01-25 21:02:41 +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 d18b3f049a Tests for @Enable/@ComponentScan without @Configuration
Issue: SPR-10660
2016-01-25 20:32:45 +01:00
Juergen Hoeller c95dfca726 Log profile-based exclusion of XML bean definition file
Issue: SPR-10202
2016-01-25 20:26:12 +01:00
Juergen Hoeller 837cb752a4 Clarify component scan include-filter semantics
Issue: SPR-13844
2016-01-25 20:24:26 +01:00
Juergen Hoeller ebad8db8d5 Clarify environment property precedence rules
Issue: SPR-13845
2016-01-25 20:23:25 +01:00
Juergen Hoeller 64d83e78ea Latest dependency updates (Hibernate ORM 5.0.7, Jetty 9.3.7, Undertow 1.3.14, SLF4J 1.7.14) 2016-01-25 20:18:54 +01:00
Rossen Stoyanchev e14f42f386 Update reference for HTTP HEAD and OPTIONS support
Issue: SPR-13130
2016-01-25 08:49:04 -05:00
Rossen Stoyanchev 135738f9bf AbstractController supports HTTP OPTIONS
Issue: SPR-13130
2016-01-25 08:49:04 -05:00
Sebastien Deleuze a730e55d92 Add support for Jackson 2.7
AbstractJackson2HttpMessageConverter now implements its own
TypeVariable resolution algorithm since in Jackson 2.7 it is now
deprecated and has not the same behavior .
See https://github.com/FasterXML/jackson-databind/issues/1087
for more details.

The dependency on jackson-datatype-jdk7 has been removed since
it is now provided by default in the jackson-databind module.

Issues: SPR-13483, SPR-13728
2016-01-25 09:38:16 +01:00
Rossen Stoyanchev ccd17dfaea Support HTTP OPTIONS
Issue: SPR-13130
2016-01-24 20:18:41 -05:00
Rossen Stoyanchev d70ad765bf Support HTTP HEAD
Issue: SPR-13130
2016-01-24 20:18:41 -05:00
Rossen Stoyanchev fb7dfc4569 Polish 2016-01-24 20:18:35 -05:00
Brian Clozel 2b3ad218e5 Clarify RequestMappingHandlerAdapter javadoc
This commit updates the javadoc of
`RequestMappingHanderAdapter.setCacheSecondsForSessionAttributeHandlers`
to explain how one can disable that feature and prevent "Cache-Control"
directives from being added when `@SessionAttributes` annotations are
used on Controllers.

Issue: SPR-13598
2016-01-22 21:17:58 +01:00
Brian Clozel 84fe46cd43 Register prefixed path patterns with FixedVersionStrategy
Prior to this change, configuring a `FixedVersionStrategy` like so
would configure a single "/js/**" path pattern:

```
versionResourceResolver.addFixedVersionStrategy("v1.0.0","/js/**");
```

This commit makes sure that for each path pattern, its prefixed version
is added to the map. For example, the previous configuration also
adds "/v1.0.0/js/**".

Issue: SPR-13883
2016-01-22 18:30:39 +01:00
Brian Clozel 8f1d06f19c Reorder HTTP headers processing in RequestMappingHandlerAdapter
Prior to this change, the `RequestMappingHandlerAdapter` would first add
a "Cache-Control" HTTP header to the response (depending on its
`WebContentGenerator` configuration and `@SessionAttributes` on the
handler class); then, the Adapter would delegate the actual handler the
processing of the request.
This leads to issues, as the handler does not have full control to the
response and has to deal with pre-existing headers in the response. This
means that the Adapter and the handler can add incompatible
Cache-Control directives without knowing it, since one cannot see the
headers added by the other until the response is committed.

This commit switches the order of execution: first, the handler is
called (possibly adding HTTP headers), then the RMHA processes the
response and adds "Cache-Control" directives *only if there's no
Cache-Control header already defined*.

Issue: SPR-13867
2016-01-22 16:04:03 +01:00
Rossen Stoyanchev ebccfd023a MVC Java config protected factory methods
This change exposes protected methods for instantiating sub-classes of
RequestMappingHandlerAdapter and ExceptonHandlerExceptionResolver
similar to the existing method for RequestMappingHandlerMapping.
2016-01-22 09:48:50 -05:00
Rossen Stoyanchev 9cc518d167 Polish StringHttpMessageConverterTests 2016-01-22 09:40:33 -05:00
Stephane Nicoll cd903e26de Polish 2016-01-22 04:35:33 +01:00
Andy Clement a12f23936c Allow use of '&' prefix to access factory bean in SpEL
Prior to this change SpEL did not have an syntactic
construct enabling easy access to a FactoryBean. With this
change it is now possible to use &foo in an expression when
the factory bean should be returned.

Issue: SPR-9511
2016-01-21 16:14:16 -08:00
Rossen Stoyanchev 415b2763ce MockHttpServletRequestBuilder parses form data
Spring MVC Test now parses application/x-www-form-urlencoded request
content and populates request parameters from it.

This can be useful when running client-side tests against a MockMvc
via MockMvcClientHttpRequestFactory.

Issue: SPR-13733
2016-01-21 17:26:23 -05:00
Rossen Stoyanchev 6a9455b7d0 Fix failing test 2016-01-21 17:05:05 -05:00
Rossen Stoyanchev 1416c2a00e ContentRequestMatchers asserts request with form data
Issue: SPR-13044
2016-01-21 12:42:33 -05:00
Brian Clozel 2f6d86b7aa Fix OutOfBoundsExceptio in ResourceUrlEncodingFilter
Prior to this change, the `ResourceUrlEncodingFilter` would try to
lookup resources URLs as soon as the given URL would be longer than the
expected context+servlet prefix path. This can lead to
OutOfBoundsExceptions when the provided URL does not start with that
prefix and still has the required length.

This commit makes sure that all candidate URLs for resources lookup are
prefixed with the cached servlet and context path. This underlines the
fact that the `ResourceUrlEncodingFilter` does not support relative URLs
for now and delegates to the native servlet implementation in that case.

Issue: SPR-13861
2016-01-21 17:28:29 +01:00
Rossen Stoyanchev 952a3170e6 HeaderResultMatchers supports multi-value headers
Issue: SPR-10087
2016-01-21 11:19:43 -05:00
Rossen Stoyanchev ae224bed3e Polish HeaderResultMatchers 2016-01-21 10:20:04 -05:00
Rossen Stoyanchev 18db77da7c Merge pull request #927 from ksokol-improvement/SPR-13719 2016-01-21 09:14:27 -05:00
Rossen Stoyanchev df223eb118 Polish custom HTTP verb in Spring MVC Test
Issue: SPR-13719
2016-01-21 09:13:33 -05:00
Kamill Sokol 3554348919 Support custom HTTP verbs in Spring MVC Test
Prior to this commit, Spring MVC Test only supported HTTP methods GET,
POST, HEAD, OPTIONS, PUT, PATCH, DELETE, TRACE and multipart file
upload. This change adds generic methods to MockMvcRequestBuilders in
order to allow testing of arbitrary HTTP methods in a Spring MVC
application.

Issue: SPR-13719
2016-01-21 09:12:43 -05:00
Rossen Stoyanchev 9e16cbda4c Polish ServletServerHttpRequest change 2016-01-20 17:50:36 -05:00
Sammy Chu 5185953f29 Avoid double encoding URI in ServletServerHttpRequest
Issue: SPR-13876
2016-01-20 17:42:40 -05:00
Rossen Stoyanchev a5f4aa6824 Add HttpStatus to ModelAndView
Issue: SPR-13560
2016-01-20 16:54:05 -05:00
Stephane Nicoll 29700658d4 Support Quartz trigger without JobDetail
This commit allows to create a Quartz trigger implementation via
either `CronTriggerFactoryBean` or `SimpleTriggerFactoryBean` even if no
job detail is provided.

Issue: SPR-13604
2016-01-19 18:03:03 +01:00
Stephane Nicoll 0d04af14f8 Refine test
Issue: SPR-13837
2016-01-19 15:11:58 +01:00
Stephane Nicoll 9b9df6a744 Add test
Issue: SPR-13837
2016-01-19 14:40:52 +01:00
Stephane Nicoll 714ae2684c Support for global separator in JDBC namespace
Previously, if a database needs to be initialized with several scripts
and many (or all) use a custom separator, said separator must be repeated
for each script.

This commit introduces a `separator` property at the parent element level
that can be used to customize the default separator. This is available
for both the `initialize-database` and `embedded-database` elements.

Issue: SPR-13792
2016-01-18 16:09:07 +01:00
Stephane Nicoll eb49f3c225 Add interface-based detection test
Add a test that explicitely validates that `@ManagedResource` and friends
can be set on an interface.

Issue: SPR-13138
2016-01-18 14:14:17 +01:00
Stephane Nicoll a112557dc4 Support SendTo at class-level
Issue: SPR-13578
2016-01-16 16:34:02 +01:00
Rossen Stoyanchev 73a794336c Support @ResponseStatus on controller type level
Issue: SPR-13547
2016-01-15 17:15:34 -05:00
Rossen Stoyanchev 4b1183582a Add methodCall option to HandlerResultMatchers
Issue: SPR-13736
2016-01-15 12:44:00 -05:00
Rossen Stoyanchev 1320da906b Polish HandlerResultMatchers 2016-01-15 12:44:00 -05: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
Juergen Hoeller 182b1e99e3 TODO marker for test which fails as of AspectJ 1.9 beta 3
Issue: SPR-13839
2016-01-15 17:43:59 +01:00
Stephane Nicoll dc8de51408 Json view support for JMS
Support of @JsonView on @JmsListener annotated method that uses the
jackson converter. Also update MappingJackson2MessageConverter to offer
a public API to set the JSON view to use to serialize a payload.

Issue: SPR-13237
2016-01-15 17:18:14 +01:00
Juergen Hoeller cdc9bf76a9 SessionDisconnectEvent actually preserves given session user
Issue: SPR-13871
2016-01-15 17:03:17 +01:00
Juergen Hoeller 9761af9ad8 Validate @RequestMapping methods on AOP proxies
Issue: SPR-13842
2016-01-15 17:01:58 +01:00
Juergen Hoeller c1352c1201 Upgrade to AspectJ 1.9 beta 3 (for build compatibility with JDK 9 build 95+)
Issue: SPR-13839
2016-01-15 17:01:10 +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
Rossen Stoyanchev 037f351efd Replace anonymous impls with ListenableFutureAdapater
Before this change AsyncRestTemplate had two anonymous implementations
of ListenableFuture that were adapting the result. Those have been
replaces with ListenableFutureAdapter.

This commit is preparation for SPR-13785.
2016-01-14 16:47:55 -05:00
Ian Chan 93298fc9fa Catch RejectedExecutionException in WebAsyncManager
Issue: SPR-13836
2016-01-14 15:47:00 -05:00
Rossen Stoyanchev 4818378c25 Better document client-side tests against MockMvc
Issue: SPR-13815
2016-01-14 15:15:07 -05:00
Rossen Stoyanchev 7690f27c5e Add MediaType constants for application/pdf
Issue: SPR-13831
2016-01-14 14:57:09 -05:00
Rossen Stoyanchev f3c2bb6557 Fix error message in RestTemplate
Issue: SPR-13860
2016-01-14 14:52:10 -05:00
Rossen Stoyanchev 24fdf64d91 Fix javadoc issue in ResponseEntityExceptionHandler
Issue: SPR-13869
2016-01-14 14:25:30 -05:00
Rossen Stoyanchev e56587dcc3 Add note to @CrossOrigin javadoc
Issue: SPR-13857
2016-01-14 14:13:53 -05:00
Stephane Nicoll 31a3607de6 Lazy resolution of the JMS message
Previously, any `javax.jms.Message` was converted eagerly to the Message
abstraction. This leads to unnecessary conversion if the Payload is not
requested by the underlying method (i.e. if the `javax.jms.Message` is
injected directly).

This commit returns a `Message` implementation that holds the
`javax.jms.Message` and lazily resolve the payload or the headers on
demand (that is the first time they are requested).

Issue: SPR-13777
2016-01-14 17:20:25 +01:00
Juergen Hoeller 50829c9fdc Shared EntityManager does not insist on actualTransactionActive flag anymore
Issue: SPR-13838
2016-01-13 14:11:13 +01:00
Juergen Hoeller 773d175681 Polishing 2016-01-13 12:52:05 +01:00
Juergen Hoeller e14c2de1d2 ImportStack extends ArrayDeque instead of Stack and relies on standard contains implementation
Issue: SPR-13852
2016-01-13 12:46:28 +01:00
Juergen Hoeller 5d4547d343 FastByteArrayInputStream consistently returns -1 when no data available
Issue: SPR-13858
2016-01-13 12:44:34 +01:00
Stephane Nicoll 96cb0e6bd6 Upgrade to Undertow 1.3.12 2016-01-12 16:34:13 +01:00
Stephane Nicoll ee946f6ac6 Fix typo 2016-01-12 15:05:59 +01:00
Dennis Kieselhorst 554bf4958d Improve Content-Length exception message
In case ShallowEtagHeaderFilter is not used, the message was confusing
2016-01-08 09:30:31 +01:00
Brian Clozel cdda839426 XML configuration support for RFC 5861
This commit adds the XML+XSD configuration part of the RFC 5861
Cache-Control directives added in Spring's `CacheControl`.

Issue: SPR-13841
2016-01-07 18:13:34 +01:00
madorb 6c282096c6 Add RFC-5681 support to CacheControl
This commit adds the "stale-while-revalidate" and "stale-if-error"
Cache-Control directives in the `CacheControl` support class.

Issue: SPR-13841
2016-01-07 18:13:26 +01:00
Brian Clozel d681f77d62 Polish
Issue: SPR-13817
2016-01-05 17:31:30 +01:00
Brian Clozel 473cf9c40e Preserve ETag HTTP header for versioned resources
Prior to this change, a resource handler chain configured with a
`VersionResourceResolver` would add the resource version to the request
attributes when serving that resource. This approach would not work when
a `CachingResourceResolver` is configured and the resource is already
cached. Indeed, that code path is not executed when the resource is
resolved from the cache.

This commit adds a new `VersionedResource` interface that's used by the
`VersionResourceResolver`, adding a `getVersion()` method that returns
the version string for that resource. This way, the version information
is cached with the resource itself and the request attributes are no
longer used for this.

Issue: SPR-13817
2016-01-05 14:55:14 +01:00
Stephane Nicoll 6e7e4c0359 Merge pull request #948 from kamilszymanski/jcache-docs
* pr/948:
  Fix list of supported JCache annotations
2016-01-05 08:15:02 +00:00
Kamil Szymanski fca7c52236 Fix list of supported JCache annotations
Closes gh-948
2016-01-05 08:13:06 +00:00
Juergen Hoeller 04f31816bd Avoid getTypeForFactoryBean warn logging for lazy-init beans
Issue: SPR-13833
2015-12-31 11:47:46 +01:00
Juergen Hoeller 9bffb9e53f Refined RequestMappingHandlerMapping bean definition
Issue: SPR-13832
2015-12-31 11:44:12 +01:00
holub 9152f20bc1 Update SockJS client code snippet 2015-12-30 10:21:46 +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 388bd87ef0 ComponentScan annotation is repeatable now
Issue: SPR-13151
2015-12-29 21:40:08 +01:00
Juergen Hoeller aecb8b6c6b Avoid sensitive Proxy.getInvocationHandler call in synthesizeAnnotation
Issue: SPR-13829
2015-12-29 21:39:43 +01:00
Brian Clozel 74d3bceb19 Add missing StatusResultMatcher for HTTP Status 451
Issue: SPR-13632
2015-12-29 21:23:09 +01:00
Brian Clozel 9e4cf85af7 Add HTTP Status 451 UNavailable for legal reasons
Issue: SPR-13632
2015-12-29 20:51:42 +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 e48ec4fcd3 StatementCreatorUtils always tries getParameterType on Oracle 12c driver
Issue: SPR-13825
2015-12-29 11:19:21 +01:00
Juergen Hoeller 1d8a3e1f07 BeanFactoryAnnotationUtils searches on bean implementation classes and meta-annotations as well
Issue: SPR-13819
Issue: SPR-13452
2015-12-28 23:28:08 +01:00
Stephane Nicoll 7d0ebddebe Flag Caffeine as Java8+ only
See also SPR-13824
2015-12-28 15:06:35 +01:00
Juergen Hoeller 826a00a56a Expect IllegalStateException instead of specific message for @Scheduled proxy mismatch
Issue: SPR-13816
2015-12-24 12:38:26 +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
Rossen Stoyanchev 63958ac0ff Fix concurrent test failure
Since ListenableFuture callbacks are invoked after the future is set,
we cannot rely on callbacks having taken place right after a call
to future.get(). This change adds a CountdownLatch to detect when
the callbacks were invoked.

Issue: SPR-12538
2015-12-22 22:07:55 -05:00
Juergen Hoeller 873b173dcc Upgrade to Undertow 1.3.11 2015-12-23 01:18:55 +01:00
Juergen Hoeller 1cfeb07fa5 Consistent use of varargs plus related polishing
(cherry picked from commit deae872)
2015-12-23 00:31:11 +01:00
Rossen Stoyanchev bc671f05d6 Fix test warnings 2015-12-22 17:52:56 -05:00
Rossen Stoyanchev 258cc7b27f Update AsyncRestTemplate interception
AsyncRequestExecution now properly supports decoration of the
request (URI, HTTP method, and headers).

Removed a no-op IdentityListenableFutureAdapter.

Use Spring Framework coding style.

Issue: SPR-12538
2015-12-22 17:36:24 -05:00
Jakub Narloch 12969f6268 SPR-12538 AsyncRestTemplate interceptors 2015-12-22 16:21:47 -05:00
Rossen Stoyanchev 74b77e0d74 Fix warnings 2015-12-22 16:16:51 -05:00
Rossen Stoyanchev 12b73caa84 Add @RestControllerAdvice
Issue: SPR-13673
2015-12-22 16:11:34 -05:00
Rossen Stoyanchev 8656186f60 Support for public WebSocket upgrade API in Undertow
Issue: SPR-13593
2015-12-22 15:26:31 -05:00
Juergen Hoeller 4adb7e2500 AOP proxies with annotation-based aspects are serializable now
Issue: SPR-6910
2015-12-22 21:20:33 +01:00
Juergen Hoeller bb0bc3d415 Polishing 2015-12-22 16:19:26 +01:00
Juergen Hoeller 95d62658ff SystemEnvironmentPropertySource replaces hyphens in property names as well
Issue: SPR-13594
2015-12-22 16:18:13 +01:00
Stephane Nicoll 07fd7b905e Update What's new section 2015-12-22 14:50:34 +01:00
Stephane Nicoll 0194988425 Store by value support for ConcurrentMapCacheManager
ConcurrentMapCacheManager and ConcurrentMapCache now support the
serialization of cache entries via a new `storeByValue` attribute. If it is
explicitly enabled, the cache value is first serialized and that content
is stored in the cache.

The net result is that any further change made on the object returned
from the annotated method is not applied on the copy held in the cache.

Issue: SPR-13758
2015-12-22 13:50:23 +01:00
Juergen Hoeller cf20308134 SerializationDelegate as convenient Serializer/Deserializer combo
Issue: SPR-13758
2015-12-22 13:04:10 +01:00
Juergen Hoeller 41ee25b1e7 Convenience constructors for common view prefix/suffix scenarios
Issue: SPR-13813
2015-12-22 12:00:49 +01:00
Stephane Nicoll 66dd880335 Update What's new section 2015-12-22 11:33:26 +01:00
Stephane Nicoll d444ef4871 Support for bean refs in event SpEL condition
Issue: SPR-13814
2015-12-22 11:30:40 +01:00
Stephane Nicoll 9b5e47026c Support for bean refs in caching SpEL expressions
Issue: SPR-13182
2015-12-22 11:05:24 +01:00
Juergen Hoeller 1ce9788a66 Upgrade to Gradle 2.10
Issue: SPR-13484
2015-12-21 23:08:19 +01:00
Juergen Hoeller bb3ff25cad Polishing 2015-12-21 23:07:32 +01:00
Juergen Hoeller 57b3ee324f Tiles 2 support back for Spring 4.3 (to be eventually removed for 5.0 now)
Issue: SPR-13229
2015-12-21 22:15:22 +01:00
Juergen Hoeller dd930b3b66 Allow for customizing the Hibernate MetadataSources instance
Issue: SPR-13710
2015-12-21 21:38:11 +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 4668aa775d Language tag methods declared as @UsesJava7
Issue: SPR-13274
2015-12-21 19:08:37 +01:00
Juergen Hoeller b28310d0b9 Polishing 2015-12-21 18:42:49 +01:00
Juergen Hoeller 0dd320f92e Support for BCP 47 language tags
Issue: SPR-13032
2015-12-21 18:40:26 +01:00
Juergen Hoeller cad2ce0ac2 ConstructorResolver always uses arguments when completely provided
Issue: SPR-13808
2015-12-21 15:11:40 +01:00
Juergen Hoeller 09cea6e6bb Refined Future exception handling
Issue: SPR-13732
2015-12-21 15:09:09 +01:00
Stephane Nicoll d59b0d12d4 Merge pull request #939 from sniewczas/patch-1
* pr/939:
  Fix markup in reference section 9.4.2
2015-12-21 14:55:45 +01:00
Sylwester Niewczas adf744cce0 Fix markup in reference section 9.4.2
Closes gh-939
2015-12-21 14:55:14 +01:00
Stephane Nicoll 1fc3fc8bf7 Update documentation
Issue: SPR-13471
2015-12-21 14:47:50 +01:00
Stephane Nicoll edd8e2d56d Update documentation
Issue: SPR-12278
2015-12-21 14:23:14 +01:00
Stephane Nicoll 19d97c4253 Support for multi-threaded cache access
Previously, if a `@Cacheable` method was accessed with the same key by
multiple threads, the underlying method was invoked several times instead
of blocking the threads while the value is computed. This scenario
typically affects users that enable caching to avoid calling a costly
method too often. When said method can be invoked by an arbitrary number
of clients on startup, caching has close to no effect.

This commit adds a new method on `Cache` that implements the read-through
pattern:

```
<T> T get(Object key, Callable<T> valueLoader);
```

If an entry for a given key is not found, the specified `Callable` is
invoked to "load" the value and cache it before returning it to the
caller. Because the entire operation is managed by the underlying cache
provider, it is much more easier to guarantee that the loader (e.g. the
annotated method) will be called only once in case of concurrent access.

A new `sync` attribute to the `@Cacheable` annotation has been addded.
When this flag is enabled, the caching abstraction invokes the new
`Cache` method define above. This new mode bring a set of limitations:

* It can't be combined with other cache operations
* Only one `@Cacheable` operation can be specified
* Only one cache is allowed
* `condition` and `unless` attribute are not supported

The rationale behind those limitations is that the underlying Cache is
taking care of the actual caching operation so we can't really apply
any SpEL or multiple caches handling there.

Issue: SPR-9254
2015-12-21 13:34:35 +01:00
Stephane Nicoll 15c7dcd11a Upgrade Caffeine to 2.0.3 2015-12-20 13:06:11 +01:00
Sam Brannen 66562f2589 Require JUnit 4.12 or higher in the TestContext framework
Issue: SPR-13275
2015-12-19 18:43:59 +01:00
Juergen Hoeller db1171d5c4 Background bootstrapping via "bootstrapExecutor" for LocalContainerEntityManagerFactoryBean and LocalSessionFactoryBean/Builder
Issue: SPR-13732
2015-12-19 15:13:46 +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 06056e6aa6 Upgrade to JavaMail 1.5.5 and Hibernate ORM 5.0.6 2015-12-18 17:49:15 +01:00
Juergen Hoeller 2e6eb614b5 Avoid scoped destruction callbacks in case of no post-processor actually applying
Issue: SPR-13744
2015-12-18 17:14:57 +01:00
Juergen Hoeller fca5365cf1 Avoid scoped destruction callbacks in case of no post-processor actually applying
Issue: SPR-13744
2015-12-18 16:54:05 +01:00
Stephane Nicoll 1502e49fa5 Merge pull request #921 from ben-manes/caffeine
* pr/921:
  Polish contribution
  Add caching support for Caffeine
  Detect @Autowired constructors for configuration classes
2015-12-18 15:47:33 +01:00
Stephane Nicoll 3a238a2b61 Polish contribution
Closes gh-921

Issue: SPR-13690
2015-12-18 15:47:13 +01:00
Ben Manes 13aabeef37 Add caching support for Caffeine
Issue: SPR-13690
2015-12-18 15:47:13 +01:00
Juergen Hoeller 967ef73765 Detect @Autowired constructors for configuration classes
Issue: SPR-13471
2015-12-18 15:31:31 +01:00
Stephane Nicoll 9e7c791a0f Automatically autowire a bean with one constructor
Previously, if a managed bean had only one non-default constructor, we
should still annotate it with `@Autowired` to properly use constructor
injection. Not doing so resulted in an error as the container was
trying to call the default (non-existing) constructor.

This commit updates this behaviour to automatically applyed the
autowiring semantic to any bean that has only one constructor. As
before, if more than one constructor is defined, `@Autowired` must be
specified to teach the container the constructor it has to use.

Issue: SPR-12278
2015-12-18 14:04:18 +01:00
Juergen Hoeller 3d87718fc6 DispatcherServlet and ServletWrapping/ForwardingController accept any HTTP method by default
Issue: SPR-4799
2015-12-18 12:57:18 +01:00
Juergen Hoeller 08748ecaa4 PathMatchingResourcePatternResolver evaluates classpath manifest entries as well
Issue: SPR-13685
2015-12-18 12:17:57 +01:00
Juergen Hoeller 2cfe00ce32 Updated reference documentation from Hibernate 3 to Hibernate 5
Issue: SPR-13230
2015-12-18 00:27:19 +01:00
Juergen Hoeller 0084c077bb Aligned import order 2015-12-18 00:19:40 +01:00
Juergen Hoeller 760668c034 Polishing 2015-12-18 00:09:39 +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 0e68d2e951 Explicit references to spring-mvc-4.2.xsd for Velocity declarations
Issue: SPR-13235
2015-12-17 18:30:11 +01:00
Sam Brannen 9eb713ae2c Mention DCBeforeModesTEL in TestExecutionListener Javadoc 2015-12-17 17:45:08 +01:00
Juergen Hoeller b75f5faf88 Remove Tiles 2 support
Issue: SPR-13229
2015-12-17 17:18:21 +01:00
Juergen Hoeller e90942223f Deprecate Hibernate 3 support
Issue: SPR-13230
2015-12-17 17:17:05 +01:00
Juergen Hoeller a2a9c47e59 Deprecate Velocity support
Issue: SPR-13235
2015-12-17 17:15:57 +01:00
Juergen Hoeller 8ce5e88c66 Require Jackson 2.6+, FreeMarker 2.3.21+, XStream 1.4.5+
Issue: SPR-13062
2015-12-17 17:14:50 +01:00
Juergen Hoeller db05f43a75 Require JsonPath 1.1+
Issue: SPR-13729
2015-12-17 17:13:27 +01:00
Juergen Hoeller 2fd48c92d7 Correct spring-websocket-4.2 versus spring-websocket-4.1 xsd declarations
Issue: SPR-13804
2015-12-17 17:11:44 +01:00
Sam Brannen 93de3553c1 Polish Javadoc in @Cache* annotations 2015-12-17 17:05:33 +01:00
Stephane Nicoll 752d3c715a Initiate structure for 4.3 XSDs 2015-12-17 15:43:23 +01:00
Spring Buildmaster 07022eae1e Next Development Version 2015-12-17 01:12:29 -08:00
2213 changed files with 76683 additions and 31908 deletions
+44
View File
@@ -0,0 +1,44 @@
= Contributor Code of Conduct
As contributors and maintainers of this project, and in the interest of fostering an open
and welcoming community, we pledge to respect all people who contribute through reporting
issues, posting feature requests, updating documentation, submitting pull requests or
patches, and other activities.
We are committed to making participation in this project a harassment-free experience for
everyone, regardless of level of experience, gender, gender identity and expression,
sexual orientation, disability, personal appearance, body size, race, ethnicity, age,
religion, or nationality.
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* Public or private harassment
* Publishing other's private information, such as physical or electronic addresses,
without explicit permission
* Other unethical or unprofessional conduct
Project maintainers have the right and responsibility to remove, edit, or reject comments,
commits, code, wiki edits, issues, and other contributions that are not aligned to this
Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors
that they deem inappropriate, threatening, offensive, or harmful.
By adopting this Code of Conduct, project maintainers commit themselves to fairly and
consistently applying these principles to every aspect of managing this project. Project
maintainers who do not follow or enforce the Code of Conduct may be permanently removed
from the project team.
This Code of Conduct applies both within project spaces and in public spaces when an
individual is representing the project or its community.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by
contacting a project maintainer at spring-code-of-conduct@pivotal.io . All complaints will
be reviewed and investigated and will result in a response that is deemed necessary and
appropriate to the circumstances. Maintainers are obligated to maintain confidentiality
with regard to the reporter of an incident.
This Code of Conduct is adapted from the
http://contributor-covenant.org[Contributor Covenant], version 1.3.0, available at
http://contributor-covenant.org/version/1/3/0/[contributor-covenant.org/version/1/3/0/]
+8 -13
View File
@@ -6,6 +6,10 @@ to expect from the Spring team when evaluating your submission._
_Please refer back to this document as a checklist before issuing any pull
request; this will save time for everyone!_
## Code of Conduct
This project adheres to the Contributor Covenant [code of conduct](CODE_OF_CONDUCT.adoc).
By participating, you are expected to uphold this code. Please report unacceptable behavior to spring-code-of-conduct@pivotal.io.
## Take Your First Steps
### Understand the basics
@@ -29,14 +33,6 @@ do not find something similar, please create a new JIRA issue before submitting
a pull request unless the change is truly trivial -- for example: typo fixes,
removing compiler warnings, etc.
### Discuss non-trivial contribution ideas with committers
If you're considering anything more than correcting a typo or fixing a minor
bug, please discuss it on the [spring-framework-contrib][] mailing list before
submitting a pull request. We're happy to provide guidance, but please spend an
hour or two researching the subject on your own, including searching the mailing
list for prior discussions.
### Sign the Individual Contributor License Agreement (ICLA)
If you have not previously done so, please fill out and submit the
@@ -92,15 +88,14 @@ present in the framework.
1. Preserve existing formatting; i.e. do not reformat code for its own sake
1. Search the codebase using `git grep` and other tools to discover common
naming conventions, etc.
1. Latin-1 (ISO-8859-1) encoding for Java sources; use `native2ascii` to convert
if necessary
1. UTF-8 encoding for Java sources
### Add Apache license header to all new classes
```java
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -128,11 +123,11 @@ modified a file in 2015 whose header still reads:
* Copyright 2002-2011 the original author or authors.
```
Then be sure to update it to 2015 accordingly:
Then be sure to update it to 2016 accordingly:
```java
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
```
### Use @since tags for newly-added public API types and methods
+4
View File
@@ -10,6 +10,10 @@ The framework also serves as the foundation for [Spring Integration][], [Spring
and the rest of the Spring [family of projects][]. Browse the repositories under
the [Spring organization][] on GitHub for a full list.
## Code of Conduct
This project adheres to the Contributor Covenant [code of conduct](CODE_OF_CONDUCT.adoc).
By participating, you are expected to uphold this code. Please report unacceptable behavior to spring-code-of-conduct@pivotal.io.
## Downloading Artifacts
See [downloading Spring artifacts][] for Maven repository information. Unable to
use Maven or other transitive dependency management tools?
+173 -189
View File
@@ -10,6 +10,10 @@ buildscript {
}
}
plugins {
id "org.sonarqube" version "1.1"
}
ext {
linkHomepage = 'https://projects.spring.io/spring-framework'
linkCi = 'https://build.spring.io/browse/SPR'
@@ -27,57 +31,55 @@ configure(allprojects) { project ->
group = "org.springframework"
version = qualifyVersionIfNecessary(version)
ext.aspectjVersion = "1.8.7"
ext.aspectjVersion = "1.8.9"
ext.caffeineVersion = "2.3.5"
ext.eclipselinkVersion = "2.4.2"
ext.ehcacheVersion = "2.10.1"
ext.ehcacheVersion = "2.10.3"
ext.ehcachejcacheVersion = "1.0.1"
ext.ehcache3Version = "3.0.0.m4"
ext.ejbApiVersion = "3.0"
ext.fileuploadVersion = "1.3.1"
ext.ehcache3Version = "3.1.3"
ext.ejbVersion = "3.0"
ext.fileuploadVersion = "1.3.2"
ext.freemarkerVersion = "2.3.23"
ext.groovyVersion = "2.4.5"
ext.gsonVersion = "2.5"
ext.guavaVersion = "19.0"
ext.groovyVersion = "2.4.9"
ext.gsonVersion = "2.8.0"
ext.guavaVersion = "20.0"
ext.hamcrestVersion = "1.3"
ext.hibernate3Version = "3.6.10.Final"
ext.hibernate4Version = "4.3.11.Final"
ext.hibernate5Version = "5.0.5.Final"
ext.hibernate5Version = "5.2.10.Final"
ext.hibval4Version = "4.3.2.Final"
ext.hibval5Version = "5.2.2.Final"
ext.hsqldbVersion = "2.3.3"
ext.htmlunitVersion = "2.19"
ext.httpasyncVersion = "4.1.1"
ext.httpclientVersion = "4.5.1"
ext.jackson2Version = "2.6.4"
ext.jasperreportsVersion = "6.2.0"
ext.javamailVersion = "1.5.4"
ext.jettyVersion = "9.3.6.v20151106"
ext.jodaVersion = "2.9.1"
ext.jrubyVersion = "1.7.23" // JRuby 9000 only supported through JSR-223 (StandardScriptFactory)
ext.jsonassertVersion = "1.2.3"
ext.jsonpathVersion = "2.1.0"
ext.hibval5Version = "5.2.5.Final"
ext.hsqldbVersion = "2.3.4"
ext.httpasyncVersion = "4.1.3"
ext.httpclientVersion = "4.5.3"
ext.jackson2Version = "2.8.7"
ext.jasperreportsVersion = "6.2.1" // our tests fail with JR-internal NPEs against 6.2.2 and higher
ext.javamailVersion = "1.5.6"
ext.jettyVersion = "9.3.14.v20161028" // as of 9.3.15, Jetty has hard Servlet 3.1 requirement
ext.jetty94Version = "9.4.3.v20170317" // for spring-websocket support, optimized for Jetty 9.4
ext.jodaVersion = "2.9.9"
ext.jrubyVersion = "1.7.26" // JRuby 9000 primarily supported through JSR-223 (StandardScriptFactory)
ext.jtaVersion = "1.2"
ext.junitVersion = "4.12"
ext.nettyVersion = "4.0.33.Final"
ext.okhttpVersion = "2.7.0"
ext.openjpaVersion = "2.4.0"
ext.poiVersion = "3.13"
ext.protobufVersion = "2.6.1"
ext.reactorVersion = "2.0.7.RELEASE"
ext.romeVersion = "1.5.1"
ext.seleniumVersion = "2.48.2"
ext.slf4jVersion = "1.7.13"
ext.snakeyamlVersion = "1.16"
ext.snifferVersion = "1.14"
ext.log4jVersion = "1.2.17"
ext.nettyVersion = "4.1.8.Final"
ext.okhttpVersion = "2.7.5"
ext.okhttp3Version = "3.6.0"
ext.openjpaVersion = "2.4.1"
ext.poiVersion = "3.14"
ext.reactorVersion = "2.0.8.RELEASE"
ext.romeVersion = "1.7.1"
ext.slf4jVersion = "1.7.21"
ext.snakeyamlVersion = "1.17"
ext.snifferVersion = "1.15"
ext.testngVersion = "6.9.10"
ext.tiles2Version = "2.2.2"
ext.tiles3Version = "3.0.5"
ext.tomcatVersion = "8.0.30"
ext.tiles3Version = "3.0.7"
ext.tomcatVersion = "8.5.11"
ext.tyrusVersion = "1.3.5" // constrained by WebLogic 12.1.3 support
ext.undertowVersion = "1.3.10.Final"
ext.woodstoxVersion = "5.0.1"
ext.undertowVersion = "1.3.28.Final"
ext.xmlunitVersion = "1.6"
ext.xstreamVersion = "1.4.8"
ext.xstreamVersion = "1.4.9"
ext.gradleScriptDir = "${rootProject.projectDir}/gradle"
@@ -109,11 +111,13 @@ configure(allprojects) { project ->
compileJava {
sourceCompatibility = 1.6
targetCompatibility = 1.6
options.encoding = 'UTF-8'
}
compileTestJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
options.encoding = 'UTF-8'
options.compilerArgs += "-parameters"
}
@@ -130,8 +134,6 @@ configure(allprojects) { project ->
repositories {
maven { url "https://repo.spring.io/libs-release" }
maven { url "https://repo.spring.io/milestone" }
maven { url "https://repo.spring.io/snapshot" } // reactor 2.0.6 snapshot
}
dependencies {
@@ -197,13 +199,13 @@ configure(allprojects) { project ->
"http://portals.apache.org/pluto/portlet-2.0-apidocs/",
"http://tiles.apache.org/tiles-request/apidocs/",
"http://tiles.apache.org/framework/apidocs/",
"http://aopalliance.sourceforge.net/doc/",
"http://www.eclipse.org/aspectj/doc/released/aspectj5rt-api/",
"http://ehcache.org/apidocs/",
"http://quartz-scheduler.org/api/2.2.0/",
"http://fasterxml.github.com/jackson-core/javadoc/2.3.0/",
"http://fasterxml.github.com/jackson-databind/javadoc/2.3.0/",
"http://fasterxml.github.io/jackson-dataformat-xml/javadoc/2.3.0/",
"http://ehcache.org/apidocs/${ehcacheVersion}",
"http://ehcache.org/apidocs/${ehcache3Version}",
"http://quartz-scheduler.org/api/2.2.1/",
"http://fasterxml.github.io/jackson-core/javadoc/2.8/",
"http://fasterxml.github.io/jackson-databind/javadoc/2.8/",
"http://fasterxml.github.io/jackson-dataformat-xml/javadoc/2.8/",
"http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/"
] as String[]
}
@@ -215,13 +217,12 @@ configure(subprojects - project(":spring-build-src")) { subproject ->
configurations {
jacoco
}
dependencies {
jacoco("org.jacoco:org.jacoco.agent:0.7.1.201405082137:runtime")
jacoco("org.jacoco:org.jacoco.agent:0.7.5.201505241946:runtime")
}
gradle.taskGraph.whenReady {taskGraph ->
if (taskGraph.hasTask(':sonarRunner')) {
if (taskGraph.hasTask(':sonarqube')) {
test.jvmArgs "-javaagent:${configurations.jacoco.asPath}=destfile=${buildDir}/jacoco.exec,includes=org.springframework.*"
}
}
@@ -249,16 +250,16 @@ configure(subprojects - project(":spring-build-src")) { subproject ->
options.links(project.ext.javadocLinks)
options.addStringOption('Xdoclint:none', '-quiet')
// suppress warnings due to cross-module @see and @link references;
// note that global 'api' task does display all warnings.
// Suppress warnings due to cross-module @see and @link references.
// Note that global 'api' task does display all warnings.
logging.captureStandardError LogLevel.INFO
logging.captureStandardOutput LogLevel.INFO // suppress "## warnings" message
logging.captureStandardOutput LogLevel.INFO // suppress "## warnings" message
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
// don't include or exclude anything explicitly by default. See SPR-12085.
// Don't include or exclude anything explicitly by default. See SPR-12085.
}
task javadocJar(type: Jar) {
@@ -274,6 +275,7 @@ configure(subprojects - project(":spring-build-src")) { subproject ->
project("spring-build-src") {
description = "Exposes gradle buildSrc for IDE support"
apply plugin: "groovy"
dependencies {
@@ -287,12 +289,12 @@ project("spring-build-src") {
project("spring-core") {
description = "Spring Core"
// As of Spring 4.0.3, spring-core includes asm 5.0 and repackages cglib 3.2, inlining
// both into the spring-core jar. cglib 3.2 itself depends on asm 5.0 and is therefore
// As of Spring 4.0.3, spring-core includes asm 5.x and repackages cglib 3.2, inlining
// both into the spring-core jar. cglib 3.2 itself depends on asm 5.x and is therefore
// further transformed by the JarJar task to depend on org.springframework.asm; this
// avoids including two different copies of asm unnecessarily.
def cglibVersion = "3.2.0"
def objenesisVersion = "2.2"
def cglibVersion = "3.2.5"
def objenesisVersion = "2.5.1"
configurations {
jarjar
@@ -312,9 +314,9 @@ project("spring-core") {
configurations.cglib.each { originalJar ->
zipfileset(src: originalJar)
}
// repackage net.sf.cglib => org.springframework.cglib
// Repackage net.sf.cglib => org.springframework.cglib
rule(pattern: "net.sf.cglib.**", result: "org.springframework.cglib.@1")
// as mentioned above, transform cglib"s internal asm dependencies from
// As mentioned above, transform cglib"s internal asm dependencies from
// org.objectweb.asm => org.springframework.asm. Doing this counts on the
// the fact that Spring and cglib depend on the same version of asm!
rule(pattern: "org.objectweb.asm.**", result: "org.springframework.asm.@1")
@@ -335,7 +337,7 @@ project("spring-core") {
configurations.objenesis.each { originalJar ->
zipfileset(src: originalJar)
}
// repackage org.objenesis => org.springframework.objenesis
// Repackage org.objenesis => org.springframework.objenesis
rule(pattern: "org.objenesis.**", result: "org.springframework.objenesis.@1")
}
}
@@ -352,17 +354,17 @@ project("spring-core") {
compile("commons-logging:commons-logging:1.2")
optional("commons-codec:commons-codec:1.10")
optional("org.aspectj:aspectjweaver:${aspectjVersion}")
optional("net.sf.jopt-simple:jopt-simple:4.9")
optional("log4j:log4j:1.2.17")
optional("net.sf.jopt-simple:jopt-simple:5.0.3")
optional("log4j:log4j:${log4jVersion}")
testCompile("org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}")
testCompile("xmlunit:xmlunit:${xmlunitVersion}")
testCompile("com.fasterxml.woodstox:woodstox-core:${woodstoxVersion}") {
testCompile("com.fasterxml.woodstox:woodstox-core:5.0.3") {
exclude group: "stax", module: "stax-api"
}
}
jar {
// inline repackaged cglib classes directly into the spring-core jar
// Inline repackaged cglib classes directly into spring-core jar
dependsOn cglibRepackJar
from(zipTree(cglibRepackJar.archivePath)) {
include "org/springframework/cglib/**"
@@ -384,13 +386,14 @@ project("spring-beans") {
optional("javax.inject:javax.inject:1")
optional("javax.el:javax.el-api:2.2.5")
optional("org.yaml:snakeyaml:${snakeyamlVersion}")
testCompile("log4j:log4j:1.2.17")
testCompile("log4j:log4j:${log4jVersion}")
testCompile("org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}")
}
}
}
project("spring-beans-groovy") {
description "Groovy Bean Definitions"
merge.into = project(":spring-beans")
apply plugin: "groovy"
@@ -399,8 +402,8 @@ project("spring-beans-groovy") {
optional("org.codehaus.groovy:groovy-all:${groovyVersion}")
}
// this module's Java and Groovy sources need to be compiled together
compileJava.enabled=false
// This module's Java and Groovy sources need to be compiled together.
compileJava.enabled = false
sourceSets {
main {
groovy {
@@ -423,7 +426,6 @@ project("spring-aop") {
compile(project(":spring-core"))
compile(files(project(":spring-core").cglibRepackJar))
compile(files(project(":spring-core").objenesisRepackJar))
compile("aopalliance:aopalliance:1.0")
optional("org.aspectj:aspectjweaver:${aspectjVersion}")
optional("commons-pool:commons-pool:1.6")
optional("org.apache.commons:commons-pool2:2.4.2")
@@ -467,6 +469,7 @@ project("spring-instrument-tomcat") {
project("spring-context") {
description = "Spring Context"
apply plugin: "groovy"
dependencies {
@@ -477,19 +480,19 @@ project("spring-context") {
compile(files(project(":spring-core").cglibRepackJar))
optional(project(":spring-instrument"))
optional("javax.inject:javax.inject:1")
optional("javax.ejb:ejb-api:${ejbApiVersion}")
optional("javax.ejb:ejb-api:${ejbVersion}")
optional("javax.enterprise.concurrent:javax.enterprise.concurrent-api:1.0")
optional("javax.money:money-api:1.0")
optional("javax.money:money-api:1.0.1")
optional("org.eclipse.persistence:javax.persistence:2.0.0")
optional("javax.validation:validation-api:1.0.0.GA")
optional("org.hibernate:hibernate-validator:${hibval4Version}")
optional("joda-time:joda-time:${jodaVersion}")
optional("org.aspectj:aspectjweaver:${aspectjVersion}")
optional("org.codehaus.groovy:groovy-all:${groovyVersion}")
optional("org.beanshell:bsh:2.0b4")
optional("org.beanshell:bsh:2.0b5")
optional("org.jruby:jruby:${jrubyVersion}")
testCompile("javax.inject:javax.inject-tck:1")
testCompile("org.javamoney:moneta:1.0")
testCompile("org.javamoney:moneta:1.1")
testCompile("commons-dbcp:commons-dbcp:1.4")
testCompile("org.apache.commons:commons-pool2:2.4.2")
testCompile("org.slf4j:slf4j-api:${slf4jVersion}")
@@ -528,10 +531,9 @@ project("spring-messaging") {
}
testCompile("org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}")
testCompile("org.apache.tomcat.embed:tomcat-embed-websocket:${tomcatVersion}")
testCompile("org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}")
testCompile("io.netty:netty-all:${nettyVersion}")
testCompile("commons-dbcp:commons-dbcp:1.4")
testCompile("log4j:log4j:1.2.17")
testCompile("log4j:log4j:${log4jVersion}")
testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}")
testCompile("xmlunit:xmlunit:${xmlunitVersion}")
}
@@ -545,13 +547,13 @@ project("spring-tx") {
compile(project(":spring-core"))
optional(project(":spring-aop"))
optional(project(":spring-context")) // for JCA, @EnableTransactionManagement
optional("aopalliance:aopalliance:1.0")
optional("javax.transaction:javax.transaction-api:${jtaVersion}")
optional("javax.resource:connector-api:1.5")
optional("javax.ejb:ejb-api:${ejbApiVersion}")
optional("javax.ejb:ejb-api:${ejbVersion}")
optional("com.ibm.websphere:uow:6.0.2.17")
testCompile("org.aspectj:aspectjweaver:${aspectjVersion}")
testCompile("org.eclipse.persistence:javax.persistence:2.0.0")
testCompile("org.codehaus.groovy:groovy-all:${groovyVersion}")
}
}
@@ -559,22 +561,10 @@ project("spring-oxm") {
description = "Spring Object/XML Marshalling"
apply from: "oxm.gradle"
compileTestJava {
// necessary to avoid java.lang.VerifyError on jibx compilation
// see http://jira.codehaus.org/browse/JIBX-465
sourceCompatibility = 1.6
targetCompatibility = 1.6
}
if (!System.getProperty("java.version").contains("1.8.")) {
// necessary because castor and xjc tasks cannot find the JDK's compiler on JDK 9
compileTestJava.enabled = false
}
dependencies {
compile(project(":spring-beans"))
compile(project(":spring-core"))
optional("org.codehaus.castor:castor-xml:1.4.0") {
optional("org.codehaus.castor:castor-xml:1.4.1") {
exclude group: 'stax', module: 'stax-api'
exclude group: "org.springframework", module: "spring-context"
}
@@ -589,14 +579,12 @@ project("spring-oxm") {
testCompile(project(":spring-context"))
testCompile("xmlunit:xmlunit:${xmlunitVersion}")
testCompile("xpp3:xpp3:1.1.4c")
testCompile("org.codehaus.jettison:jettison:1.3.7") {
testCompile("org.codehaus.jettison:jettison:1.3.8") {
exclude group: 'stax', module: 'stax-api'
}
if (compileTestJava.enabled) {
testCompile(files(genCastor.classesDir).builtBy(genCastor))
testCompile(files(genJaxb.classesDir).builtBy(genJaxb))
testCompile(files(genXmlbeans.classesDir).builtBy(genXmlbeans))
}
testCompile(files(genCastor.classesDir).builtBy(genCastor))
testCompile(files(genJaxb.classesDir).builtBy(genJaxb))
testCompile(files(genXmlbeans.classesDir).builtBy(genXmlbeans))
}
}
@@ -612,7 +600,6 @@ project("spring-jms") {
compile(project(":spring-tx"))
provided("javax.jms:jms-api:1.1-rev-1")
optional(project(":spring-oxm"))
optional("aopalliance:aopalliance:1.0")
optional("javax.transaction:javax.transaction-api:${jtaVersion}")
optional("javax.resource:connector-api:1.5")
optional("com.fasterxml.jackson.core:jackson-databind:${jackson2Version}")
@@ -630,9 +617,9 @@ project("spring-jdbc") {
optional("javax.transaction:javax.transaction-api:${jtaVersion}")
optional("com.mchange:c3p0:0.9.5.2")
optional("org.hsqldb:hsqldb:${hsqldbVersion}")
optional("com.h2database:h2:1.4.190")
optional("org.apache.derby:derby:10.12.1.1")
optional("org.apache.derby:derbyclient:10.12.1.1")
optional("com.h2database:h2:1.4.193")
optional("org.apache.derby:derby:10.13.1.1")
optional("org.apache.derby:derbyclient:10.13.1.1")
}
}
@@ -648,8 +635,9 @@ project("spring-context-support") {
optional("javax.mail:javax.mail-api:${javamailVersion}")
optional("javax.cache:cache-api:1.0.0")
optional("com.google.guava:guava:${guavaVersion}")
optional("com.github.ben-manes.caffeine:caffeine:${caffeineVersion}")
optional("net.sf.ehcache:ehcache:${ehcacheVersion}")
optional("org.quartz-scheduler:quartz:2.2.2")
optional("org.quartz-scheduler:quartz:2.2.3")
optional("org.codehaus.fabric3.api:commonj:1.1.0")
optional("org.apache.velocity:velocity:1.7")
optional("org.freemarker:freemarker:${freemarkerVersion}")
@@ -675,6 +663,7 @@ project("spring-context-support") {
project("spring-web") {
description = "Spring Web"
apply plugin: "groovy"
// Re-generate Protobuf classes from *.proto files and move them in test sources
@@ -704,7 +693,6 @@ project("spring-web") {
optional("javax.el:javax.el-api:2.2.5")
optional("javax.faces:javax.faces-api:2.2")
optional("javax.validation:validation-api:1.0.0.GA")
optional("aopalliance:aopalliance:1.0")
optional("org.codehaus.groovy:groovy-all:${groovyVersion}")
optional("com.caucho:hessian:4.0.38")
optional("commons-fileupload:commons-fileupload:${fileuploadVersion}")
@@ -712,6 +700,7 @@ project("spring-web") {
optional("org.apache.httpcomponents:httpasyncclient:${httpasyncVersion}")
optional("io.netty:netty-all:${nettyVersion}")
optional("com.squareup.okhttp:okhttp:${okhttpVersion}")
optional("com.squareup.okhttp3:okhttp:${okhttp3Version}")
optional("com.fasterxml.jackson.core:jackson-databind:${jackson2Version}")
optional("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${jackson2Version}")
optional("com.google.code.gson:gson:${gsonVersion}")
@@ -722,9 +711,9 @@ project("spring-web") {
optional("org.eclipse.jetty:jetty-server:${jettyVersion}") {
exclude group: "javax.servlet", module: "javax.servlet-api"
}
optional("log4j:log4j:1.2.17")
optional("com.googlecode.protobuf-java-format:protobuf-java-format:1.2")
optional("com.google.protobuf:protobuf-java:${protobufVersion}")
optional("log4j:log4j:${log4jVersion}")
optional("com.google.protobuf:protobuf-java:2.6.1")
optional("com.googlecode.protobuf-java-format:protobuf-java-format:1.4")
optional("javax.mail:javax.mail-api:${javamailVersion}")
testCompile(project(":spring-context-support")) // for JafMediaTypeFactory
testCompile("xmlunit:xmlunit:${xmlunitVersion}")
@@ -733,58 +722,13 @@ project("spring-web") {
exclude group: "org.apache.taglibs", module: "taglibs-standard-spec"
}
testCompile("com.fasterxml.jackson.datatype:jackson-datatype-joda:${jackson2Version}")
testCompile("com.fasterxml.jackson.datatype:jackson-datatype-jdk7:${jackson2Version}")
testCompile("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${jackson2Version}")
testCompile("com.fasterxml.jackson.module:jackson-module-kotlin:${jackson2Version}")
testCompile("com.squareup.okhttp3:mockwebserver:${okhttp3Version}")
testRuntime("com.sun.mail:javax.mail:${javamailVersion}")
}
}
project("spring-websocket") {
description = "Spring WebSocket"
dependencies {
compile(project(":spring-core"))
compile(project(":spring-context"))
compile(project(":spring-web"))
optional(project(":spring-messaging"))
optional(project(":spring-webmvc"))
optional("javax.servlet:javax.servlet-api:3.1.0")
optional("javax.websocket:javax.websocket-api:1.0")
optional("org.apache.tomcat:tomcat-websocket:${tomcatVersion}") {
exclude group: "org.apache.tomcat", module: "tomcat-websocket-api"
exclude group: "org.apache.tomcat", module: "tomcat-servlet-api"
}
optional("org.glassfish.tyrus:tyrus-spi:${tyrusVersion}")
optional("org.glassfish.tyrus:tyrus-core:${tyrusVersion}")
optional("org.glassfish.tyrus:tyrus-server:${tyrusVersion}")
optional("org.glassfish.tyrus:tyrus-container-servlet:${tyrusVersion}")
optional("org.eclipse.jetty:jetty-webapp:${jettyVersion}") {
exclude group: "javax.servlet", module: "javax.servlet"
}
optional("org.eclipse.jetty.websocket:websocket-server:${jettyVersion}") {
exclude group: "javax.servlet", module: "javax.servlet"
}
optional("org.eclipse.jetty.websocket:websocket-client:${jettyVersion}")
optional("org.eclipse.jetty:jetty-client:${jettyVersion}")
optional("io.undertow:undertow-core:${undertowVersion}")
optional("io.undertow:undertow-servlet:${undertowVersion}") {
exclude group: "org.jboss.spec.javax.servlet", module: "jboss-servlet-api_3.1_spec"
exclude group: "org.jboss.spec.javax.annotation", module: "jboss-annotations-api_1.2_spec"
}
optional("io.undertow:undertow-websockets-jsr:${undertowVersion}") {
exclude group: "org.jboss.spec.javax.websocket", module: "jboss-websocket-api_1.1_spec"
}
optional("com.fasterxml.jackson.core:jackson-databind:${jackson2Version}")
testCompile("org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}")
testCompile("org.apache.tomcat.embed:tomcat-embed-websocket:${tomcatVersion}")
testCompile("org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}")
testCompile("io.projectreactor:reactor-net:${reactorVersion}")
testCompile("io.netty:netty-all:${nettyVersion}")
testCompile("log4j:log4j:1.2.17")
testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}")
}
}
project("spring-orm") {
description = "Spring Object/Relational Mapping"
@@ -796,7 +740,6 @@ project("spring-orm") {
optional(project(":spring-aop"))
optional(project(":spring-context"))
optional(project(":spring-web"))
optional("aopalliance:aopalliance:1.0")
optional("org.eclipse.persistence:javax.persistence:2.0.5")
optional("org.eclipse.persistence:org.eclipse.persistence.core:${eclipselinkVersion}")
optional("org.eclipse.persistence:org.eclipse.persistence.jpa:${eclipselinkVersion}") {
@@ -837,7 +780,6 @@ project("spring-orm-hibernate4") {
optional("org.hibernate:hibernate-core:${hibernate4Version}")
optional("org.hibernate:hibernate-entitymanager:${hibernate4Version}")
optional("javax.servlet:javax.servlet-api:3.0.1")
optional("aopalliance:aopalliance:1.0")
testCompile("javax.validation:validation-api:1.1.0.GA")
testCompile("org.hibernate:hibernate-validator:${hibval5Version}")
testCompile("javax.el:javax.el-api:2.2.5")
@@ -854,10 +796,8 @@ project("spring-orm-hibernate5") {
provided(project(":spring-tx"))
optional(project(":spring-web"))
optional("org.hibernate:hibernate-core:${hibernate5Version}")
optional("org.hibernate:hibernate-entitymanager:${hibernate5Version}")
optional("javax.servlet:javax.servlet-api:3.0.1")
optional("javax.transaction:javax.transaction-api:${jtaVersion}")
optional("aopalliance:aopalliance:1.0")
}
}
@@ -865,13 +805,14 @@ project("spring-webmvc") {
description = "Spring Web MVC"
dependencies {
compile(project(":spring-aop"))
compile(project(":spring-beans"))
compile(project(":spring-context"))
compile(project(":spring-core"))
compile(files(project(":spring-core").objenesisRepackJar))
compile(project(":spring-expression"))
compile(project(":spring-web"))
provided("javax.servlet:javax.servlet-api:3.0.1")
provided("javax.servlet:javax.servlet-api:3.1.0")
optional(project(":spring-context-support")) // for Velocity support
optional(project(":spring-oxm")) // for MarshallingView
optional("javax.servlet.jsp:javax.servlet.jsp-api:2.2.1")
@@ -913,9 +854,7 @@ project("spring-webmvc") {
exclude group: "org.slf4j", module: "jcl-over-slf4j"
exclude group: "org.springframework", module: "spring-web"
}
optional('org.webjars:webjars-locator:0.28')
testCompile(project(":spring-aop"))
testCompile("rhino:js:1.7R1")
optional('org.webjars:webjars-locator:0.32')
testCompile("xmlunit:xmlunit:${xmlunitVersion}")
testCompile("dom4j:dom4j:1.6.1") {
exclude group: "xml-apis", module: "xml-apis"
@@ -935,12 +874,13 @@ project("spring-webmvc") {
testCompile("org.hibernate:hibernate-validator:${hibval4Version}")
testCompile("org.apache.httpcomponents:httpclient:${httpclientVersion}")
testCompile("commons-fileupload:commons-fileupload:${fileuploadVersion}")
testCompile("commons-io:commons-io:1.3")
testCompile("commons-io:commons-io:1.4")
testCompile("joda-time:joda-time:${jodaVersion}")
testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}")
testCompile("org.jruby:jruby:${jrubyVersion}")
testCompile("org.python:jython-standalone:2.5.3")
testCompile("org.webjars:underscorejs:1.8.3")
testCompile("org.mozilla:rhino:1.7.7.1")
testRuntime("org.jruby:jruby:${jrubyVersion}")
testRuntime("org.python:jython-standalone:2.5.3")
testRuntime("org.webjars:underscorejs:1.8.3")
}
}
@@ -991,6 +931,51 @@ project("spring-webmvc-portlet") {
}
}
project("spring-websocket") {
description = "Spring WebSocket"
dependencies {
compile(project(":spring-core"))
compile(project(":spring-context"))
compile(project(":spring-web"))
optional(project(":spring-messaging"))
optional(project(":spring-webmvc"))
optional("javax.servlet:javax.servlet-api:3.1.0")
optional("javax.websocket:javax.websocket-api:1.0")
optional("org.apache.tomcat:tomcat-websocket:${tomcatVersion}") {
exclude group: "org.apache.tomcat", module: "tomcat-websocket-api"
exclude group: "org.apache.tomcat", module: "tomcat-servlet-api"
}
optional("org.glassfish.tyrus:tyrus-spi:${tyrusVersion}")
optional("org.glassfish.tyrus:tyrus-core:${tyrusVersion}")
optional("org.glassfish.tyrus:tyrus-server:${tyrusVersion}")
optional("org.glassfish.tyrus:tyrus-container-servlet:${tyrusVersion}")
optional("org.eclipse.jetty:jetty-webapp:${jettyVersion}") {
exclude group: "javax.servlet", module: "javax.servlet"
}
optional("org.eclipse.jetty.websocket:websocket-server:${jetty94Version}") {
exclude group: "javax.servlet", module: "javax.servlet"
}
optional("org.eclipse.jetty.websocket:websocket-client:${jetty94Version}")
optional("org.eclipse.jetty:jetty-client:${jetty94Version}")
optional("io.undertow:undertow-core:${undertowVersion}")
optional("io.undertow:undertow-servlet:${undertowVersion}") {
exclude group: "org.jboss.spec.javax.servlet", module: "jboss-servlet-api_3.1_spec"
exclude group: "org.jboss.spec.javax.annotation", module: "jboss-annotations-api_1.2_spec"
}
optional("io.undertow:undertow-websockets-jsr:${undertowVersion}") {
exclude group: "org.jboss.spec.javax.websocket", module: "jboss-websocket-api_1.1_spec"
}
optional("com.fasterxml.jackson.core:jackson-databind:${jackson2Version}")
testCompile("org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}")
testCompile("org.apache.tomcat.embed:tomcat-embed-websocket:${tomcatVersion}")
testCompile("io.projectreactor:reactor-net:${reactorVersion}")
testCompile("io.netty:netty-all:${nettyVersion}")
testCompile("log4j:log4j:${log4jVersion}")
testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}")
}
}
project("spring-test") {
description = "Spring TestContext Framework"
@@ -1004,6 +989,7 @@ project("spring-test") {
optional(project(":spring-web"))
optional(project(":spring-webmvc"))
optional(project(":spring-webmvc-portlet"))
optional(project(":spring-websocket"))
optional("junit:junit:${junitVersion}")
optional("org.testng:testng:${testngVersion}")
optional("javax.inject:javax.inject:1")
@@ -1015,18 +1001,20 @@ project("spring-test") {
}
optional("javax.portlet:portlet-api:2.0")
optional("javax.el:javax.el-api:2.2.5")
optional("javax.websocket:javax.websocket-api:1.0")
optional("org.aspectj:aspectjweaver:${aspectjVersion}")
optional("org.codehaus.groovy:groovy-all:${groovyVersion}")
optional("org.hamcrest:hamcrest-core:${hamcrestVersion}")
optional("com.jayway.jsonpath:json-path:${jsonpathVersion}")
optional("org.skyscreamer:jsonassert:${jsonassertVersion}")
optional("xmlunit:xmlunit:${xmlunitVersion}")
optional("net.sourceforge.htmlunit:htmlunit:${htmlunitVersion}")
optional("org.seleniumhq.selenium:selenium-htmlunit-driver:${seleniumVersion}")
optional("net.sourceforge.htmlunit:htmlunit:2.23")
optional("org.seleniumhq.selenium:htmlunit-driver:2.23.2")
optional("org.seleniumhq.selenium:selenium-java:2.53.1")
optional("org.skyscreamer:jsonassert:1.4.0")
optional("com.jayway.jsonpath:json-path:2.2.0")
testCompile(project(":spring-context-support"))
testCompile(project(":spring-oxm"))
testCompile("javax.mail:javax.mail-api:${javamailVersion}")
testCompile("javax.ejb:ejb-api:${ejbApiVersion}")
testCompile("javax.ejb:ejb-api:${ejbVersion}")
testCompile("org.hibernate:hibernate-core:${hibernate4Version}")
testCompile("org.hibernate:hibernate-entitymanager:${hibernate4Version}")
testCompile("org.hibernate:hibernate-validator:${hibval5Version}")
@@ -1044,8 +1032,9 @@ project("spring-test") {
testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}")
testCompile("org.apache.httpcomponents:httpclient:${httpclientVersion}")
testCompile("javax.cache:cache-api:1.0.0")
testRuntime("log4j:log4j:${log4jVersion}")
testRuntime("org.ehcache:ehcache:${ehcache3Version}")
testRuntime("org.terracotta:management-model:2.0.0")
testRuntime("org.terracotta:management-model:2.3.0")
}
task testNG(type: Test) {
@@ -1080,8 +1069,8 @@ project("spring-aspects") {
dependencies {
aspects(project(":spring-orm"))
ajc("org.aspectj:aspectjtools:1.9.0.BETA-2") // for the ability to build on JDK 9, not exposed in the POMs yet
rt("org.aspectj:aspectjrt:${aspectjVersion}") // regular AspectJ version here, to be exposed in the POMs
ajc("org.aspectj:aspectjtools:${aspectjVersion}")
rt("org.aspectj:aspectjrt:${aspectjVersion}")
compile("org.aspectj:aspectjweaver:${aspectjVersion}")
provided("org.eclipse.persistence:javax.persistence:2.0.0")
optional(project(":spring-aop")) // for @Async support
@@ -1099,8 +1088,7 @@ project("spring-aspects") {
eclipse.project {
natures += "org.eclipse.ajdt.ui.ajnature"
buildCommands = [new org.gradle.plugins.ide.eclipse.model.
BuildCommand("org.eclipse.ajdt.core.ajbuilder")]
buildCommands = [new org.gradle.plugins.ide.eclipse.model.BuildCommand("org.eclipse.ajdt.core.ajbuilder")]
}
}
@@ -1139,10 +1127,8 @@ project("spring-framework-bom") {
}
}
apply plugin: 'sonar-runner'
sonarRunner {
sonarProperties {
sonarqube {
properties {
property "sonar.projectName", "Spring Framework"
property "sonar.profile", "Spring Framework"
property "sonar.jacoco.reportPath", "${buildDir.name}/jacoco.exec"
@@ -1170,9 +1156,7 @@ configure(rootProject) {
separateOutputDirs = false
backends = ['docbook']
options doctype: 'book', eruby: 'erubis'
attributes 'spring-version': project.version,
'revnumber' : project.version,
'docinfo' : ""
attributes 'spring-version': project.version, 'revnumber': project.version, 'docinfo': ""
}
reference {
@@ -1195,7 +1179,7 @@ configure(rootProject) {
// don't publish the default jar for the root project
configurations.archives.artifacts.clear()
dependencies { // for integration tests
dependencies { // for integration tests
testCompile(project(":spring-aop"))
testCompile(project(":spring-beans"))
testCompile(project(":spring-context"))
@@ -1244,11 +1228,11 @@ configure(rootProject) {
doFirst {
classpath = files(
// ensure Servlet 3.x and Hibernate 4.x have precedence on the javadoc
// Ensure Servlet 3.x and Hibernate 4.x have precedence on the javadoc
// classpath over their respective 2.5 and 3.x variants
project(":spring-webmvc").sourceSets.main.compileClasspath.files.find { it =~ "servlet-api" },
rootProject.sourceSets.test.compileClasspath.files.find { it =~ "hibernate-core" },
// ensure the javadoc process can resolve types compiled from .aj sources
// Ensure the javadoc process can resolve types compiled from .aj sources
project(":spring-aspects").sourceSets.main.output
)
classpath += files(subprojects.collect { it.sourceSets.main.compileClasspath })
@@ -1308,7 +1292,7 @@ configure(rootProject) {
baseName = "spring-framework"
classifier = "dist"
description = "Builds -${classifier} archive, containing all jars and docs, " +
"suitable for community download page."
"suitable for community download page."
ext.baseDir = "${baseName}-${project.version}";
@@ -1381,7 +1365,7 @@ configure(rootProject) {
task wrapper(type: Wrapper) {
description = "Generates gradlew[.bat] scripts"
gradleVersion = "2.5"
gradleVersion = "2.14.1"
doLast() {
def gradleOpts = "-XX:MaxMetaspaceSize=1024m -Xmx1024m"
@@ -1398,14 +1382,14 @@ configure(rootProject) {
}
configure([project(':spring-build-src'), project(':spring-framework-bom')]) {
sonarRunner {
sonarqube {
skipProject = true
}
}
configure(project(':spring-core')) {
sonarRunner {
sonarProperties {
sonarqube {
properties {
property "sonar.exclusions",
"src/main/java/org/springframework/cglib/**/*,src/main/java/org/springframework/asm/**/*"
}
+1 -1
View File
@@ -1 +1 @@
version=4.2.4.BUILD-SNAPSHOT
version=4.3.8.RELEASE
+2 -2
View File
@@ -29,8 +29,8 @@ def customizePom(pom, gradleProject) {
}
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
name "Apache License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0"
distribution "repo"
}
}
Binary file not shown.
+2 -2
View File
@@ -1,6 +1,6 @@
#Thu Jul 09 16:54:55 EEST 2015
#Wed Aug 17 21:21:18 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip
Vendored
+27 -27
View File
@@ -6,13 +6,31 @@
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
GRADLE_OPTS="-XX:MaxMetaspaceSize=1024m -Xmx1024m $GRADLE_OPTS"
DEFAULT_JVM_OPTS=""
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
GRADLE_OPTS="-XX:MaxMetaspaceSize=1024m -Xmx1024m $GRADLE_OPTS"
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
@@ -31,6 +49,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
@@ -41,31 +60,11 @@ case "`uname`" in
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -91,7 +90,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -115,6 +114,7 @@ fi
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
Vendored
+5 -5
View File
@@ -8,15 +8,15 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set GRADLE_OPTS=-XX:MaxMetaspaceSize=1024m -Xmx1024m -XX:MaxHeapSize=256m %GRADLE_OPTS%
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set GRADLE_OPTS=-XX:MaxMetaspaceSize=1024m -Xmx1024m -XX:MaxHeapSize=256m %GRADLE_OPTS%
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@@ -47,7 +47,7 @@ echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
+3 -3
View File
@@ -29,8 +29,8 @@ REM - generates OXM test classes to avoid errors on import into Eclipse
REM - generates metadata for all subprojects
REM - skips metadata gen for the root project (-x :eclipse) to work
REM around Eclipse's inability to import hierarchical project structures
REM SET COMMAND="./gradlew cleanEclipse :spring-oxm:compileTestJava eclipse -x :eclipse"
SET COMMAND=gradlew cleanEclipse :spring-oxm:compileTestJava eclipse -x :eclipse
REM SET COMMAND="./gradlew --no-daemon cleanEclipse :spring-oxm:compileTestJava eclipse -x :eclipse"
SET COMMAND=gradlew --no-daemon cleanEclipse :spring-oxm:compileTestJava eclipse -x :eclipse
echo.
echo -----------------------------------------------------------------------
@@ -69,7 +69,7 @@ echo When the above is complete, return here and press the enter key.
pause
set COMMAND=gradlew :eclipse
set COMMAND=gradlew --no-daemon :eclipse
echo.
echo -----------------------------------------------------------------------
+2 -2
View File
@@ -42,7 +42,7 @@ read
# - generates metadata for all subprojects
# - skips metadata gen for the root project (-x :eclipse) to work
# around Eclipse's inability to import hierarchical project structures
COMMAND="./gradlew cleanEclipse :spring-oxm:compileTestJava eclipse -x :eclipse"
COMMAND="./gradlew --no-daemon cleanEclipse :spring-oxm:compileTestJava eclipse -x :eclipse"
cat <<EOM
@@ -84,7 +84,7 @@ EOM
read
COMMAND="./gradlew :eclipse"
COMMAND="./gradlew --no-daemon :eclipse"
cat <<EOM
@@ -0,0 +1,28 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.aopalliance.aop;
/**
* Tag interface for Advice. Implementations can be any type
* of advice, such as Interceptors.
*
* @author Rod Johnson
* @version $Id: Advice.java,v 1.1 2004/03/19 17:02:16 johnsonr Exp $
*/
public interface Advice {
}
@@ -0,0 +1,48 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.aopalliance.aop;
/**
* Superclass for all AOP infrastructure exceptions.
* Unchecked, as such exceptions are fatal and end user
* code shouldn't be forced to catch them.
*
* @author Rod Johnson
* @author Bob Lee
* @author Juergen Hoeller
*/
@SuppressWarnings("serial")
public class AspectException extends RuntimeException {
/**
* Constructor for AspectException.
* @param message the exception message
*/
public AspectException(String message) {
super(message);
}
/**
* Constructor for AspectException.
* @param message the exception message
* @param cause the root cause, if any
*/
public AspectException(String message, Throwable cause) {
super(message, cause);
}
}
@@ -0,0 +1,59 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.aopalliance.intercept;
/**
* Intercepts the construction of a new object.
*
* <p>The user should implement the {@link
* #construct(ConstructorInvocation)} method to modify the original
* behavior. E.g. the following class implements a singleton
* interceptor (allows only one unique instance for the intercepted
* class):
*
* <pre class=code>
* class DebuggingInterceptor implements ConstructorInterceptor {
* Object instance=null;
*
* Object construct(ConstructorInvocation i) throws Throwable {
* if(instance==null) {
* return instance=i.proceed();
* } else {
* throw new Exception("singleton does not allow multiple instance");
* }
* }
* }
* </pre>
*
* @author Rod Johnson
*/
public interface ConstructorInterceptor extends Interceptor {
/**
* Implement this method to perform extra treatments before and
* after the construction of a new object. Polite implementations
* would certainly like to invoke {@link Joinpoint#proceed()}.
* @param invocation the construction joinpoint
* @return the newly created object, which is also the result of
* the call to {@link Joinpoint#proceed()}; might be replaced by
* the interceptor
* @throws Throwable if the interceptors or the target object
* throws an exception
*/
Object construct(ConstructorInvocation invocation) throws Throwable;
}
@@ -0,0 +1,41 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.aopalliance.intercept;
import java.lang.reflect.Constructor;
/**
* Description of an invocation to a constuctor, given to an
* interceptor upon constructor-call.
*
* <p>A constructor invocation is a joinpoint and can be intercepted
* by a constructor interceptor.
*
* @author Rod Johnson
* @see ConstructorInterceptor
*/
public interface ConstructorInvocation extends Invocation {
/**
* Get the constructor being called.
* <p>This method is a friendly implementation of the
* {@link Joinpoint#getStaticPart()} method (same result).
* @return the constructor being called
*/
Constructor<?> getConstructor();
}
@@ -0,0 +1,69 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.aopalliance.intercept;
import org.aopalliance.aop.Advice;
/**
* This interface represents a generic interceptor.
*
* <p>A generic interceptor can intercept runtime events that occur
* within a base program. Those events are materialized by (reified
* in) joinpoints. Runtime joinpoints can be invocations, field
* access, exceptions...
*
* <p>This interface is not used directly. Use the sub-interfaces
* to intercept specific events. For instance, the following class
* implements some specific interceptors in order to implement a
* debugger:
*
* <pre class=code>
* class DebuggingInterceptor implements MethodInterceptor,
* ConstructorInterceptor, FieldInterceptor {
*
* Object invoke(MethodInvocation i) throws Throwable {
* debug(i.getMethod(), i.getThis(), i.getArgs());
* return i.proceed();
* }
*
* Object construct(ConstructorInvocation i) throws Throwable {
* debug(i.getConstructor(), i.getThis(), i.getArgs());
* return i.proceed();
* }
*
* Object get(FieldAccess fa) throws Throwable {
* debug(fa.getField(), fa.getThis(), null);
* return fa.proceed();
* }
*
* Object set(FieldAccess fa) throws Throwable {
* debug(fa.getField(), fa.getThis(), fa.getValueToSet());
* return fa.proceed();
* }
*
* void debug(AccessibleObject ao, Object this, Object value) {
* ...
* }
* }
* </pre>
*
* @author Rod Johnson
* @see Joinpoint
*/
public interface Interceptor extends Advice {
}
@@ -0,0 +1,37 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.aopalliance.intercept;
/**
* This interface represents an invocation in the program.
*
* <p>An invocation is a joinpoint and can be intercepted by an
* interceptor.
*
* @author Rod Johnson
*/
public interface Invocation extends Joinpoint {
/**
* Get the arguments as an array object.
* It is possible to change element values within this
* array to change the arguments.
* @return the argument of the invocation
*/
Object[] getArguments();
}
@@ -0,0 +1,65 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.aopalliance.intercept;
import java.lang.reflect.AccessibleObject;
/**
* This interface represents a generic runtime joinpoint (in the AOP
* terminology).
*
* <p>A runtime joinpoint is an <i>event</i> that occurs on a static
* joinpoint (i.e. a location in a the program). For instance, an
* invocation is the runtime joinpoint on a method (static joinpoint).
* The static part of a given joinpoint can be generically retrieved
* using the {@link #getStaticPart()} method.
*
* <p>In the context of an interception framework, a runtime joinpoint
* is then the reification of an access to an accessible object (a
* method, a constructor, a field), i.e. the static part of the
* joinpoint. It is passed to the interceptors that are installed on
* the static joinpoint.
*
* @author Rod Johnson
* @see Interceptor
*/
public interface Joinpoint {
/**
* Proceed to the next interceptor in the chain.
* <p>The implementation and the semantics of this method depends
* on the actual joinpoint type (see the children interfaces).
* @return see the children interfaces' proceed definition
* @throws Throwable if the joinpoint throws an exception
*/
Object proceed() throws Throwable;
/**
* Return the object that holds the current joinpoint's static part.
* <p>For instance, the target object for an invocation.
* @return the object (can be null if the accessible object is static)
*/
Object getThis();
/**
* Return the static part of this joinpoint.
* <p>The static part is an accessible object on which a chain of
* interceptors are installed.
*/
AccessibleObject getStaticPart();
}
@@ -0,0 +1,56 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.aopalliance.intercept;
/**
* Intercepts calls on an interface on its way to the target. These
* are nested "on top" of the target.
*
* <p>The user should implement the {@link #invoke(MethodInvocation)}
* method to modify the original behavior. E.g. the following class
* implements a tracing interceptor (traces all the calls on the
* intercepted method(s)):
*
* <pre class=code>
* class TracingInterceptor implements MethodInterceptor {
* Object invoke(MethodInvocation i) throws Throwable {
* System.out.println("method "+i.getMethod()+" is called on "+
* i.getThis()+" with args "+i.getArguments());
* Object ret=i.proceed();
* System.out.println("method "+i.getMethod()+" returns "+ret);
* return ret;
* }
* }
* </pre>
*
* @author Rod Johnson
*/
public interface MethodInterceptor extends Interceptor {
/**
* Implement this method to perform extra treatments before and
* after the invocation. Polite implementations would certainly
* like to invoke {@link Joinpoint#proceed()}.
* @param invocation the method invocation joinpoint
* @return the result of the call to {@link Joinpoint#proceed()};
* might be intercepted by the interceptor
* @throws Throwable if the interceptors or the target object
* throws an exception
*/
Object invoke(MethodInvocation invocation) throws Throwable;
}
@@ -0,0 +1,41 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.aopalliance.intercept;
import java.lang.reflect.Method;
/**
* Description of an invocation to a method, given to an interceptor
* upon method-call.
*
* <p>A method invocation is a joinpoint and can be intercepted by a
* method interceptor.
*
* @author Rod Johnson
* @see MethodInterceptor
*/
public interface MethodInvocation extends Invocation {
/**
* Get the method being called.
* <p>This method is a frienly implementation of the
* {@link Joinpoint#getStaticPart()} method (same result).
* @return the method being called
*/
Method getMethod();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -86,7 +86,7 @@ public interface MethodMatcher {
* @return whether there's a runtime match
* @see MethodMatcher#matches(Method, Class)
*/
boolean matches(Method method, Class<?> targetClass, Object[] args);
boolean matches(Method method, Class<?> targetClass, Object... args);
/**
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,12 +29,14 @@ class TrueMethodMatcher implements MethodMatcher, Serializable {
public static final TrueMethodMatcher INSTANCE = new TrueMethodMatcher();
/**
* Enforce Singleton pattern.
*/
private TrueMethodMatcher() {
}
@Override
public boolean isRuntime() {
return false;
@@ -46,11 +48,17 @@ class TrueMethodMatcher implements MethodMatcher, Serializable {
}
@Override
public boolean matches(Method method, Class<?> targetClass, Object[] args) {
public boolean matches(Method method, Class<?> targetClass, Object... args) {
// Should never be invoked as isRuntime returns false.
throw new UnsupportedOperationException();
}
@Override
public String toString() {
return "MethodMatcher.TRUE";
}
/**
* Required to support serialization. Replaces with canonical
* instance on deserialization, protecting Singleton pattern.
@@ -60,9 +68,4 @@ class TrueMethodMatcher implements MethodMatcher, Serializable {
return INSTANCE;
}
@Override
public String toString() {
return "MethodMatcher.TRUE";
}
}
@@ -16,6 +16,9 @@
package org.springframework.aop.aspectj;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
@@ -55,7 +58,8 @@ import org.springframework.util.StringUtils;
* @author Ramnivas Laddad
* @since 2.0
*/
public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedenceInformation {
@SuppressWarnings("serial")
public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedenceInformation, Serializable {
/**
* Key used in ReflectiveMethodInvocation userAtributes map for the current joinpoint.
@@ -86,10 +90,13 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
}
protected final Method aspectJAdviceMethod;
private final Class<?> declaringClass;
/** The total number of arguments we have to populate on advice dispatch */
private final int adviceInvocationArgumentCount;
private final String methodName;
private final Class<?>[] parameterTypes;
protected transient Method aspectJAdviceMethod;
private final AspectJExpressionPointcut pointcut;
@@ -135,7 +142,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
*/
private int joinPointStaticPartArgumentIndex = -1;
private Map<String, Integer> argumentBindings = null;
private Map<String, Integer> argumentBindings;
private boolean argumentsIntrospected = false;
@@ -154,8 +161,10 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
Method aspectJAdviceMethod, AspectJExpressionPointcut pointcut, AspectInstanceFactory aspectInstanceFactory) {
Assert.notNull(aspectJAdviceMethod, "Advice method must not be null");
this.declaringClass = aspectJAdviceMethod.getDeclaringClass();
this.methodName = aspectJAdviceMethod.getName();
this.parameterTypes = aspectJAdviceMethod.getParameterTypes();
this.aspectJAdviceMethod = aspectJAdviceMethod;
this.adviceInvocationArgumentCount = this.aspectJAdviceMethod.getParameterTypes().length;
this.pointcut = pointcut;
this.aspectInstanceFactory = aspectInstanceFactory;
}
@@ -250,17 +259,17 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
this.argumentNames[i] + "' that is not a valid Java identifier");
}
}
if (argumentNames != null) {
if (aspectJAdviceMethod.getParameterTypes().length == argumentNames.length + 1) {
if (this.argumentNames != null) {
if (this.aspectJAdviceMethod.getParameterTypes().length == this.argumentNames.length + 1) {
// May need to add implicit join point arg name...
Class<?> firstArgType = aspectJAdviceMethod.getParameterTypes()[0];
Class<?> firstArgType = this.aspectJAdviceMethod.getParameterTypes()[0];
if (firstArgType == JoinPoint.class ||
firstArgType == ProceedingJoinPoint.class ||
firstArgType == JoinPoint.StaticPart.class) {
String[] oldNames = argumentNames;
argumentNames = new String[oldNames.length + 1];
argumentNames[0] = "THIS_JOIN_POINT";
System.arraycopy(oldNames, 0, argumentNames, 1, oldNames.length);
String[] oldNames = this.argumentNames;
this.argumentNames = new String[oldNames.length + 1];
this.argumentNames[0] = "THIS_JOIN_POINT";
System.arraycopy(oldNames, 0, this.argumentNames, 1, oldNames.length);
}
}
}
@@ -359,11 +368,11 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
*/
public synchronized final void calculateArgumentBindings() {
// The simple case... nothing to bind.
if (this.argumentsIntrospected || this.adviceInvocationArgumentCount == 0) {
if (this.argumentsIntrospected || this.parameterTypes.length == 0) {
return;
}
int numUnboundArgs = this.adviceInvocationArgumentCount;
int numUnboundArgs = this.parameterTypes.length;
Class<?>[] parameterTypes = this.aspectJAdviceMethod.getParameterTypes();
if (maybeBindJoinPoint(parameterTypes[0]) || maybeBindProceedingJoinPoint(parameterTypes[0])) {
numUnboundArgs--;
@@ -456,13 +465,13 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
int numExpectedArgumentNames = this.aspectJAdviceMethod.getParameterTypes().length;
if (this.argumentNames.length != numExpectedArgumentNames) {
throw new IllegalStateException("Expecting to find " + numExpectedArgumentNames
+ " arguments to bind by name in advice, but actually found " +
throw new IllegalStateException("Expecting to find " + numExpectedArgumentNames +
" arguments to bind by name in advice, but actually found " +
this.argumentNames.length + " arguments.");
}
// So we match in number...
int argumentIndexOffset = this.adviceInvocationArgumentCount - numArgumentsLeftToBind;
int argumentIndexOffset = this.parameterTypes.length - numArgumentsLeftToBind;
for (int i = argumentIndexOffset; i < this.argumentNames.length; i++) {
this.argumentBindings.put(this.argumentNames[i], i);
}
@@ -471,8 +480,8 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
// specified, and find the discovered argument types.
if (this.returningName != null) {
if (!this.argumentBindings.containsKey(this.returningName)) {
throw new IllegalStateException("Returning argument name '"
+ this.returningName + "' was not bound in advice arguments");
throw new IllegalStateException("Returning argument name '" + this.returningName +
"' was not bound in advice arguments");
}
else {
Integer index = this.argumentBindings.get(this.returningName);
@@ -482,8 +491,8 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
}
if (this.throwingName != null) {
if (!this.argumentBindings.containsKey(this.throwingName)) {
throw new IllegalStateException("Throwing argument name '"
+ this.throwingName + "' was not bound in advice arguments");
throw new IllegalStateException("Throwing argument name '" + this.throwingName +
"' was not bound in advice arguments");
}
else {
Integer index = this.argumentBindings.get(this.throwingName);
@@ -543,7 +552,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
calculateArgumentBindings();
// AMC start
Object[] adviceInvocationArgs = new Object[this.adviceInvocationArgumentCount];
Object[] adviceInvocationArgs = new Object[this.parameterTypes.length];
int numBound = 0;
if (this.joinPointArgumentIndex != -1) {
@@ -580,11 +589,10 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
}
}
if (numBound != this.adviceInvocationArgumentCount) {
throw new IllegalStateException("Required to bind " + this.adviceInvocationArgumentCount
+ " arguments, but only bound " + numBound + " (JoinPointMatch " +
(jpMatch == null ? "was NOT" : "WAS") +
" bound in invocation)");
if (numBound != this.parameterTypes.length) {
throw new IllegalStateException("Required to bind " + this.parameterTypes.length +
" arguments, but only bound " + numBound + " (JoinPointMatch " +
(jpMatch == null ? "was NOT" : "WAS") + " bound in invocation)");
}
return adviceInvocationArgs;
@@ -665,6 +673,16 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
"aspect name '" + this.aspectName + "'";
}
private void readObject(ObjectInputStream inputStream) throws IOException, ClassNotFoundException {
inputStream.defaultReadObject();
try {
this.aspectJAdviceMethod = this.declaringClass.getMethod(this.methodName, this.parameterTypes);
}
catch (NoSuchMethodException ex) {
throw new IllegalStateException("Failed to find advice method on deserialization", ex);
}
}
/**
* MethodMatcher that excludes the specified advice method.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package org.springframework.aop.aspectj;
import java.io.Serializable;
import java.lang.reflect.Method;
import org.aopalliance.intercept.MethodInterceptor;
@@ -29,7 +30,9 @@ import org.springframework.aop.AfterAdvice;
* @author Rod Johnson
* @since 2.0
*/
public class AspectJAfterAdvice extends AbstractAspectJAdvice implements MethodInterceptor, AfterAdvice {
@SuppressWarnings("serial")
public class AspectJAfterAdvice extends AbstractAspectJAdvice
implements MethodInterceptor, AfterAdvice, Serializable {
public AspectJAfterAdvice(
Method aspectJBeforeAdviceMethod, AspectJExpressionPointcut pointcut, AspectInstanceFactory aif) {
@@ -37,6 +40,7 @@ public class AspectJAfterAdvice extends AbstractAspectJAdvice implements MethodI
super(aspectJBeforeAdviceMethod, pointcut, aif);
}
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
try {
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package org.springframework.aop.aspectj;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
@@ -32,7 +33,9 @@ import org.springframework.util.TypeUtils;
* @author Ramnivas Laddad
* @since 2.0
*/
public class AspectJAfterReturningAdvice extends AbstractAspectJAdvice implements AfterReturningAdvice, AfterAdvice {
@SuppressWarnings("serial")
public class AspectJAfterReturningAdvice extends AbstractAspectJAdvice
implements AfterReturningAdvice, AfterAdvice, Serializable {
public AspectJAfterReturningAdvice(
Method aspectJBeforeAdviceMethod, AspectJExpressionPointcut pointcut, AspectInstanceFactory aif) {
@@ -40,6 +43,7 @@ public class AspectJAfterReturningAdvice extends AbstractAspectJAdvice implement
super(aspectJBeforeAdviceMethod, pointcut, aif);
}
@Override
public boolean isBeforeAdvice() {
return false;
@@ -62,6 +66,7 @@ public class AspectJAfterReturningAdvice extends AbstractAspectJAdvice implement
}
}
/**
* Following AspectJ semantics, if a returning clause was specified, then the
* advice is only invoked if the returned value is an instance of the given
@@ -96,7 +101,7 @@ public class AspectJAfterReturningAdvice extends AbstractAspectJAdvice implement
else if (Object.class == type && void.class == method.getReturnType()) {
return true;
}
else{
else {
return ClassUtils.isAssignable(type, method.getReturnType());
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package org.springframework.aop.aspectj;
import java.io.Serializable;
import java.lang.reflect.Method;
import org.aopalliance.intercept.MethodInterceptor;
@@ -29,7 +30,9 @@ import org.springframework.aop.AfterAdvice;
* @author Rod Johnson
* @since 2.0
*/
public class AspectJAfterThrowingAdvice extends AbstractAspectJAdvice implements MethodInterceptor, AfterAdvice {
@SuppressWarnings("serial")
public class AspectJAfterThrowingAdvice extends AbstractAspectJAdvice
implements MethodInterceptor, AfterAdvice, Serializable {
public AspectJAfterThrowingAdvice(
Method aspectJBeforeAdviceMethod, AspectJExpressionPointcut pointcut, AspectInstanceFactory aif) {
@@ -37,6 +40,7 @@ public class AspectJAfterThrowingAdvice extends AbstractAspectJAdvice implements
super(aspectJBeforeAdviceMethod, pointcut, aif);
}
@Override
public boolean isBeforeAdvice() {
return false;
@@ -57,11 +61,11 @@ public class AspectJAfterThrowingAdvice extends AbstractAspectJAdvice implements
try {
return mi.proceed();
}
catch (Throwable t) {
if (shouldInvokeOnThrowing(t)) {
invokeAdviceMethod(getJoinPointMatch(), null, t);
catch (Throwable ex) {
if (shouldInvokeOnThrowing(ex)) {
invokeAdviceMethod(getJoinPointMatch(), null, ex);
}
throw t;
throw ex;
}
}
@@ -69,8 +73,8 @@ public class AspectJAfterThrowingAdvice extends AbstractAspectJAdvice implements
* In AspectJ semantics, after throwing advice that specifies a throwing clause
* is only invoked if the thrown exception is a subtype of the given throwing type.
*/
private boolean shouldInvokeOnThrowing(Throwable t) {
return getDiscoveredThrowingType().isAssignableFrom(t.getClass());
private boolean shouldInvokeOnThrowing(Throwable ex) {
return getDiscoveredThrowingType().isAssignableFrom(ex.getClass());
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package org.springframework.aop.aspectj;
import java.io.Serializable;
import java.lang.reflect.Method;
import org.aopalliance.intercept.MethodInterceptor;
@@ -33,7 +34,8 @@ import org.springframework.aop.ProxyMethodInvocation;
* @author Juergen Hoeller
* @since 2.0
*/
public class AspectJAroundAdvice extends AbstractAspectJAdvice implements MethodInterceptor {
@SuppressWarnings("serial")
public class AspectJAroundAdvice extends AbstractAspectJAdvice implements MethodInterceptor, Serializable {
public AspectJAroundAdvice(
Method aspectJAroundAdviceMethod, AspectJExpressionPointcut pointcut, AspectInstanceFactory aif) {
@@ -41,6 +43,7 @@ public class AspectJAroundAdvice extends AbstractAspectJAdvice implements Method
super(aspectJAroundAdviceMethod, pointcut, aif);
}
@Override
public boolean isBeforeAdvice() {
return false;
@@ -56,7 +59,6 @@ public class AspectJAroundAdvice extends AbstractAspectJAdvice implements Method
return true;
}
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
if (!(mi instanceof ProxyMethodInvocation)) {
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,6 @@ import java.util.concurrent.ConcurrentHashMap;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.aspectj.weaver.BCException;
import org.aspectj.weaver.patterns.NamePattern;
import org.aspectj.weaver.reflect.ReflectionWorld.ReflectionWorldException;
import org.aspectj.weaver.reflect.ShadowMatchImpl;
@@ -187,13 +186,24 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
throw new IllegalStateException("Must set property 'expression' before attempting to match");
}
if (this.pointcutExpression == null) {
this.pointcutClassLoader = (this.beanFactory instanceof ConfigurableBeanFactory ?
((ConfigurableBeanFactory) this.beanFactory).getBeanClassLoader() :
ClassUtils.getDefaultClassLoader());
this.pointcutClassLoader = determinePointcutClassLoader();
this.pointcutExpression = buildPointcutExpression(this.pointcutClassLoader);
}
}
/**
* Determine the ClassLoader to use for pointcut evaluation.
*/
private ClassLoader determinePointcutClassLoader() {
if (this.beanFactory instanceof ConfigurableBeanFactory) {
return ((ConfigurableBeanFactory) this.beanFactory).getBeanClassLoader();
}
if (this.pointcutDeclarationScope != null) {
return this.pointcutDeclarationScope.getClassLoader();
}
return ClassUtils.getDefaultClassLoader();
}
/**
* Build the underlying AspectJ pointcut expression.
*/
@@ -258,7 +268,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
}
}
}
catch (BCException ex) {
catch (Throwable ex) {
logger.debug("PointcutExpression matching rejected target class", ex);
}
return false;
@@ -305,7 +315,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
}
@Override
public boolean matches(Method method, Class<?> targetClass, Object[] args) {
public boolean matches(Method method, Class<?> targetClass, Object... args) {
checkReadyToMatch();
ShadowMatch shadowMatch = getShadowMatch(AopUtils.getMostSpecificMethod(method, targetClass), method);
ShadowMatch originalShadowMatch = getShadowMatch(method, method);
@@ -326,7 +336,6 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
}
catch (IllegalStateException ex) {
// No current invocation...
// TODO: Should we really proceed here?
if (logger.isDebugEnabled()) {
logger.debug("Could not access current invocation - matching with limited context: " + ex);
}
@@ -413,39 +422,46 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
shadowMatch = this.shadowMatchCache.get(targetMethod);
if (shadowMatch == null) {
try {
shadowMatch = this.pointcutExpression.matchesMethodExecution(methodToMatch);
}
catch (ReflectionWorldException ex) {
// Failed to introspect target method, probably because it has been loaded
// in a special ClassLoader. Let's try the declaring ClassLoader instead...
try {
fallbackExpression = getFallbackPointcutExpression(methodToMatch.getDeclaringClass());
if (fallbackExpression != null) {
shadowMatch = fallbackExpression.matchesMethodExecution(methodToMatch);
}
}
catch (ReflectionWorldException ex2) {
fallbackExpression = null;
}
}
if (shadowMatch == null && targetMethod != originalMethod) {
methodToMatch = originalMethod;
try {
shadowMatch = this.pointcutExpression.matchesMethodExecution(methodToMatch);
}
catch (ReflectionWorldException ex3) {
// Could neither introspect the target class nor the proxy class ->
// let's try the original method's declaring class before we give up...
catch (ReflectionWorldException ex) {
// Failed to introspect target method, probably because it has been loaded
// in a special ClassLoader. Let's try the declaring ClassLoader instead...
try {
fallbackExpression = getFallbackPointcutExpression(methodToMatch.getDeclaringClass());
if (fallbackExpression != null) {
shadowMatch = fallbackExpression.matchesMethodExecution(methodToMatch);
}
}
catch (ReflectionWorldException ex4) {
catch (ReflectionWorldException ex2) {
fallbackExpression = null;
}
}
if (shadowMatch == null && targetMethod != originalMethod) {
methodToMatch = originalMethod;
try {
shadowMatch = this.pointcutExpression.matchesMethodExecution(methodToMatch);
}
catch (ReflectionWorldException ex3) {
// Could neither introspect the target class nor the proxy class ->
// let's try the original method's declaring class before we give up...
try {
fallbackExpression = getFallbackPointcutExpression(methodToMatch.getDeclaringClass());
if (fallbackExpression != null) {
shadowMatch = fallbackExpression.matchesMethodExecution(methodToMatch);
}
}
catch (ReflectionWorldException ex4) {
fallbackExpression = null;
}
}
}
}
catch (Throwable ex) {
// Possibly AspectJ 1.8.10 encountering an invalid signature
logger.debug("PointcutExpression matching rejected target method", ex);
fallbackExpression = null;
}
if (shadowMatch == null) {
shadowMatch = new ShadowMatchImpl(org.aspectj.util.FuzzyBoolean.NO, null, null, null);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,8 @@ package org.springframework.aop.aspectj;
import org.springframework.aop.Pointcut;
import org.springframework.aop.support.AbstractGenericPointcutAdvisor;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
/**
* Spring AOP Advisor that can be used for any AspectJ pointcut expression.
@@ -26,16 +28,11 @@ import org.springframework.aop.support.AbstractGenericPointcutAdvisor;
* @since 2.0
*/
@SuppressWarnings("serial")
public class AspectJExpressionPointcutAdvisor extends AbstractGenericPointcutAdvisor {
public class AspectJExpressionPointcutAdvisor extends AbstractGenericPointcutAdvisor implements BeanFactoryAware {
private final AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
@Override
public Pointcut getPointcut() {
return this.pointcut;
}
public void setExpression(String expression) {
this.pointcut.setExpression(expression);
}
@@ -52,12 +49,22 @@ public class AspectJExpressionPointcutAdvisor extends AbstractGenericPointcutAdv
return this.pointcut.getLocation();
}
public void setParameterTypes(Class<?>[] types) {
this.pointcut.setParameterTypes(types);
}
public void setParameterNames(String... names) {
this.pointcut.setParameterNames(names);
}
public void setParameterTypes(Class<?>... types) {
this.pointcut.setParameterTypes(types);
}
@Override
public void setBeanFactory(BeanFactory beanFactory) {
this.pointcut.setBeanFactory(beanFactory);
}
@Override
public Pointcut getPointcut() {
return this.pointcut;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package org.springframework.aop.aspectj;
import java.io.Serializable;
import java.lang.reflect.Method;
import org.springframework.aop.MethodBeforeAdvice;
@@ -27,7 +28,8 @@ import org.springframework.aop.MethodBeforeAdvice;
* @author Adrian Colyer
* @since 2.0
*/
public class AspectJMethodBeforeAdvice extends AbstractAspectJAdvice implements MethodBeforeAdvice {
@SuppressWarnings("serial")
public class AspectJMethodBeforeAdvice extends AbstractAspectJAdvice implements MethodBeforeAdvice, Serializable {
public AspectJMethodBeforeAdvice(
Method aspectJBeforeAdviceMethod, AspectJExpressionPointcut pointcut, AspectInstanceFactory aif) {
@@ -35,6 +37,7 @@ public class AspectJMethodBeforeAdvice extends AbstractAspectJAdvice implements
super(aspectJBeforeAdviceMethod, pointcut, aif);
}
@Override
public void before(Method method, Object[] args, Object target) throws Throwable {
invokeAdviceMethod(getJoinPointMatch(), null, null);
@@ -65,7 +65,7 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor {
/**
* Private constructor to share common code between impl-based delegate and reference-based delegate
* (cannot use method such as init() to share common code, due the the use of final fields)
* (cannot use method such as init() to share common code, due the use of final fields)
* @param interfaceType static field defining the introduction
* @param typePattern type pattern the introduction is restricted to
* @param implementationClass implementation class
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -55,10 +55,12 @@ public class SimpleAspectInstanceFactory implements AspectInstanceFactory {
return this.aspectClass.newInstance();
}
catch (InstantiationException ex) {
throw new AopConfigException("Unable to instantiate aspect class [" + this.aspectClass.getName() + "]", ex);
throw new AopConfigException(
"Unable to instantiate aspect class: " + this.aspectClass.getName(), ex);
}
catch (IllegalAccessException ex) {
throw new AopConfigException("Cannot access element class [" + this.aspectClass.getName() + "]", ex);
throw new AopConfigException(
"Could not access aspect constructor: " + this.aspectClass.getName(), ex);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
package org.springframework.aop.aspectj;
import java.io.Serializable;
import org.springframework.core.Ordered;
import org.springframework.util.Assert;
@@ -29,7 +31,8 @@ import org.springframework.util.Assert;
* @since 2.0
* @see SimpleAspectInstanceFactory
*/
public class SingletonAspectInstanceFactory implements AspectInstanceFactory {
@SuppressWarnings("serial")
public class SingletonAspectInstanceFactory implements AspectInstanceFactory, Serializable {
private final Object aspectInstance;
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@ import org.springframework.util.StringUtils;
* Spring AOP {@link ClassFilter} implementation using AspectJ type matching.
*
* @author Rod Johnson
* @author Juergen Hoeller
* @since 2.0
*/
public class TypePatternClassFilter implements ClassFilter {
@@ -76,17 +77,21 @@ public class TypePatternClassFilter implements ClassFilter {
* or is recognized as invalid
*/
public void setTypePattern(String typePattern) {
Assert.notNull(typePattern);
Assert.notNull(typePattern, "Type pattern must not be null");
this.typePattern = typePattern;
this.aspectJTypePatternMatcher =
PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingContextClassloaderForResolution().
parseTypePattern(replaceBooleanOperators(typePattern));
}
/**
* Return the AspectJ type pattern to match.
*/
public String getTypePattern() {
return typePattern;
return this.typePattern;
}
/**
* Should the pointcut apply to the given interface or target class?
* @param clazz candidate target class
@@ -95,9 +100,7 @@ public class TypePatternClassFilter implements ClassFilter {
*/
@Override
public boolean matches(Class<?> clazz) {
if (this.aspectJTypePatternMatcher == null) {
throw new IllegalStateException("No 'typePattern' has been set via ctor/setter.");
}
Assert.state(this.aspectJTypePatternMatcher != null, "No type pattern has been set");
return this.aspectJTypePatternMatcher.matches(clazz);
}
@@ -108,9 +111,8 @@ public class TypePatternClassFilter implements ClassFilter {
* <p>This method converts back to {@code &&} for the AspectJ pointcut parser.
*/
private String replaceBooleanOperators(String pcExpr) {
pcExpr = StringUtils.replace(pcExpr," and "," && ");
pcExpr = StringUtils.replace(pcExpr, " or ", " || ");
pcExpr = StringUtils.replace(pcExpr, " not ", " ! ");
return pcExpr;
String result = StringUtils.replace(pcExpr," and "," && ");
result = StringUtils.replace(result, " or ", " || ");
return StringUtils.replace(result, " not ", " ! ");
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +38,6 @@ import org.aspectj.lang.reflect.AjType;
import org.aspectj.lang.reflect.AjTypeSystem;
import org.aspectj.lang.reflect.PerClauseKind;
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
import org.springframework.aop.framework.AopConfigException;
import org.springframework.core.ParameterNameDiscoverer;
import org.springframework.core.annotation.AnnotationUtils;
@@ -61,34 +60,6 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
private static final String AJC_MAGIC = "ajc$";
/**
* Find and return the first AspectJ annotation on the given method
* (there <i>should</i> only be one anyway...)
*/
@SuppressWarnings("unchecked")
protected static AspectJAnnotation<?> findAspectJAnnotationOnMethod(Method method) {
Class<?>[] classesToLookFor = new Class<?>[] {
Before.class, Around.class, After.class, AfterReturning.class, AfterThrowing.class, Pointcut.class};
for (Class<?> c : classesToLookFor) {
AspectJAnnotation<?> foundAnnotation = findAnnotation(method, (Class<Annotation>) c);
if (foundAnnotation != null) {
return foundAnnotation;
}
}
return null;
}
private static <A extends Annotation> AspectJAnnotation<A> findAnnotation(Method method, Class<A> toLookFor) {
A result = AnnotationUtils.findAnnotation(method, toLookFor);
if (result != null) {
return new AspectJAnnotation<A>(result);
}
else {
return null;
}
}
/** Logger available to subclasses */
protected final Log logger = LogFactory.getLog(getClass());
@@ -150,48 +121,35 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
}
/**
* The pointcut and advice annotations both have an "argNames" member which contains a
* comma-separated list of the argument names. We use this (if non-empty) to build the
* formal parameters for the pointcut.
* Find and return the first AspectJ annotation on the given method
* (there <i>should</i> only be one anyway...)
*/
protected AspectJExpressionPointcut createPointcutExpression(
Method annotatedMethod, Class<?> declarationScope, String[] pointcutParameterNames) {
Class<?> [] pointcutParameterTypes = new Class<?>[0];
if (pointcutParameterNames != null) {
pointcutParameterTypes = extractPointcutParameterTypes(pointcutParameterNames,annotatedMethod);
@SuppressWarnings("unchecked")
protected static AspectJAnnotation<?> findAspectJAnnotationOnMethod(Method method) {
Class<?>[] classesToLookFor = new Class<?>[] {
Before.class, Around.class, After.class, AfterReturning.class, AfterThrowing.class, Pointcut.class};
for (Class<?> c : classesToLookFor) {
AspectJAnnotation<?> foundAnnotation = findAnnotation(method, (Class<Annotation>) c);
if (foundAnnotation != null) {
return foundAnnotation;
}
}
AspectJExpressionPointcut ajexp =
new AspectJExpressionPointcut(declarationScope,pointcutParameterNames,pointcutParameterTypes);
ajexp.setLocation(annotatedMethod.toString());
return ajexp;
return null;
}
/**
* Create the pointcut parameters needed by aspectj based on the given argument names
* and the argument types that are available from the adviceMethod. Needs to take into
* account (ignore) any JoinPoint based arguments as these are not pointcut context but
* rather part of the advice execution context (thisJoinPoint, thisJoinPointStaticPart)
*/
private Class<?>[] extractPointcutParameterTypes(String[] argNames, Method adviceMethod) {
Class<?>[] ret = new Class<?>[argNames.length];
Class<?>[] paramTypes = adviceMethod.getParameterTypes();
if (argNames.length > paramTypes.length) {
throw new IllegalStateException("Expecting at least " + argNames.length +
" arguments in the advice declaration, but only found " + paramTypes.length);
private static <A extends Annotation> AspectJAnnotation<A> findAnnotation(Method method, Class<A> toLookFor) {
A result = AnnotationUtils.findAnnotation(method, toLookFor);
if (result != null) {
return new AspectJAnnotation<A>(result);
}
// Make the simplifying assumption for now that all of the JoinPoint based arguments
// come first in the advice declaration.
int typeOffset = paramTypes.length - argNames.length;
for (int i = 0; i < ret.length; i++) {
ret[i] = paramTypes[i + typeOffset];
else {
return null;
}
return ret;
}
protected enum AspectJAnnotationType {
AtPointcut,
AtBefore,
AtAfter,
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,7 +50,7 @@ public class AnnotationAwareAspectJAutoProxyCreator extends AspectJAwareAdvisorA
private List<Pattern> includePatterns;
private AspectJAdvisorFactory aspectJAdvisorFactory = new ReflectiveAspectJAdvisorFactory();
private AspectJAdvisorFactory aspectJAdvisorFactory;
private BeanFactoryAspectJAdvisorsBuilder aspectJAdvisorsBuilder;
@@ -74,6 +74,9 @@ public class AnnotationAwareAspectJAutoProxyCreator extends AspectJAwareAdvisorA
@Override
protected void initBeanFactory(ConfigurableListableBeanFactory beanFactory) {
super.initBeanFactory(beanFactory);
if (this.aspectJAdvisorFactory == null) {
this.aspectJAdvisorFactory = new ReflectiveAspectJAdvisorFactory(beanFactory);
}
this.aspectJAdvisorsBuilder =
new BeanFactoryAspectJAdvisorsBuilderAdapter(beanFactory, this.aspectJAdvisorFactory);
}
@@ -130,6 +133,7 @@ public class AnnotationAwareAspectJAutoProxyCreator extends AspectJAwareAdvisorA
public BeanFactoryAspectJAdvisorsBuilderAdapter(
ListableBeanFactory beanFactory, AspectJAdvisorFactory advisorFactory) {
super(beanFactory, advisorFactory);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -63,31 +63,31 @@ public interface AspectJAdvisorFactory {
/**
* Build Spring AOP Advisors for all annotated At-AspectJ methods
* on the specified aspect instance.
* @param aif the aspect instance factory (not the aspect instance itself
* in order to avoid eager instantiation)
* @param aspectInstanceFactory the aspect instance factory
* (not the aspect instance itself in order to avoid eager instantiation)
* @return a list of advisors for this class
*/
List<Advisor> getAdvisors(MetadataAwareAspectInstanceFactory aif);
List<Advisor> getAdvisors(MetadataAwareAspectInstanceFactory aspectInstanceFactory);
/**
* Build a Spring AOP Advisor for the given AspectJ advice method.
* @param candidateAdviceMethod the candidate advice method
* @param aif the aspect instance factory
* @param declarationOrderInAspect the declaration order within the aspect
* @param aspectInstanceFactory the aspect instance factory
* @param declarationOrder the declaration order within the aspect
* @param aspectName the name of the aspect
* @return {@code null} if the method is not an AspectJ advice method
* or if it is a pointcut that will be used by other advice but will not
* create a Spring advice in its own right
*/
Advisor getAdvisor(Method candidateAdviceMethod,
MetadataAwareAspectInstanceFactory aif, int declarationOrderInAspect, String aspectName);
Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aspectInstanceFactory,
int declarationOrder, String aspectName);
/**
* Build a Spring AOP Advice for the given AspectJ advice method.
* @param candidateAdviceMethod the candidate advice method
* @param pointcut the corresponding AspectJ expression pointcut
* @param aif the aspect instance factory
* @param declarationOrderInAspect the declaration order within the aspect
* @param expressionPointcut the AspectJ expression pointcut
* @param aspectInstanceFactory the aspect instance factory
* @param declarationOrder the declaration order within the aspect
* @param aspectName the name of the aspect
* @return {@code null} if the method is not an AspectJ advice method
* or if it is a pointcut that will be used by other advice but will not
@@ -98,7 +98,7 @@ public interface AspectJAdvisorFactory {
* @see org.springframework.aop.aspectj.AspectJAfterReturningAdvice
* @see org.springframework.aop.aspectj.AspectJAfterThrowingAdvice
*/
Advice getAdvice(Method candidateAdviceMethod, AspectJExpressionPointcut pointcut,
MetadataAwareAspectInstanceFactory aif, int declarationOrderInAspect, String aspectName);
Advice getAdvice(Method candidateAdviceMethod, AspectJExpressionPointcut expressionPointcut,
MetadataAwareAspectInstanceFactory aspectInstanceFactory, int declarationOrder, String aspectName);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,9 +16,9 @@
package org.springframework.aop.aspectj.annotation;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.aspectj.lang.reflect.PerClauseKind;
@@ -50,7 +50,7 @@ import org.springframework.util.ClassUtils;
public class AspectJProxyFactory extends ProxyCreatorSupport {
/** Cache for singleton aspect instances */
private static final Map<Class<?>, Object> aspectCache = new HashMap<Class<?>, Object>();
private static final Map<Class<?>, Object> aspectCache = new ConcurrentHashMap<Class<?>, Object>();
private final AspectJAdvisorFactory aspectFactory = new ReflectiveAspectJAdvisorFactory();
@@ -144,7 +144,7 @@ public class AspectJProxyFactory extends ProxyCreatorSupport {
private MetadataAwareAspectInstanceFactory createAspectInstanceFactory(
AspectMetadata am, Class<?> aspectClass, String aspectName) {
MetadataAwareAspectInstanceFactory instanceFactory = null;
MetadataAwareAspectInstanceFactory instanceFactory;
if (am.getAjType().getPerClause().getKind() == PerClauseKind.SINGLETON) {
// Create a shared aspect instance.
Object instance = getSingletonAspectInstance(aspectClass);
@@ -162,23 +162,29 @@ public class AspectJProxyFactory extends ProxyCreatorSupport {
* is created if one cannot be found in the instance cache.
*/
private Object getSingletonAspectInstance(Class<?> aspectClass) {
synchronized (aspectCache) {
Object instance = aspectCache.get(aspectClass);
if (instance != null) {
return instance;
}
try {
instance = aspectClass.newInstance();
aspectCache.put(aspectClass, instance);
return instance;
}
catch (InstantiationException ex) {
throw new AopConfigException("Unable to instantiate aspect class [" + aspectClass.getName() + "]", ex);
}
catch (IllegalAccessException ex) {
throw new AopConfigException("Cannot access aspect class [" + aspectClass.getName() + "]", ex);
// Quick check without a lock...
Object instance = aspectCache.get(aspectClass);
if (instance == null) {
synchronized (aspectCache) {
// To be safe, check within full lock now...
instance = aspectCache.get(aspectClass);
if (instance != null) {
return instance;
}
try {
instance = aspectClass.newInstance();
aspectCache.put(aspectClass, instance);
return instance;
}
catch (InstantiationException ex) {
throw new AopConfigException("Unable to instantiate aspect class [" + aspectClass.getName() + "]", ex);
}
catch (IllegalAccessException ex) {
throw new AopConfigException("Cannot access aspect class [" + aspectClass.getName() + "]", ex);
}
}
}
return instance;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,10 @@
package org.springframework.aop.aspectj.annotation;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.AjType;
import org.aspectj.lang.reflect.AjTypeSystem;
@@ -31,21 +35,35 @@ import org.springframework.aop.support.ComposablePointcut;
* Metadata for an AspectJ aspect class, with an additional Spring AOP pointcut
* for the per clause.
*
* <p>Uses AspectJ 5 AJType reflection API, so is only supported on Java 5.
* Enables us to work with different AspectJ instantiation models such as
* "singleton", "pertarget" and "perthis".
* <p>Uses AspectJ 5 AJType reflection API, enabling us to work with different
* AspectJ instantiation models such as "singleton", "pertarget" and "perthis".
*
* @author Rod Johnson
* @author Juergen Hoeller
* @since 2.0
* @see org.springframework.aop.aspectj.AspectJExpressionPointcut
*/
public class AspectMetadata {
@SuppressWarnings("serial")
public class AspectMetadata implements Serializable {
/**
* The name of this aspect as defined to Spring (the bean name) -
* allows us to determine if two pieces of advice come from the
* same aspect and hence their relative precedence.
*/
private final String aspectName;
/**
* The aspect class, stored separately for re-resolution of the
* corresponding AjType on deserialization.
*/
private final Class<?> aspectClass;
/**
* AspectJ reflection information (AspectJ 5 / Java 5 specific).
* Re-resolved on deserialization since it isn't serializable itself.
*/
private final AjType<?> ajType;
private transient AjType<?> ajType;
/**
* Spring AOP pointcut corresponding to the per clause of the
@@ -54,13 +72,6 @@ public class AspectMetadata {
*/
private final Pointcut perClausePointcut;
/**
* The name of this aspect as defined to Spring (the bean name) -
* allows us to determine if two pieces of advice come from the
* same aspect and hence their relative precedence.
*/
private String aspectName;
/**
* Create a new AspectMetadata instance for the given aspect class.
@@ -83,26 +94,29 @@ public class AspectMetadata {
if (ajType == null) {
throw new IllegalArgumentException("Class '" + aspectClass.getName() + "' is not an @AspectJ aspect");
}
this.ajType = ajType;
if (this.ajType.getDeclarePrecedence().length > 0) {
if (ajType.getDeclarePrecedence().length > 0) {
throw new IllegalArgumentException("DeclarePrecendence not presently supported in Spring AOP");
}
this.aspectClass = ajType.getJavaClass();
this.ajType = ajType;
switch (this.ajType.getPerClause().getKind()) {
case SINGLETON :
case SINGLETON:
this.perClausePointcut = Pointcut.TRUE;
return;
case PERTARGET : case PERTHIS :
case PERTARGET:
case PERTHIS:
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setLocation("@Aspect annotation on " + aspectClass.getName());
ajexp.setLocation(aspectClass.getName());
ajexp.setExpression(findPerClause(aspectClass));
ajexp.setPointcutDeclarationScope(aspectClass);
this.perClausePointcut = ajexp;
return;
case PERTYPEWITHIN :
case PERTYPEWITHIN:
// Works with a type pattern
this.perClausePointcut = new ComposablePointcut(new TypePatternClassFilter(findPerClause(aspectClass)));
return;
default :
default:
throw new AopConfigException(
"PerClause " + ajType.getPerClause().getKind() + " not supported by Spring AOP for " + aspectClass);
}
@@ -112,8 +126,6 @@ public class AspectMetadata {
* Extract contents from String of form {@code pertarget(contents)}.
*/
private String findPerClause(Class<?> aspectClass) {
// TODO when AspectJ provides this, we can remove this hack. Hence we don't
// bother to make it elegant. Or efficient. Or robust :-)
String str = aspectClass.getAnnotation(Aspect.class).value();
str = str.substring(str.indexOf("(") + 1);
str = str.substring(0, str.length() - 1);
@@ -132,7 +144,7 @@ public class AspectMetadata {
* Return the aspect class.
*/
public Class<?> getAspectClass() {
return this.ajType.getJavaClass();
return this.aspectClass;
}
/**
@@ -173,4 +185,10 @@ public class AspectMetadata {
return (isPerThisOrPerTarget() || isPerTypeWithin());
}
private void readObject(ObjectInputStream inputStream) throws IOException, ClassNotFoundException {
inputStream.defaultReadObject();
this.ajType = AjTypeSystem.getAjType(this.aspectClass);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,10 +16,13 @@
package org.springframework.aop.aspectj.annotation;
import java.io.Serializable;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.OrderUtils;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
/**
@@ -37,7 +40,8 @@ import org.springframework.util.ClassUtils;
* @see org.springframework.beans.factory.BeanFactory
* @see LazySingletonAspectInstanceFactoryDecorator
*/
public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInstanceFactory {
@SuppressWarnings("serial")
public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInstanceFactory, Serializable {
private final BeanFactory beanFactory;
@@ -66,6 +70,8 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst
* @param type the type that should be introspected by AspectJ
*/
public BeanFactoryAspectInstanceFactory(BeanFactory beanFactory, String name, Class<?> type) {
Assert.notNull(beanFactory, "BeanFactory must not be null");
Assert.notNull(name, "Bean name must not be null");
this.beanFactory = beanFactory;
this.name = name;
this.aspectMetadata = new AspectMetadata(type, name);
@@ -79,12 +85,9 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst
@Override
public ClassLoader getAspectClassLoader() {
if (this.beanFactory instanceof ConfigurableBeanFactory) {
return ((ConfigurableBeanFactory) this.beanFactory).getBeanClassLoader();
}
else {
return ClassUtils.getDefaultClassLoader();
}
return (this.beanFactory instanceof ConfigurableBeanFactory ?
((ConfigurableBeanFactory) this.beanFactory).getBeanClassLoader() :
ClassUtils.getDefaultClassLoader());
}
@Override
@@ -92,6 +95,23 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst
return this.aspectMetadata;
}
@Override
public Object getAspectCreationMutex() {
if (this.beanFactory != null) {
if (this.beanFactory.isSingleton(name)) {
// Rely on singleton semantics provided by the factory -> no local lock.
return null;
}
else if (this.beanFactory instanceof ConfigurableBeanFactory) {
// No singleton guarantees from the factory -> let's lock locally but
// reuse the factory's singleton lock, just in case a lazy dependency
// of our advice bean happens to trigger the singleton lock implicitly...
return ((ConfigurableBeanFactory) this.beanFactory).getSingletonMutex();
}
}
return this;
}
/**
* Determine the order for this factory's target aspect, either
* an instance-specific order expressed through implementing the
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,10 +17,10 @@
package org.springframework.aop.aspectj.annotation;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.aspectj.lang.reflect.PerClauseKind;
@@ -43,12 +43,12 @@ public class BeanFactoryAspectJAdvisorsBuilder {
private final AspectJAdvisorFactory advisorFactory;
private List<String> aspectBeanNames;
private volatile List<String> aspectBeanNames;
private final Map<String, List<Advisor>> advisorsCache = new HashMap<String, List<Advisor>>();
private final Map<String, List<Advisor>> advisorsCache = new ConcurrentHashMap<String, List<Advisor>>();
private final Map<String, MetadataAwareAspectInstanceFactory> aspectFactoryCache =
new HashMap<String, MetadataAwareAspectInstanceFactory>();
new ConcurrentHashMap<String, MetadataAwareAspectInstanceFactory>();
/**
@@ -56,7 +56,7 @@ public class BeanFactoryAspectJAdvisorsBuilder {
* @param beanFactory the ListableBeanFactory to scan
*/
public BeanFactoryAspectJAdvisorsBuilder(ListableBeanFactory beanFactory) {
this(beanFactory, new ReflectiveAspectJAdvisorFactory());
this(beanFactory, new ReflectiveAspectJAdvisorFactory(beanFactory));
}
/**
@@ -80,56 +80,57 @@ public class BeanFactoryAspectJAdvisorsBuilder {
* @see #isEligibleBean
*/
public List<Advisor> buildAspectJAdvisors() {
List<String> aspectNames = null;
List<String> aspectNames = this.aspectBeanNames;
synchronized (this) {
aspectNames = this.aspectBeanNames;
if (aspectNames == null) {
List<Advisor> advisors = new LinkedList<Advisor>();
aspectNames = new LinkedList<String>();
String[] beanNames =
BeanFactoryUtils.beanNamesForTypeIncludingAncestors(this.beanFactory, Object.class, true, false);
for (String beanName : beanNames) {
if (!isEligibleBean(beanName)) {
continue;
}
// We must be careful not to instantiate beans eagerly as in this
// case they would be cached by the Spring container but would not
// have been weaved
Class<?> beanType = this.beanFactory.getType(beanName);
if (beanType == null) {
continue;
}
if (this.advisorFactory.isAspect(beanType)) {
aspectNames.add(beanName);
AspectMetadata amd = new AspectMetadata(beanType, beanName);
if (amd.getAjType().getPerClause().getKind() == PerClauseKind.SINGLETON) {
MetadataAwareAspectInstanceFactory factory =
new BeanFactoryAspectInstanceFactory(this.beanFactory, beanName);
List<Advisor> classAdvisors = this.advisorFactory.getAdvisors(factory);
if (this.beanFactory.isSingleton(beanName)) {
this.advisorsCache.put(beanName, classAdvisors);
if (aspectNames == null) {
synchronized (this) {
aspectNames = this.aspectBeanNames;
if (aspectNames == null) {
List<Advisor> advisors = new LinkedList<Advisor>();
aspectNames = new LinkedList<String>();
String[] beanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
this.beanFactory, Object.class, true, false);
for (String beanName : beanNames) {
if (!isEligibleBean(beanName)) {
continue;
}
// We must be careful not to instantiate beans eagerly as in this case they
// would be cached by the Spring container but would not have been weaved.
Class<?> beanType = this.beanFactory.getType(beanName);
if (beanType == null) {
continue;
}
if (this.advisorFactory.isAspect(beanType)) {
aspectNames.add(beanName);
AspectMetadata amd = new AspectMetadata(beanType, beanName);
if (amd.getAjType().getPerClause().getKind() == PerClauseKind.SINGLETON) {
MetadataAwareAspectInstanceFactory factory =
new BeanFactoryAspectInstanceFactory(this.beanFactory, beanName);
List<Advisor> classAdvisors = this.advisorFactory.getAdvisors(factory);
if (this.beanFactory.isSingleton(beanName)) {
this.advisorsCache.put(beanName, classAdvisors);
}
else {
this.aspectFactoryCache.put(beanName, factory);
}
advisors.addAll(classAdvisors);
}
else {
// Per target or per this.
if (this.beanFactory.isSingleton(beanName)) {
throw new IllegalArgumentException("Bean with name '" + beanName +
"' is a singleton, but aspect instantiation model is not singleton");
}
MetadataAwareAspectInstanceFactory factory =
new PrototypeAspectInstanceFactory(this.beanFactory, beanName);
this.aspectFactoryCache.put(beanName, factory);
advisors.addAll(this.advisorFactory.getAdvisors(factory));
}
advisors.addAll(classAdvisors);
}
else {
// Per target or per this.
if (this.beanFactory.isSingleton(beanName)) {
throw new IllegalArgumentException("Bean with name '" + beanName +
"' is a singleton, but aspect instantiation model is not singleton");
}
MetadataAwareAspectInstanceFactory factory =
new PrototypeAspectInstanceFactory(this.beanFactory, beanName);
this.aspectFactoryCache.put(beanName, factory);
advisors.addAll(this.advisorFactory.getAdvisors(factory));
}
}
this.aspectBeanNames = aspectNames;
return advisors;
}
this.aspectBeanNames = aspectNames;
return advisors;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,9 @@
package org.springframework.aop.aspectj.annotation;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.lang.reflect.Method;
import org.aopalliance.aop.Advice;
@@ -37,58 +40,70 @@ import org.springframework.aop.support.Pointcuts;
* @author Juergen Hoeller
* @since 2.0
*/
@SuppressWarnings("serial")
class InstantiationModelAwarePointcutAdvisorImpl
implements InstantiationModelAwarePointcutAdvisor, AspectJPrecedenceInformation {
implements InstantiationModelAwarePointcutAdvisor, AspectJPrecedenceInformation, Serializable {
private final AspectJExpressionPointcut declaredPointcut;
private Pointcut pointcut;
private final Class<?> declaringClass;
private final String methodName;
private final Class<?>[] parameterTypes;
private transient Method aspectJAdviceMethod;
private final AspectJAdvisorFactory aspectJAdvisorFactory;
private final MetadataAwareAspectInstanceFactory aspectInstanceFactory;
private final Method method;
private final int declarationOrder;
private final String aspectName;
private final Pointcut pointcut;
private final boolean lazy;
private final AspectJAdvisorFactory atAspectJAdvisorFactory;
private Advice instantiatedAdvice;
private int declarationOrder;
private String aspectName;
private Boolean isBeforeAdvice;
private Boolean isAfterAdvice;
public InstantiationModelAwarePointcutAdvisorImpl(AspectJAdvisorFactory af, AspectJExpressionPointcut ajexp,
MetadataAwareAspectInstanceFactory aif, Method method, int declarationOrderInAspect, String aspectName) {
public InstantiationModelAwarePointcutAdvisorImpl(AspectJExpressionPointcut declaredPointcut,
Method aspectJAdviceMethod, AspectJAdvisorFactory aspectJAdvisorFactory,
MetadataAwareAspectInstanceFactory aspectInstanceFactory, int declarationOrder, String aspectName) {
this.declaredPointcut = ajexp;
this.method = method;
this.atAspectJAdvisorFactory = af;
this.aspectInstanceFactory = aif;
this.declarationOrder = declarationOrderInAspect;
this.declaredPointcut = declaredPointcut;
this.declaringClass = aspectJAdviceMethod.getDeclaringClass();
this.methodName = aspectJAdviceMethod.getName();
this.parameterTypes = aspectJAdviceMethod.getParameterTypes();
this.aspectJAdviceMethod = aspectJAdviceMethod;
this.aspectJAdvisorFactory = aspectJAdvisorFactory;
this.aspectInstanceFactory = aspectInstanceFactory;
this.declarationOrder = declarationOrder;
this.aspectName = aspectName;
if (aif.getAspectMetadata().isLazilyInstantiated()) {
if (aspectInstanceFactory.getAspectMetadata().isLazilyInstantiated()) {
// Static part of the pointcut is a lazy type.
Pointcut preInstantiationPointcut =
Pointcuts.union(aif.getAspectMetadata().getPerClausePointcut(), this.declaredPointcut);
Pointcut preInstantiationPointcut = Pointcuts.union(
aspectInstanceFactory.getAspectMetadata().getPerClausePointcut(), this.declaredPointcut);
// Make it dynamic: must mutate from pre-instantiation to post-instantiation state.
// If it's not a dynamic pointcut, it may be optimized out
// by the Spring AOP infrastructure after the first evaluation.
this.pointcut = new PerTargetInstantiationModelPointcut(this.declaredPointcut, preInstantiationPointcut, aif);
this.pointcut = new PerTargetInstantiationModelPointcut(
this.declaredPointcut, preInstantiationPointcut, aspectInstanceFactory);
this.lazy = true;
}
else {
// A singleton aspect.
this.instantiatedAdvice = instantiateAdvice(this.declaredPointcut);
this.pointcut = declaredPointcut;
this.pointcut = this.declaredPointcut;
this.lazy = false;
this.instantiatedAdvice = instantiateAdvice(this.declaredPointcut);
}
}
@@ -142,8 +157,8 @@ class InstantiationModelAwarePointcutAdvisorImpl
private Advice instantiateAdvice(AspectJExpressionPointcut pcut) {
return this.atAspectJAdvisorFactory.getAdvice(
this.method, pcut, this.aspectInstanceFactory, this.declarationOrder, this.aspectName);
return this.aspectJAdvisorFactory.getAdvice(this.aspectJAdviceMethod, pcut,
this.aspectInstanceFactory, this.declarationOrder, this.aspectName);
}
public MetadataAwareAspectInstanceFactory getAspectInstanceFactory() {
@@ -191,7 +206,7 @@ class InstantiationModelAwarePointcutAdvisorImpl
*/
private void determineAdviceType() {
AspectJAnnotation<?> aspectJAnnotation =
AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(this.method);
AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(this.aspectJAdviceMethod);
if (aspectJAnnotation == null) {
this.isBeforeAdvice = false;
this.isAfterAdvice = false;
@@ -220,11 +235,21 @@ class InstantiationModelAwarePointcutAdvisorImpl
@Override
public String toString() {
return "InstantiationModelAwarePointcutAdvisor: expression [" + getDeclaredPointcut().getExpression() +
"]; advice method [" + this.method + "]; perClauseKind=" +
"]; advice method [" + this.aspectJAdviceMethod + "]; perClauseKind=" +
this.aspectInstanceFactory.getAspectMetadata().getAjType().getPerClause().getKind();
}
private void readObject(ObjectInputStream inputStream) throws IOException, ClassNotFoundException {
inputStream.defaultReadObject();
try {
this.aspectJAdviceMethod = this.declaringClass.getMethod(this.methodName, this.parameterTypes);
}
catch (NoSuchMethodException ex) {
throw new IllegalStateException("Failed to find advice method on deserialization", ex);
}
}
/**
* Pointcut implementation that changes its behaviour when the advice is instantiated.
@@ -256,7 +281,7 @@ class InstantiationModelAwarePointcutAdvisorImpl
}
@Override
public boolean matches(Method method, Class<?> targetClass, Object[] args) {
public boolean matches(Method method, Class<?> targetClass, Object... args) {
// This can match only on declared pointcut.
return (isAspectMaterialized() && this.declaredPointcut.matches(method, targetClass));
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
package org.springframework.aop.aspectj.annotation;
import java.io.Serializable;
import org.springframework.util.Assert;
/**
@@ -25,7 +27,8 @@ import org.springframework.util.Assert;
* @author Juergen Hoeller
* @since 2.0
*/
public class LazySingletonAspectInstanceFactoryDecorator implements MetadataAwareAspectInstanceFactory {
@SuppressWarnings("serial")
public class LazySingletonAspectInstanceFactoryDecorator implements MetadataAwareAspectInstanceFactory, Serializable {
private final MetadataAwareAspectInstanceFactory maaif;
@@ -43,11 +46,17 @@ public class LazySingletonAspectInstanceFactoryDecorator implements MetadataAwar
@Override
public synchronized Object getAspectInstance() {
public Object getAspectInstance() {
if (this.materialized == null) {
synchronized (this) {
if (this.materialized == null) {
this.materialized = this.maaif.getAspectInstance();
Object mutex = this.maaif.getAspectCreationMutex();
if (mutex == null) {
this.materialized = this.maaif.getAspectInstance();
}
else {
synchronized (mutex) {
if (this.materialized == null) {
this.materialized = this.maaif.getAspectInstance();
}
}
}
}
@@ -68,6 +77,11 @@ public class LazySingletonAspectInstanceFactoryDecorator implements MetadataAwar
return this.maaif.getAspectMetadata();
}
@Override
public Object getAspectCreationMutex() {
return this.maaif.getAspectCreationMutex();
}
@Override
public int getOrder() {
return this.maaif.getOrder();
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,4 +39,11 @@ public interface MetadataAwareAspectInstanceFactory extends AspectInstanceFactor
*/
AspectMetadata getAspectMetadata();
/**
* Return the best possible creation mutex for this factory.
* @return the mutex object (may be {@code null} for no mutex to use)
* @since 4.3
*/
Object getAspectCreationMutex();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,11 +16,13 @@
package org.springframework.aop.aspectj.annotation;
import java.io.Serializable;
import org.springframework.beans.factory.BeanFactory;
/**
* AspectInstanceFactory backed by a BeanFactory-provided prototype,
* enforcing prototype semantics.
* {@link org.springframework.aop.aspectj.AspectInstanceFactory} backed by a
* {@link BeanFactory}-provided prototype, enforcing prototype semantics.
*
* <p>Note that this may instantiate multiple times, which probably won't give the
* semantics you expect. Use a {@link LazySingletonAspectInstanceFactoryDecorator}
@@ -32,7 +34,8 @@ import org.springframework.beans.factory.BeanFactory;
* @see org.springframework.beans.factory.BeanFactory
* @see LazySingletonAspectInstanceFactoryDecorator
*/
public class PrototypeAspectInstanceFactory extends BeanFactoryAspectInstanceFactory {
@SuppressWarnings("serial")
public class PrototypeAspectInstanceFactory extends BeanFactoryAspectInstanceFactory implements Serializable {
/**
* Create a PrototypeAspectInstanceFactory. AspectJ will be called to
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package org.springframework.aop.aspectj.annotation;
import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@@ -45,6 +46,7 @@ import org.springframework.aop.aspectj.AspectJMethodBeforeAdvice;
import org.springframework.aop.aspectj.DeclareParentsAdvisor;
import org.springframework.aop.framework.AopConfigException;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.converter.ConvertingComparator;
@@ -65,7 +67,8 @@ import org.springframework.util.comparator.InstanceComparator;
* @author Phillip Webb
* @since 2.0
*/
public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFactory {
@SuppressWarnings("serial")
public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFactory implements Serializable {
private static final Comparator<Method> METHOD_COMPARATOR;
@@ -77,8 +80,9 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
new Converter<Method, Annotation>() {
@Override
public Annotation convert(Method method) {
AspectJAnnotation<?> annotation = AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(method);
return annotation == null ? null : annotation.getAnnotation();
AspectJAnnotation<?> annotation =
AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(method);
return (annotation != null ? annotation.getAnnotation() : null);
}
}));
comparator.addComparator(new ConvertingComparator<Method, String>(
@@ -92,18 +96,42 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
}
private final BeanFactory beanFactory;
/**
* Create a new {@code ReflectiveAspectJAdvisorFactory}.
*/
public ReflectiveAspectJAdvisorFactory() {
this(null);
}
/**
* Create a new {@code ReflectiveAspectJAdvisorFactory}, propagating the given
* {@link BeanFactory} to the created {@link AspectJExpressionPointcut} instances,
* for bean pointcut handling as well as consistent {@link ClassLoader} resolution.
* @param beanFactory the BeanFactory to propagate (may be {@code null}}
* @since 4.3.6
* @see AspectJExpressionPointcut#setBeanFactory
* @see org.springframework.beans.factory.config.ConfigurableBeanFactory#getBeanClassLoader()
*/
public ReflectiveAspectJAdvisorFactory(BeanFactory beanFactory) {
this.beanFactory = beanFactory;
}
@Override
public List<Advisor> getAdvisors(MetadataAwareAspectInstanceFactory maaif) {
final Class<?> aspectClass = maaif.getAspectMetadata().getAspectClass();
final String aspectName = maaif.getAspectMetadata().getAspectName();
public List<Advisor> getAdvisors(MetadataAwareAspectInstanceFactory aspectInstanceFactory) {
Class<?> aspectClass = aspectInstanceFactory.getAspectMetadata().getAspectClass();
String aspectName = aspectInstanceFactory.getAspectMetadata().getAspectName();
validate(aspectClass);
// We need to wrap the MetadataAwareAspectInstanceFactory with a decorator
// so that it will only instantiate once.
final MetadataAwareAspectInstanceFactory lazySingletonAspectInstanceFactory =
new LazySingletonAspectInstanceFactoryDecorator(maaif);
MetadataAwareAspectInstanceFactory lazySingletonAspectInstanceFactory =
new LazySingletonAspectInstanceFactoryDecorator(aspectInstanceFactory);
final List<Advisor> advisors = new LinkedList<Advisor>();
List<Advisor> advisors = new LinkedList<Advisor>();
for (Method method : getAdvisorMethods(aspectClass)) {
Advisor advisor = getAdvisor(method, lazySingletonAspectInstanceFactory, advisors.size(), aspectName);
if (advisor != null) {
@@ -158,9 +186,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
}
if (DeclareParents.class == declareParents.defaultImpl()) {
// This is what comes back if it wasn't set. This seems bizarre...
// TODO this restriction possibly should be relaxed
throw new IllegalStateException("defaultImpl must be set on DeclareParents");
throw new IllegalStateException("'defaultImpl' attribute must be set on DeclareParents");
}
return new DeclareParentsAdvisor(
@@ -169,18 +195,19 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
@Override
public Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aif,
public Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aspectInstanceFactory,
int declarationOrderInAspect, String aspectName) {
validate(aif.getAspectMetadata().getAspectClass());
validate(aspectInstanceFactory.getAspectMetadata().getAspectClass());
AspectJExpressionPointcut ajexp =
getPointcut(candidateAdviceMethod, aif.getAspectMetadata().getAspectClass());
if (ajexp == null) {
AspectJExpressionPointcut expressionPointcut = getPointcut(
candidateAdviceMethod, aspectInstanceFactory.getAspectMetadata().getAspectClass());
if (expressionPointcut == null) {
return null;
}
return new InstantiationModelAwarePointcutAdvisorImpl(
this, ajexp, aif, candidateAdviceMethod, declarationOrderInAspect, aspectName);
return new InstantiationModelAwarePointcutAdvisorImpl(expressionPointcut, candidateAdviceMethod,
this, aspectInstanceFactory, declarationOrderInAspect, aspectName);
}
private AspectJExpressionPointcut getPointcut(Method candidateAdviceMethod, Class<?> candidateAspectClass) {
@@ -189,18 +216,20 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
if (aspectJAnnotation == null) {
return null;
}
AspectJExpressionPointcut ajexp =
new AspectJExpressionPointcut(candidateAspectClass, new String[0], new Class<?>[0]);
ajexp.setExpression(aspectJAnnotation.getPointcutExpression());
ajexp.setBeanFactory(this.beanFactory);
return ajexp;
}
@Override
public Advice getAdvice(Method candidateAdviceMethod, AspectJExpressionPointcut ajexp,
MetadataAwareAspectInstanceFactory aif, int declarationOrderInAspect, String aspectName) {
public Advice getAdvice(Method candidateAdviceMethod, AspectJExpressionPointcut expressionPointcut,
MetadataAwareAspectInstanceFactory aspectInstanceFactory, int declarationOrder, String aspectName) {
Class<?> candidateAspectClass = aif.getAspectMetadata().getAspectClass();
Class<?> candidateAspectClass = aspectInstanceFactory.getAspectMetadata().getAspectClass();
validate(candidateAspectClass);
AspectJAnnotation<?> aspectJAnnotation =
@@ -225,27 +254,32 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
switch (aspectJAnnotation.getAnnotationType()) {
case AtBefore:
springAdvice = new AspectJMethodBeforeAdvice(candidateAdviceMethod, ajexp, aif);
springAdvice = new AspectJMethodBeforeAdvice(
candidateAdviceMethod, expressionPointcut, aspectInstanceFactory);
break;
case AtAfter:
springAdvice = new AspectJAfterAdvice(candidateAdviceMethod, ajexp, aif);
springAdvice = new AspectJAfterAdvice(
candidateAdviceMethod, expressionPointcut, aspectInstanceFactory);
break;
case AtAfterReturning:
springAdvice = new AspectJAfterReturningAdvice(candidateAdviceMethod, ajexp, aif);
springAdvice = new AspectJAfterReturningAdvice(
candidateAdviceMethod, expressionPointcut, aspectInstanceFactory);
AfterReturning afterReturningAnnotation = (AfterReturning) aspectJAnnotation.getAnnotation();
if (StringUtils.hasText(afterReturningAnnotation.returning())) {
springAdvice.setReturningName(afterReturningAnnotation.returning());
}
break;
case AtAfterThrowing:
springAdvice = new AspectJAfterThrowingAdvice(candidateAdviceMethod, ajexp, aif);
springAdvice = new AspectJAfterThrowingAdvice(
candidateAdviceMethod, expressionPointcut, aspectInstanceFactory);
AfterThrowing afterThrowingAnnotation = (AfterThrowing) aspectJAnnotation.getAnnotation();
if (StringUtils.hasText(afterThrowingAnnotation.throwing())) {
springAdvice.setThrowingName(afterThrowingAnnotation.throwing());
}
break;
case AtAround:
springAdvice = new AspectJAroundAdvice(candidateAdviceMethod, ajexp, aif);
springAdvice = new AspectJAroundAdvice(
candidateAdviceMethod, expressionPointcut, aspectInstanceFactory);
break;
case AtPointcut:
if (logger.isDebugEnabled()) {
@@ -254,12 +288,12 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
return null;
default:
throw new UnsupportedOperationException(
"Unsupported advice type on method " + candidateAdviceMethod);
"Unsupported advice type on method: " + candidateAdviceMethod);
}
// Now to configure the advice...
springAdvice.setAspectName(aspectName);
springAdvice.setDeclarationOrder(declarationOrderInAspect);
springAdvice.setDeclarationOrder(declarationOrder);
String[] argNames = this.parameterNameDiscoverer.getParameterNames(candidateAdviceMethod);
if (argNames != null) {
springAdvice.setArgumentNamesFromStringArray(argNames);
@@ -268,6 +302,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
return springAdvice;
}
/**
* Synthetic advisor that instantiates the aspect.
* Triggered by per-clause pointcut on non-singleton aspect.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,6 +50,11 @@ public class SimpleMetadataAwareAspectInstanceFactory extends SimpleAspectInstan
return this.metadata;
}
@Override
public Object getAspectCreationMutex() {
return this;
}
@Override
protected int getOrderForAspectClass(Class<?> aspectClass) {
return OrderUtils.getOrder(aspectClass, Ordered.LOWEST_PRECEDENCE);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
package org.springframework.aop.aspectj.annotation;
import java.io.Serializable;
import org.springframework.aop.aspectj.SingletonAspectInstanceFactory;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.OrderUtils;
@@ -30,8 +32,9 @@ import org.springframework.core.annotation.OrderUtils;
* @since 2.0
* @see SimpleMetadataAwareAspectInstanceFactory
*/
@SuppressWarnings("serial")
public class SingletonMetadataAwareAspectInstanceFactory extends SingletonAspectInstanceFactory
implements MetadataAwareAspectInstanceFactory {
implements MetadataAwareAspectInstanceFactory, Serializable {
private final AspectMetadata metadata;
@@ -52,6 +55,11 @@ public class SingletonMetadataAwareAspectInstanceFactory extends SingletonAspect
return this.metadata;
}
@Override
public Object getAspectCreationMutex() {
return this;
}
@Override
protected int getOrderForAspectClass(Class<?> aspectClass) {
return OrderUtils.getOrder(aspectClass, Ordered.LOWEST_PRECEDENCE);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -71,7 +71,7 @@ public abstract class AbstractInterceptorDrivenBeanDefinitionDecorator implement
BeanDefinition interceptorDefinition = createInterceptorDefinition(node);
// generate name and register the interceptor
String interceptorName = existingBeanName + "." + getInterceptorNameSuffix(interceptorDefinition);
String interceptorName = existingBeanName + '.' + getInterceptorNameSuffix(interceptorDefinition);
BeanDefinitionReaderUtils.registerBeanDefinition(
new BeanDefinitionHolder(interceptorDefinition, interceptorName), registry);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -97,7 +97,7 @@ public abstract class AopConfigUtils {
}
}
static void forceAutoProxyCreatorToExposeProxy(BeanDefinitionRegistry registry) {
public static void forceAutoProxyCreatorToExposeProxy(BeanDefinitionRegistry registry) {
if (registry.containsBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME)) {
BeanDefinition definition = registry.getBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME);
definition.getPropertyValues().add("exposeProxy", Boolean.TRUE);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -113,7 +113,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
* Create a AdvisedSupport instance with the given parameters.
* @param interfaces the proxied interfaces
*/
public AdvisedSupport(Class<?>[] interfaces) {
public AdvisedSupport(Class<?>... interfaces) {
this();
setInterfaces(interfaces);
}
@@ -586,7 +586,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
* Simple wrapper class around a Method. Used as the key when
* caching methods, for efficient equals and hashCode comparisons.
*/
private static class MethodCacheKey {
private static final class MethodCacheKey implements Comparable<MethodCacheKey> {
private final Method method;
@@ -599,17 +599,28 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}
MethodCacheKey otherKey = (MethodCacheKey) other;
return (this.method == otherKey.method);
return (this == other || (other instanceof MethodCacheKey &&
this.method == ((MethodCacheKey) other).method));
}
@Override
public int hashCode() {
return this.hashCode;
}
@Override
public String toString() {
return this.method.toString();
}
@Override
public int compareTo(MethodCacheKey other) {
int result = this.method.getName().compareTo(other.method.getName());
if (result == 0) {
result = this.method.toString().compareTo(other.method.toString());
}
return result;
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@ import org.springframework.aop.TargetClassAware;
import org.springframework.aop.TargetSource;
import org.springframework.aop.support.AopUtils;
import org.springframework.aop.target.SingletonTargetSource;
import org.springframework.core.DecoratingProxy;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -42,6 +43,25 @@ import org.springframework.util.ObjectUtils;
*/
public abstract class AopProxyUtils {
/**
* Obtain the singleton target object behind the given proxy, if any.
* @param candidate the (potential) proxy to check
* @return the singleton target object managed in a {@link SingletonTargetSource},
* or {@code null} in any other case (not a proxy, not an existing singleton target)
* @since 4.3.8
* @see Advised#getTargetSource()
* @see SingletonTargetSource#getTarget()
*/
public static Object getSingletonTarget(Object candidate) {
if (candidate instanceof Advised) {
TargetSource targetSource = ((Advised) candidate).getTargetSource();
if (targetSource instanceof SingletonTargetSource) {
return ((SingletonTargetSource) targetSource).getTarget();
}
}
return null;
}
/**
* Determine the ultimate target class of the given bean instance, traversing
* not only a top-level proxy but any number of nested proxies as well &mdash;
@@ -58,14 +78,7 @@ public abstract class AopProxyUtils {
Class<?> result = null;
while (current instanceof TargetClassAware) {
result = ((TargetClassAware) current).getTargetClass();
Object nested = null;
if (current instanceof Advised) {
TargetSource targetSource = ((Advised) current).getTargetSource();
if (targetSource instanceof SingletonTargetSource) {
nested = ((SingletonTargetSource) targetSource).getTarget();
}
}
current = nested;
current = getSingletonTarget(current);
}
if (result == null) {
result = (AopUtils.isCglibProxy(candidate) ? candidate.getClass().getSuperclass() : candidate.getClass());
@@ -78,11 +91,29 @@ public abstract class AopProxyUtils {
* <p>This will always add the {@link Advised} interface unless the AdvisedSupport's
* {@link AdvisedSupport#setOpaque "opaque"} flag is on. Always adds the
* {@link org.springframework.aop.SpringProxy} marker interface.
* @param advised the proxy config
* @return the complete set of interfaces to proxy
* @see SpringProxy
* @see Advised
* @see org.springframework.aop.SpringProxy
*/
public static Class<?>[] completeProxiedInterfaces(AdvisedSupport advised) {
return completeProxiedInterfaces(advised, false);
}
/**
* Determine the complete set of interfaces to proxy for the given AOP configuration.
* <p>This will always add the {@link Advised} interface unless the AdvisedSupport's
* {@link AdvisedSupport#setOpaque "opaque"} flag is on. Always adds the
* {@link org.springframework.aop.SpringProxy} marker interface.
* @param advised the proxy config
* @param decoratingProxy whether to expose the {@link DecoratingProxy} interface
* @return the complete set of interfaces to proxy
* @since 4.3
* @see SpringProxy
* @see Advised
* @see DecoratingProxy
*/
static Class<?>[] completeProxiedInterfaces(AdvisedSupport advised, boolean decoratingProxy) {
Class<?>[] specifiedInterfaces = advised.getProxiedInterfaces();
if (specifiedInterfaces.length == 0) {
// No user-specified interfaces: check whether target class is an interface.
@@ -99,6 +130,7 @@ public abstract class AopProxyUtils {
}
boolean addSpringProxy = !advised.isInterfaceProxied(SpringProxy.class);
boolean addAdvised = !advised.isOpaque() && !advised.isInterfaceProxied(Advised.class);
boolean addDecoratingProxy = (decoratingProxy && !advised.isInterfaceProxied(DecoratingProxy.class));
int nonUserIfcCount = 0;
if (addSpringProxy) {
nonUserIfcCount++;
@@ -106,13 +138,22 @@ public abstract class AopProxyUtils {
if (addAdvised) {
nonUserIfcCount++;
}
if (addDecoratingProxy) {
nonUserIfcCount++;
}
Class<?>[] proxiedInterfaces = new Class<?>[specifiedInterfaces.length + nonUserIfcCount];
System.arraycopy(specifiedInterfaces, 0, proxiedInterfaces, 0, specifiedInterfaces.length);
int index = specifiedInterfaces.length;
if (addSpringProxy) {
proxiedInterfaces[specifiedInterfaces.length] = SpringProxy.class;
proxiedInterfaces[index] = SpringProxy.class;
index++;
}
if (addAdvised) {
proxiedInterfaces[proxiedInterfaces.length - 1] = Advised.class;
proxiedInterfaces[index] = Advised.class;
index++;
}
if (addDecoratingProxy) {
proxiedInterfaces[index] = DecoratingProxy.class;
}
return proxiedInterfaces;
}
@@ -134,6 +175,9 @@ public abstract class AopProxyUtils {
if (proxy instanceof Advised) {
nonUserIfcCount++;
}
if (proxy instanceof DecoratingProxy) {
nonUserIfcCount++;
}
Class<?>[] userInterfaces = new Class<?>[proxyInterfaces.length - nonUserIfcCount];
System.arraycopy(proxyInterfaces, 0, userInterfaces, 0, userInterfaces.length);
Assert.notEmpty(userInterfaces, "JDK proxy must implement one or more interfaces");
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ import java.lang.reflect.UndeclaredThrowableException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
import org.aopalliance.aop.Advice;
@@ -56,9 +57,6 @@ import org.springframework.util.ObjectUtils;
/**
* CGLIB-based {@link AopProxy} implementation for the Spring AOP framework.
*
* <p>Formerly named {@code Cglib2AopProxy}, as of Spring 3.2, this class depends on
* Spring's own internally repackaged version of CGLIB 3.</i>.
*
* <p>Objects of this type should be obtained through proxy factories,
* configured by an {@link AdvisedSupport} object. This class is internal
* to Spring's AOP framework and need not be used directly by client code.
@@ -214,7 +212,7 @@ class CglibAopProxy implements AopProxy, Serializable {
"Common causes of this problem include using a final class or a non-visible class",
ex);
}
catch (Exception ex) {
catch (Throwable ex) {
// TargetSource.getTarget() failed
throw new AopConfigException("Unexpected AOP exception", ex);
}
@@ -241,10 +239,11 @@ class CglibAopProxy implements AopProxy, Serializable {
* validates it if not.
*/
private void validateClassIfNecessary(Class<?> proxySuperClass, ClassLoader proxyClassLoader) {
if (logger.isInfoEnabled()) {
if (logger.isWarnEnabled()) {
synchronized (validatedClasses) {
if (!validatedClasses.containsKey(proxySuperClass)) {
doValidateClass(proxySuperClass, proxyClassLoader);
doValidateClass(proxySuperClass, proxyClassLoader,
ClassUtils.getAllInterfacesForClassAsSet(proxySuperClass));
validatedClasses.put(proxySuperClass, Boolean.TRUE);
}
}
@@ -255,30 +254,35 @@ class CglibAopProxy implements AopProxy, Serializable {
* Checks for final methods on the given {@code Class}, as well as package-visible
* methods across ClassLoaders, and writes warnings to the log for each one found.
*/
private void doValidateClass(Class<?> proxySuperClass, ClassLoader proxyClassLoader) {
if (Object.class != proxySuperClass) {
private void doValidateClass(Class<?> proxySuperClass, ClassLoader proxyClassLoader, Set<Class<?>> ifcs) {
if (proxySuperClass != Object.class) {
Method[] methods = proxySuperClass.getDeclaredMethods();
for (Method method : methods) {
int mod = method.getModifiers();
if (!Modifier.isStatic(mod)) {
if (Modifier.isFinal(mod)) {
logger.info("Unable to proxy method [" + method + "] because it is final: " +
"All calls to this method via a proxy will NOT be routed to the target instance.");
if (implementsInterface(method, ifcs)) {
logger.warn("Unable to proxy interface-implementing method [" + method + "] because " +
"it is marked as final: Consider using interface-based JDK proxies instead!");
}
logger.info("Final method [" + method + "] cannot get proxied via CGLIB: " +
"Calls to this method will NOT be routed to the target instance and " +
"might lead to NPEs against uninitialized fields in the proxy instance.");
}
else if (!Modifier.isPublic(mod) && !Modifier.isProtected(mod) && !Modifier.isPrivate(mod) &&
proxyClassLoader != null && proxySuperClass.getClassLoader() != proxyClassLoader) {
logger.info("Unable to proxy method [" + method + "] because it is package-visible " +
"across different ClassLoaders: All calls to this method via a proxy will " +
"NOT be routed to the target instance.");
logger.info("Method [" + method + "] is package-visible across different ClassLoaders " +
"and cannot get proxied via CGLIB: Declare this method as public or protected " +
"if you need to support invocations through the proxy.");
}
}
}
doValidateClass(proxySuperClass.getSuperclass(), proxyClassLoader);
doValidateClass(proxySuperClass.getSuperclass(), proxyClassLoader, ifcs);
}
}
private Callback[] getCallbacks(Class<?> rootClass) throws Exception {
// Parameters used for optimisation choices...
// Parameters used for optimization choices...
boolean exposeProxy = this.advised.isExposeProxy();
boolean isFrozen = this.advised.isFrozen();
boolean isStatic = this.advised.getTargetSource().isStatic();
@@ -317,14 +321,14 @@ class CglibAopProxy implements AopProxy, Serializable {
Callback[] callbacks;
// If the target is a static one and the advice chain is frozen,
// then we can make some optimisations by sending the AOP calls
// then we can make some optimizations by sending the AOP calls
// direct to the target using the fixed chain for that method.
if (isStatic && isFrozen) {
Method[] methods = rootClass.getMethods();
Callback[] fixedCallbacks = new Callback[methods.length];
this.fixedInterceptorMap = new HashMap<String, Integer>(methods.length);
// TODO: small memory optimisation here (can skip creation for methods with no advice)
// TODO: small memory optimization here (can skip creation for methods with no advice)
for (int x = 0; x < methods.length; x++) {
List<Object> chain = this.advised.getInterceptorsAndDynamicInterceptionAdvice(methods[x], rootClass);
fixedCallbacks[x] = new FixedChainStaticTargetInterceptor(
@@ -345,25 +349,6 @@ class CglibAopProxy implements AopProxy, Serializable {
return callbacks;
}
/**
* Process a return value. Wraps a return of {@code this} if necessary to be the
* {@code proxy} and also verifies that {@code null} is not returned as a primitive.
*/
private static Object processReturnType(Object proxy, Object target, Method method, Object retVal) {
// Massage return value if necessary
if (retVal != null && retVal == target && !RawTargetAccess.class.isAssignableFrom(method.getDeclaringClass())) {
// Special case: it returned "this". Note that we can't help
// if the target sets a reference to itself in another returned object.
retVal = proxy;
}
Class<?> returnType = method.getReturnType();
if (retVal == null && returnType != Void.TYPE && returnType.isPrimitive()) {
throw new AopInvocationException(
"Null return value from advice does not match primitive return type for: " + method);
}
return retVal;
}
@Override
public boolean equals(Object other) {
@@ -377,6 +362,39 @@ class CglibAopProxy implements AopProxy, Serializable {
}
/**
* Check whether the given method is declared on any of the given interfaces.
*/
private static boolean implementsInterface(Method method, Set<Class<?>> ifcs) {
for (Class<?> ifc : ifcs) {
if (ClassUtils.hasMethod(ifc, method.getName(), method.getParameterTypes())) {
return true;
}
}
return false;
}
/**
* Process a return value. Wraps a return of {@code this} if necessary to be the
* {@code proxy} and also verifies that {@code null} is not returned as a primitive.
*/
private static Object processReturnType(Object proxy, Object target, Method method, Object retVal) {
// Massage return value if necessary
if (retVal != null && retVal == target &&
!RawTargetAccess.class.isAssignableFrom(method.getDeclaringClass())) {
// Special case: it returned "this". Note that we can't help
// if the target sets a reference to itself in another returned object.
retVal = proxy;
}
Class<?> returnType = method.getReturnType();
if (retVal == null && returnType != Void.TYPE && returnType.isPrimitive()) {
throw new AopInvocationException(
"Null return value from advice does not match primitive return type for: " + method);
}
return retVal;
}
/**
* Serializable replacement for CGLIB's NoOp interface.
* Public to allow use elsewhere in the framework.
@@ -822,51 +840,42 @@ class CglibAopProxy implements AopProxy, Serializable {
// Else use the AOP_PROXY.
if (isStatic && isFrozen && this.fixedInterceptorMap.containsKey(key)) {
if (logger.isDebugEnabled()) {
logger.debug("Method has advice and optimisations are enabled: " + method);
logger.debug("Method has advice and optimizations are enabled: " + method);
}
// We know that we are optimising so we can use the FixedStaticChainInterceptors.
// We know that we are optimizing so we can use the FixedStaticChainInterceptors.
int index = this.fixedInterceptorMap.get(key);
return (index + this.fixedInterceptorOffset);
}
else {
if (logger.isDebugEnabled()) {
logger.debug("Unable to apply any optimisations to advised method: " + method);
logger.debug("Unable to apply any optimizations to advised method: " + method);
}
return AOP_PROXY;
}
}
else {
// See if the return type of the method is outside the class hierarchy
// of the target type. If so we know it never needs to have return type
// massage and can use a dispatcher.
// If the proxy is being exposed, then must use the interceptor the
// correct one is already configured. If the target is not static, then
// cannot use a dispatcher because the target cannot be released.
// See if the return type of the method is outside the class hierarchy of the target type.
// If so we know it never needs to have return type massage and can use a dispatcher.
// If the proxy is being exposed, then must use the interceptor the correct one is already
// configured. If the target is not static, then we cannot use a dispatcher because the
// target needs to be explicitly released after the invocation.
if (exposeProxy || !isStatic) {
return INVOKE_TARGET;
}
Class<?> returnType = method.getReturnType();
if (targetClass == returnType) {
if (returnType.isAssignableFrom(targetClass)) {
if (logger.isDebugEnabled()) {
logger.debug("Method " + method +
"has return type same as target type (may return this) - using INVOKE_TARGET");
logger.debug("Method return type is assignable from target type and " +
"may therefore return 'this' - using INVOKE_TARGET: " + method);
}
return INVOKE_TARGET;
}
else if (returnType.isPrimitive() || !returnType.isAssignableFrom(targetClass)) {
if (logger.isDebugEnabled()) {
logger.debug("Method " + method +
" has return type that ensures this cannot be returned- using DISPATCH_TARGET");
}
return DISPATCH_TARGET;
}
else {
if (logger.isDebugEnabled()) {
logger.debug("Method " + method +
"has return type that is assignable from the target type (may return this) - " +
"using INVOKE_TARGET");
logger.debug("Method return type ensures 'this' cannot be returned - " +
"using DISPATCH_TARGET: " + method);
}
return INVOKE_TARGET;
return DISPATCH_TARGET;
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ import org.springframework.aop.AopInvocationException;
import org.springframework.aop.RawTargetAccess;
import org.springframework.aop.TargetSource;
import org.springframework.aop.support.AopUtils;
import org.springframework.core.DecoratingProxy;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
@@ -116,7 +117,7 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa
if (logger.isDebugEnabled()) {
logger.debug("Creating JDK dynamic proxy: target source is " + this.advised.getTargetSource());
}
Class<?>[] proxiedInterfaces = AopProxyUtils.completeProxiedInterfaces(this.advised);
Class<?>[] proxiedInterfaces = AopProxyUtils.completeProxiedInterfaces(this.advised, true);
findDefinedEqualsAndHashCodeMethods(proxiedInterfaces);
return Proxy.newProxyInstance(classLoader, proxiedInterfaces, this);
}
@@ -164,11 +165,15 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa
// The target does not implement the equals(Object) method itself.
return equals(args[0]);
}
if (!this.hashCodeDefined && AopUtils.isHashCodeMethod(method)) {
else if (!this.hashCodeDefined && AopUtils.isHashCodeMethod(method)) {
// The target does not implement the hashCode() method itself.
return hashCode();
}
if (!this.advised.opaque && method.getDeclaringClass().isInterface() &&
else if (method.getDeclaringClass() == DecoratingProxy.class) {
// There is only getDecoratedClass() declared -> dispatch to proxy config.
return AopProxyUtils.ultimateTargetClass(this.advised);
}
else if (!this.advised.opaque && method.getDeclaringClass().isInterface() &&
method.getDeclaringClass().isAssignableFrom(Advised.class)) {
// Service invocations on ProxyConfig with the proxy config...
return AopUtils.invokeJoinpointUsingReflection(this.advised, method, args);
@@ -210,7 +215,8 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa
// Massage return value if necessary.
Class<?> returnType = method.getReturnType();
if (retVal != null && retVal == target && returnType.isInstance(proxy) &&
if (retVal != null && retVal == target &&
returnType != Object.class && returnType.isInstance(proxy) &&
!RawTargetAccess.class.isAssignableFrom(method.getDeclaringClass())) {
// Special case: it returned "this" and the return type of the method
// is type-compatible. Note that we can't help if the target sets
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,9 +22,9 @@ import org.springframework.aop.TargetSource;
import org.springframework.util.ClassUtils;
/**
* Factory for AOP proxies for programmatic use, rather than via a bean
* factory. This class provides a simple way of obtaining and configuring
* AOP proxies in code.
* Factory for AOP proxies for programmatic use, rather than via declarative
* setup in a bean factory. This class provides a simple way of obtaining
* and configuring AOP proxy instances in custom user code.
*
* @author Rod Johnson
* @author Juergen Hoeller
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -139,7 +139,8 @@ public class ProxyProcessorSupport extends ProxyConfig implements Ordered, BeanC
* @return whether the given interface is an internal language interface
*/
protected boolean isInternalLanguageInterface(Class<?> ifc) {
return ifc.getName().equals("groovy.lang.GroovyObject");
return (ifc.getName().equals("groovy.lang.GroovyObject") ||
ifc.getName().endsWith(".cglib.proxy.Factory"));
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ import org.springframework.aop.AfterReturningAdvice;
import org.springframework.util.Assert;
/**
* Interceptor to wrap am {@link org.springframework.aop.AfterReturningAdvice}.
* Interceptor to wrap an {@link org.springframework.aop.AfterReturningAdvice}.
* Used internally by the AOP framework; application developers should not need
* to use this class directly.
*
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,7 +54,8 @@ public abstract class AbstractAdvisorAutoProxyCreator extends AbstractAutoProxyC
public void setBeanFactory(BeanFactory beanFactory) {
super.setBeanFactory(beanFactory);
if (!(beanFactory instanceof ConfigurableListableBeanFactory)) {
throw new IllegalStateException("Cannot use AdvisorAutoProxyCreator without a ConfigurableListableBeanFactory");
throw new IllegalArgumentException(
"AdvisorAutoProxyCreator requires a ConfigurableListableBeanFactory: " + beanFactory);
}
initBeanFactory((ConfigurableListableBeanFactory) beanFactory);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.aop.Advisor;
import org.springframework.aop.Pointcut;
import org.springframework.aop.TargetSource;
import org.springframework.aop.framework.AopInfrastructureBean;
import org.springframework.aop.framework.ProxyFactory;
@@ -54,26 +55,25 @@ import org.springframework.util.StringUtils;
* before invoking the bean itself.
*
* <p>This class distinguishes between "common" interceptors: shared for all proxies it
* creates, and "specific" interceptors: unique per bean instance. There need not
* be any common interceptors. If there are, they are set using the interceptorNames
* property. As with ProxyFactoryBean, interceptors names in the current factory
* are used rather than bean references to allow correct handling of prototype
* advisors and interceptors: for example, to support stateful mixins.
* Any advice type is supported for "interceptorNames" entries.
* creates, and "specific" interceptors: unique per bean instance. There need not be any
* common interceptors. If there are, they are set using the interceptorNames property.
* As with {@link org.springframework.aop.framework.ProxyFactoryBean}, interceptors names
* in the current factory are used rather than bean references to allow correct handling
* of prototype advisors and interceptors: for example, to support stateful mixins.
* Any advice type is supported for {@link #setInterceptorNames "interceptorNames"} entries.
*
* <p>Such auto-proxying is particularly useful if there's a large number of beans that
* need to be wrapped with similar proxies, i.e. delegating to the same interceptors.
* Instead of x repetitive proxy definitions for x target beans, you can register
* one single such post processor with the bean factory to achieve the same effect.
*
* <p>Subclasses can apply any strategy to decide if a bean is to be proxied,
* e.g. by type, by name, by definition details, etc. They can also return
* additional interceptors that should just be applied to the specific bean
* instance. The default concrete implementation is BeanNameAutoProxyCreator,
* identifying the beans to be proxied via a list of bean names.
* <p>Subclasses can apply any strategy to decide if a bean is to be proxied, e.g. by type,
* by name, by definition details, etc. They can also return additional interceptors that
* should just be applied to the specific bean instance. A simple concrete implementation is
* {@link BeanNameAutoProxyCreator}, identifying the beans to be proxied via given names.
*
* <p>Any number of {@link TargetSourceCreator} implementations can be used to create
* a custom target source - for example, to pool prototype objects. Auto-proxying will
* a custom target source: for example, to pool prototype objects. Auto-proxying will
* occur even if there is no advice, as long as a TargetSourceCreator specifies a custom
* {@link org.springframework.aop.TargetSource}. If there are no TargetSourceCreators set,
* or if none matches, a {@link org.springframework.aop.target.SingletonTargetSource}
@@ -155,8 +155,8 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
}
/**
* Specify the AdvisorAdapterRegistry to use.
* Default is the global AdvisorAdapterRegistry.
* Specify the {@link AdvisorAdapterRegistry} to use.
* <p>Default is the global {@link AdvisorAdapterRegistry}.
* @see org.springframework.aop.framework.adapter.GlobalAdvisorAdapterRegistry
*/
public void setAdvisorAdapterRegistry(AdvisorAdapterRegistry advisorAdapterRegistry) {
@@ -164,18 +164,18 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
}
/**
* Set custom TargetSourceCreators to be applied in this order.
* If the list is empty, or they all return null, a SingletonTargetSource
* Set custom {@code TargetSourceCreators} to be applied in this order.
* If the list is empty, or they all return null, a {@link SingletonTargetSource}
* will be created for each bean.
* <p>Note that TargetSourceCreators will kick in even for target beans
* where no advices or advisors have been found. If a TargetSourceCreator
* returns a TargetSource for a specific bean, that bean will be proxied
* where no advices or advisors have been found. If a {@code TargetSourceCreator}
* returns a {@link TargetSource} for a specific bean, that bean will be proxied
* in any case.
* <p>TargetSourceCreators can only be invoked if this post processor is used
* in a BeanFactory, and its BeanFactoryAware callback is used.
* @param targetSourceCreators list of TargetSourceCreator.
* Ordering is significant: The TargetSource returned from the first matching
* TargetSourceCreator (that is, the first that returns non-null) will be used.
* <p>{@code TargetSourceCreators} can only be invoked if this post processor is used
* in a {@link BeanFactory} and its {@link BeanFactoryAware} callback is triggered.
* @param targetSourceCreators the list of {@code TargetSourceCreators}.
* Ordering is significant: The {@code TargetSource} returned from the first matching
* {@code TargetSourceCreator} (that is, the first that returns non-null) will be used.
*/
public void setCustomTargetSourceCreators(TargetSourceCreator... targetSourceCreators) {
this.customTargetSourceCreators = targetSourceCreators;
@@ -206,8 +206,8 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
}
/**
* Return the owning BeanFactory.
* May be {@code null}, as this object doesn't need to belong to a bean factory.
* Return the owning {@link BeanFactory}.
* May be {@code null}, as this post-processor doesn't need to belong to a bean factory.
*/
protected BeanFactory getBeanFactory() {
return this.beanFactory;
@@ -370,6 +370,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
*/
protected boolean isInfrastructureClass(Class<?> beanClass) {
boolean retVal = Advice.class.isAssignableFrom(beanClass) ||
Pointcut.class.isAssignableFrom(beanClass) ||
Advisor.class.isAssignableFrom(beanClass) ||
AopInfrastructureBean.class.isAssignableFrom(beanClass);
if (retVal && logger.isTraceEnabled()) {
@@ -35,7 +35,7 @@ public abstract class AutoProxyUtils {
* to be proxied with its target class (in case of it getting proxied in the first
* place). The value is {@code Boolean.TRUE} or {@code Boolean.FALSE}.
* <p>Proxy factories can set this attribute if they built a target class proxy
* for a specific bean, and want to enforce that that bean can always be cast
* for a specific bean, and want to enforce that bean can always be cast
* to its target class (even if AOP advices get applied through auto-proxying).
* @see #shouldProxyTargetClass
*/
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,15 +19,16 @@ package org.springframework.aop.framework.autoproxy;
import org.springframework.beans.factory.BeanNameAware;
/**
* BeanPostProcessor implementation that creates AOP proxies based on all candidate
* Advisors in the current BeanFactory. This class is completely generic; it contains
* no special code to handle any particular aspects, such as pooling aspects.
* {@code BeanPostProcessor} implementation that creates AOP proxies based on all
* candidate {@code Advisor}s in the current {@code BeanFactory}. This class is
* completely generic; it contains no special code to handle any particular aspects,
* such as pooling aspects.
*
* <p>It's possible to filter out advisors - for example, to use multiple post processors
* of this type in the same factory - by setting the {@code usePrefix} property
* to true, in which case only advisors beginning with the DefaultAdvisorAutoProxyCreator's
* bean name followed by a dot (like "aapc.") will be used. This default prefix can be
* changed from the bean name by setting the {@code advisorBeanNamePrefix} property.
* of this type in the same factory - by setting the {@code usePrefix} property to true,
* in which case only advisors beginning with the DefaultAdvisorAutoProxyCreator's bean
* name followed by a dot (like "aapc.") will be used. This default prefix can be changed
* from the bean name by setting the {@code advisorBeanNamePrefix} property.
* The separator (.) will also be used in this case.
*
* @author Rod Johnson
@@ -40,22 +41,22 @@ public class DefaultAdvisorAutoProxyCreator extends AbstractAdvisorAutoProxyCrea
public final static String SEPARATOR = ".";
private boolean usePrefix;
private boolean usePrefix = false;
private String advisorBeanNamePrefix;
/**
* Set whether to exclude advisors with a certain prefix
* in the bean name.
* Set whether to only include advisors with a certain prefix in the bean name.
* <p>Default is {@code false}, including all beans of type {@code Advisor}.
* @see #setAdvisorBeanNamePrefix
*/
public void setUsePrefix(boolean usePrefix) {
this.usePrefix = usePrefix;
}
/**
* Return whether to exclude advisors with a certain prefix
* in the bean name.
* Return whether to only include advisors with a certain prefix in the bean name.
*/
public boolean isUsePrefix() {
return this.usePrefix;
@@ -89,7 +90,7 @@ public class DefaultAdvisorAutoProxyCreator extends AbstractAdvisorAutoProxyCrea
/**
* Consider Advisor beans with the specified prefix as eligible, if activated.
* Consider {@code Advisor} beans with the specified prefix as eligible, if activated.
* @see #setUsePrefix
* @see #setAdvisorBeanNamePrefix
*/
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,9 +31,12 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.NoUniqueBeanDefinitionException;
import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils;
import org.springframework.core.task.AsyncListenableTaskExecutor;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.core.task.TaskExecutor;
import org.springframework.core.task.support.TaskExecutorAdapter;
import org.springframework.lang.UsesJava8;
import org.springframework.util.ClassUtils;
@@ -58,6 +61,15 @@ import org.springframework.util.concurrent.ListenableFuture;
*/
public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
/**
* The default name of the {@link TaskExecutor} bean to pick up: "taskExecutor".
* <p>Note that the initial lookup happens by type; this is just the fallback
* in case of multiple executor beans found in the context.
* @since 4.2.6
*/
public static final String DEFAULT_TASK_EXECUTOR_BEAN_NAME = "taskExecutor";
// Java 8's CompletableFuture type present?
private static final boolean completableFuturePresent = ClassUtils.isPresent(
"java.util.concurrent.CompletableFuture", AsyncExecutionInterceptor.class.getClassLoader());
@@ -67,7 +79,7 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
private final Map<Method, AsyncTaskExecutor> executors = new ConcurrentHashMap<Method, AsyncTaskExecutor>(16);
private Executor defaultExecutor;
private volatile Executor defaultExecutor;
private AsyncUncaughtExceptionHandler exceptionHandler;
@@ -75,10 +87,22 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
/**
* Create a new {@link AsyncExecutionAspectSupport}, using the provided default
* executor unless individual async methods indicate via qualifier that a more
* specific executor should be used.
* @param defaultExecutor the executor to use when executing asynchronous methods
* Create a new instance with a default {@link AsyncUncaughtExceptionHandler}.
* @param defaultExecutor the {@code Executor} (typically a Spring {@code AsyncTaskExecutor}
* or {@link java.util.concurrent.ExecutorService}) to delegate to, unless a more specific
* executor has been requested via a qualifier on the async method, in which case the
* executor will be looked up at invocation time against the enclosing bean factory
*/
public AsyncExecutionAspectSupport(Executor defaultExecutor) {
this(defaultExecutor, new SimpleAsyncUncaughtExceptionHandler());
}
/**
* Create a new {@link AsyncExecutionAspectSupport} with the given exception handler.
* @param defaultExecutor the {@code Executor} (typically a Spring {@code AsyncTaskExecutor}
* or {@link java.util.concurrent.ExecutorService}) to delegate to, unless a more specific
* executor has been requested via a qualifier on the async method, in which case the
* executor will be looked up at invocation time against the enclosing bean factory
* @param exceptionHandler the {@link AsyncUncaughtExceptionHandler} to use
*/
public AsyncExecutionAspectSupport(Executor defaultExecutor, AsyncUncaughtExceptionHandler exceptionHandler) {
@@ -86,23 +110,16 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
this.exceptionHandler = exceptionHandler;
}
/**
* Create a new instance with a default {@link AsyncUncaughtExceptionHandler}.
*/
public AsyncExecutionAspectSupport(Executor defaultExecutor) {
this(defaultExecutor, new SimpleAsyncUncaughtExceptionHandler());
}
/**
* Supply the executor to be used when executing async methods.
* @param defaultExecutor the {@code Executor} (typically a Spring {@code
* AsyncTaskExecutor} or {@link java.util.concurrent.ExecutorService}) to delegate to
* unless a more specific executor has been requested via a qualifier on the async
* method, in which case the executor will be looked up at invocation time against the
* enclosing bean factory.
* @see #getExecutorQualifier
* @param defaultExecutor the {@code Executor} (typically a Spring {@code AsyncTaskExecutor}
* or {@link java.util.concurrent.ExecutorService}) to delegate to, unless a more specific
* executor has been requested via a qualifier on the async method, in which case the
* executor will be looked up at invocation time against the enclosing bean factory
* @see #getExecutorQualifier(Method)
* @see #setBeanFactory(BeanFactory)
* @see #getDefaultExecutor(BeanFactory)
*/
public void setExecutor(Executor defaultExecutor) {
this.defaultExecutor = defaultExecutor;
@@ -117,7 +134,10 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
}
/**
* Set the {@link BeanFactory} to be used when looking up executors by qualifier.
* Set the {@link BeanFactory} to be used when looking up executors by qualifier
* or when relying on the default executor lookup algorithm.
* @see #findQualifiedExecutor(BeanFactory, String)
* @see #getDefaultExecutor(BeanFactory)
*/
@Override
public void setBeanFactory(BeanFactory beanFactory) {
@@ -128,26 +148,32 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
/**
* Determine the specific executor to use when executing the given method.
* Should preferably return an {@link AsyncListenableTaskExecutor} implementation.
* @return the executor to use (or {@code null}, but just if no default executor has been set)
* @return the executor to use (or {@code null}, but just if no default executor is available)
*/
protected AsyncTaskExecutor determineAsyncExecutor(Method method) {
AsyncTaskExecutor executor = this.executors.get(method);
if (executor == null) {
Executor executorToUse = this.defaultExecutor;
Executor targetExecutor;
String qualifier = getExecutorQualifier(method);
if (StringUtils.hasLength(qualifier)) {
if (this.beanFactory == null) {
throw new IllegalStateException("BeanFactory must be set on " + getClass().getSimpleName() +
" to access qualified executor '" + qualifier + "'");
}
executorToUse = BeanFactoryAnnotationUtils.qualifiedBeanOfType(
this.beanFactory, Executor.class, qualifier);
targetExecutor = findQualifiedExecutor(this.beanFactory, qualifier);
}
else if (executorToUse == null) {
else {
targetExecutor = this.defaultExecutor;
if (targetExecutor == null) {
synchronized (this.executors) {
if (this.defaultExecutor == null) {
this.defaultExecutor = getDefaultExecutor(this.beanFactory);
}
targetExecutor = this.defaultExecutor;
}
}
}
if (targetExecutor == null) {
return null;
}
executor = (executorToUse instanceof AsyncListenableTaskExecutor ?
(AsyncListenableTaskExecutor) executorToUse : new TaskExecutorAdapter(executorToUse));
executor = (targetExecutor instanceof AsyncListenableTaskExecutor ?
(AsyncListenableTaskExecutor) targetExecutor : new TaskExecutorAdapter(targetExecutor));
this.executors.put(method, executor);
}
return executor;
@@ -160,11 +186,69 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
* been specified and that the {@linkplain #setExecutor(Executor) default executor}
* should be used.
* @param method the method to inspect for executor qualifier metadata
* @return the qualifier if specified, otherwise empty string or {@code null}
* @return the qualifier if specified, otherwise empty String or {@code null}
* @see #determineAsyncExecutor(Method)
* @see #findQualifiedExecutor(BeanFactory, String)
*/
protected abstract String getExecutorQualifier(Method method);
/**
* Retrieve a target executor for the given qualifier.
* @param qualifier the qualifier to resolve
* @return the target executor, or {@code null} if none available
* @since 4.2.6
* @see #getExecutorQualifier(Method)
*/
protected Executor findQualifiedExecutor(BeanFactory beanFactory, String qualifier) {
if (beanFactory == null) {
throw new IllegalStateException("BeanFactory must be set on " + getClass().getSimpleName() +
" to access qualified executor '" + qualifier + "'");
}
return BeanFactoryAnnotationUtils.qualifiedBeanOfType(beanFactory, Executor.class, qualifier);
}
/**
* Retrieve or build a default executor for this advice instance.
* An executor returned from here will be cached for further use.
* <p>The default implementation searches for a unique {@link TaskExecutor} bean
* in the context, or for an {@link Executor} bean named "taskExecutor" otherwise.
* If neither of the two is resolvable, this implementation will return {@code null}.
* @param beanFactory the BeanFactory to use for a default executor lookup
* @return the default executor, or {@code null} if none available
* @since 4.2.6
* @see #findQualifiedExecutor(BeanFactory, String)
* @see #DEFAULT_TASK_EXECUTOR_BEAN_NAME
*/
protected Executor getDefaultExecutor(BeanFactory beanFactory) {
if (beanFactory != null) {
try {
// Search for TaskExecutor bean... not plain Executor since that would
// match with ScheduledExecutorService as well, which is unusable for
// our purposes here. TaskExecutor is more clearly designed for it.
return beanFactory.getBean(TaskExecutor.class);
}
catch (NoUniqueBeanDefinitionException ex) {
try {
return beanFactory.getBean(DEFAULT_TASK_EXECUTOR_BEAN_NAME, Executor.class);
}
catch (NoSuchBeanDefinitionException ex2) {
if (logger.isInfoEnabled()) {
logger.info("More than one TaskExecutor bean found within the context, and none is named " +
"'taskExecutor'. Mark one of them as primary or name it 'taskExecutor' (possibly " +
"as an alias) in order to use it for async processing: " + ex.getBeanNamesFound());
}
}
}
catch (NoSuchBeanDefinitionException ex) {
logger.debug("Could not find default TaskExecutor bean", ex);
// Giving up -> either using local default executor or none at all...
logger.info("No TaskExecutor bean found for async processing");
}
}
return null;
}
/**
* Delegate for actually executing the given task with the chosen executor.
* @param task the task to execute
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,9 +26,11 @@ import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.core.BridgeMethodResolver;
import org.springframework.core.Ordered;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.util.ClassUtils;
/**
@@ -65,22 +67,27 @@ import org.springframework.util.ClassUtils;
*/
public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport implements MethodInterceptor, Ordered {
/**
* Create a new instance with a default {@link AsyncUncaughtExceptionHandler}.
* @param defaultExecutor the {@link Executor} (typically a Spring {@link AsyncTaskExecutor}
* or {@link java.util.concurrent.ExecutorService}) to delegate to;
* as of 4.2.6, a local executor for this interceptor will be built otherwise
*/
public AsyncExecutionInterceptor(Executor defaultExecutor) {
super(defaultExecutor);
}
/**
* Create a new {@code AsyncExecutionInterceptor}.
* @param defaultExecutor the {@link Executor} (typically a Spring {@link AsyncTaskExecutor}
* or {@link java.util.concurrent.ExecutorService}) to delegate to
* or {@link java.util.concurrent.ExecutorService}) to delegate to;
* as of 4.2.6, a local executor for this interceptor will be built otherwise
* @param exceptionHandler the {@link AsyncUncaughtExceptionHandler} to use
*/
public AsyncExecutionInterceptor(Executor defaultExecutor, AsyncUncaughtExceptionHandler exceptionHandler) {
super(defaultExecutor, exceptionHandler);
}
/**
* Create a new instance with a default {@link AsyncUncaughtExceptionHandler}.
*/
public AsyncExecutionInterceptor(Executor defaultExecutor) {
super(defaultExecutor);
}
/**
* Intercept the given method invocation, submit the actual calling of the method to
@@ -136,6 +143,20 @@ public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport imple
return null;
}
/**
* This implementation searches for a unique {@link org.springframework.core.task.TaskExecutor}
* bean in the context, or for an {@link Executor} bean named "taskExecutor" otherwise.
* If neither of the two is resolvable (e.g. if no {@code BeanFactory} was configured at all),
* this implementation falls back to a newly created {@link SimpleAsyncTaskExecutor} instance
* for local use if no default could be found.
* @see #DEFAULT_TASK_EXECUTOR_BEAN_NAME
*/
@Override
protected Executor getDefaultExecutor(BeanFactory beanFactory) {
Executor defaultExecutor = super.getDefaultExecutor(beanFactory);
return (defaultExecutor != null ? defaultExecutor : new SimpleAsyncTaskExecutor());
}
@Override
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE;
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -246,7 +246,7 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor {
*/
@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
String name = invocation.getMethod().getDeclaringClass().getName() + "." + invocation.getMethod().getName();
String name = ClassUtils.getQualifiedMethodName(invocation.getMethod());
StopWatch stopWatch = new StopWatch(name);
Object returnValue = null;
boolean exitThroughException = false;
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ import org.aopalliance.aop.Advice;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.util.Assert;
/**
@@ -45,7 +46,7 @@ public abstract class AbstractBeanFactoryPointcutAdvisor extends AbstractPointcu
private BeanFactory beanFactory;
private transient Advice advice;
private transient volatile Advice advice;
private transient volatile Object adviceMonitor = new Object();
@@ -72,8 +73,23 @@ public abstract class AbstractBeanFactoryPointcutAdvisor extends AbstractPointcu
@Override
public void setBeanFactory(BeanFactory beanFactory) {
this.beanFactory = beanFactory;
resetAdviceMonitor();
}
private void resetAdviceMonitor() {
if (this.beanFactory instanceof ConfigurableBeanFactory) {
this.adviceMonitor = ((ConfigurableBeanFactory) this.beanFactory).getSingletonMutex();
}
else {
this.adviceMonitor = new Object();
}
}
/**
* Specify a particular instance of the target advice directly,
* avoiding lazy resolution in {@link #getAdvice()}.
* @since 3.1
*/
public void setAdvice(Advice advice) {
synchronized (this.adviceMonitor) {
this.advice = advice;
@@ -82,18 +98,42 @@ public abstract class AbstractBeanFactoryPointcutAdvisor extends AbstractPointcu
@Override
public Advice getAdvice() {
synchronized (this.adviceMonitor) {
if (this.advice == null && this.adviceBeanName != null) {
Assert.state(this.beanFactory != null, "BeanFactory must be set to resolve 'adviceBeanName'");
this.advice = this.beanFactory.getBean(this.adviceBeanName, Advice.class);
Advice advice = this.advice;
if (advice != null || this.adviceBeanName == null) {
return advice;
}
Assert.state(this.beanFactory != null, "BeanFactory must be set to resolve 'adviceBeanName'");
if (this.beanFactory.isSingleton(this.adviceBeanName)) {
// Rely on singleton semantics provided by the factory.
advice = this.beanFactory.getBean(this.adviceBeanName, Advice.class);
this.advice = advice;
return advice;
}
else {
// No singleton guarantees from the factory -> let's lock locally but
// reuse the factory's singleton lock, just in case a lazy dependency
// of our advice bean happens to trigger the singleton lock implicitly...
synchronized (this.adviceMonitor) {
if (this.advice == null) {
this.advice = this.beanFactory.getBean(this.adviceBeanName, Advice.class);
}
return this.advice;
}
return this.advice;
}
}
@Override
public String toString() {
return getClass().getName() + ": advice bean '" + getAdviceBeanName() + "'";
StringBuilder sb = new StringBuilder(getClass().getName());
sb.append(": advice ");
if (this.adviceBeanName != null) {
sb.append("bean '").append(this.adviceBeanName).append("'");
}
else {
sb.append(this.advice);
}
return sb.toString();
}
@@ -106,7 +146,7 @@ public abstract class AbstractBeanFactoryPointcutAdvisor extends AbstractPointcu
ois.defaultReadObject();
// Initialize transient fields.
this.adviceMonitor = new Object();
resetAdviceMonitor();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@ import java.lang.reflect.Method;
import java.util.Arrays;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
@@ -129,8 +130,8 @@ public abstract class AbstractRegexpMethodPointcut extends StaticMethodMatcherPo
*/
@Override
public boolean matches(Method method, Class<?> targetClass) {
return ((targetClass != null && matchesPattern(targetClass.getName() + "." + method.getName())) ||
matchesPattern(method.getDeclaringClass().getName() + "." + method.getName()));
return ((targetClass != null && matchesPattern(ClassUtils.getQualifiedMethodName(method, targetClass))) ||
matchesPattern(ClassUtils.getQualifiedMethodName(method)));
}
/**
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@ package org.springframework.aop.support;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Proxy;
import java.util.LinkedHashSet;
import java.util.LinkedList;
@@ -34,6 +35,7 @@ import org.springframework.aop.PointcutAdvisor;
import org.springframework.aop.SpringProxy;
import org.springframework.aop.TargetClassAware;
import org.springframework.core.BridgeMethodResolver;
import org.springframework.core.MethodIntrospector;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;
@@ -112,6 +114,30 @@ public abstract class AopUtils {
return result;
}
/**
* Select an invocable method on the target type: either the given method itself
* if actually exposed on the target type, or otherwise a corresponding method
* on one of the target type's interfaces or on the target type itself.
* @param method the method to check
* @param targetType the target type to search methods on (typically an AOP proxy)
* @return a corresponding invocable method on the target type
* @throws IllegalStateException if the given method is not invocable on the given
* target type (typically due to a proxy mismatch)
* @since 4.3
* @see MethodIntrospector#selectInvocableMethod(Method, Class)
*/
public static Method selectInvocableMethod(Method method, Class<?> targetType) {
Method methodToUse = MethodIntrospector.selectInvocableMethod(method, targetType);
if (Modifier.isPrivate(methodToUse.getModifiers()) && !Modifier.isStatic(methodToUse.getModifiers()) &&
SpringProxy.class.isAssignableFrom(targetType)) {
throw new IllegalStateException(String.format(
"Need to invoke method '%s' found on proxy for target class '%s' but cannot " +
"be delegated to target bean. Switch its visibility to package or protected.",
method.getName(), method.getDeclaringClass().getSimpleName()));
}
return methodToUse;
}
/**
* Determine whether the given method is an "equals" method.
* @see java.lang.Object#equals
@@ -196,6 +222,11 @@ public abstract class AopUtils {
}
MethodMatcher methodMatcher = pc.getMethodMatcher();
if (methodMatcher == MethodMatcher.TRUE) {
// No need to iterate the methods if we're matching any method anyway...
return true;
}
IntroductionAwareMethodMatcher introductionAwareMethodMatcher = null;
if (methodMatcher instanceof IntroductionAwareMethodMatcher) {
introductionAwareMethodMatcher = (IntroductionAwareMethodMatcher) methodMatcher;
@@ -204,7 +235,7 @@ public abstract class AopUtils {
Set<Class<?>> classes = new LinkedHashSet<Class<?>>(ClassUtils.getAllInterfacesForClassAsSet(targetClass));
classes.add(targetClass);
for (Class<?> clazz : classes) {
Method[] methods = clazz.getMethods();
Method[] methods = ReflectionUtils.getAllDeclaredMethods(clazz);
for (Method method : methods) {
if ((introductionAwareMethodMatcher != null &&
introductionAwareMethodMatcher.matches(method, targetClass, hasIntroductions)) ||
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,8 +22,6 @@ import java.lang.reflect.Method;
import org.springframework.aop.ClassFilter;
import org.springframework.aop.MethodMatcher;
import org.springframework.aop.Pointcut;
import org.springframework.core.ControlFlow;
import org.springframework.core.ControlFlowFactory;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -34,7 +32,7 @@ import org.springframework.util.ObjectUtils;
*
* @author Rod Johnson
* @author Rob Harrop
* @see org.springframework.core.ControlFlow
* @author Juergen Hoeller
*/
@SuppressWarnings("serial")
public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher, Serializable {
@@ -43,7 +41,7 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
private String methodName;
private int evaluations;
private volatile int evaluations;
/**
@@ -55,11 +53,11 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
}
/**
* Construct a new pointcut that matches all calls below the
* given method in the given class. If the method name is null,
* matches all control flows below that class.
* Construct a new pointcut that matches all calls below the given method
* in the given class. If no method name is given, matches all control flows
* below the given class.
* @param clazz the clazz
* @param methodName the name of the method
* @param methodName the name of the method (may be {@code null})
*/
public ControlFlowPointcut(Class<?> clazz, String methodName) {
Assert.notNull(clazz, "Class must not be null");
@@ -91,17 +89,23 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
}
@Override
public boolean matches(Method method, Class<?> targetClass, Object[] args) {
++this.evaluations;
ControlFlow cflow = ControlFlowFactory.createControlFlow();
return (this.methodName != null) ? cflow.under(this.clazz, this.methodName) : cflow.under(this.clazz);
public boolean matches(Method method, Class<?> targetClass, Object... args) {
this.evaluations++;
for (StackTraceElement element : new Throwable().getStackTrace()) {
if (element.getClassName().equals(this.clazz.getName()) &&
(this.methodName == null || element.getMethodName().equals(this.methodName))) {
return true;
}
}
return false;
}
/**
* It's useful to know how many times we've fired, for optimization.
*/
public int getEvaluations() {
return evaluations;
return this.evaluations;
}
@@ -115,6 +119,7 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
return this;
}
@Override
public boolean equals(Object other) {
if (this == other) {
@@ -129,8 +134,7 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
@Override
public int hashCode() {
int code = 17;
code = 37 * code + this.clazz.hashCode();
int code = this.clazz.hashCode();
if (this.methodName != null) {
code = 37 * code + this.methodName.hashCode();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -138,7 +138,7 @@ public abstract class MethodMatchers {
}
@Override
public boolean matches(Method method, Class<?> targetClass, Object[] args) {
public boolean matches(Method method, Class<?> targetClass, Object... args) {
return this.mm1.matches(method, targetClass, args) || this.mm2.matches(method, targetClass, args);
}
@@ -245,7 +245,7 @@ public abstract class MethodMatchers {
}
@Override
public boolean matches(Method method, Class<?> targetClass, Object[] args) {
public boolean matches(Method method, Class<?> targetClass, Object... args) {
// Because a dynamic intersection may be composed of a static and dynamic part,
// we must avoid calling the 3-arg matches method on a dynamic matcher, as
// it will probably be an unsupported operation.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -71,7 +71,7 @@ public abstract class Pointcuts {
* @param args arguments to the method
* @return whether there's a runtime match
*/
public static boolean matches(Pointcut pointcut, Method method, Class<?> targetClass, Object[] args) {
public static boolean matches(Pointcut pointcut, Method method, Class<?> targetClass, Object... args) {
Assert.notNull(pointcut, "Pointcut must not be null");
if (pointcut == Pointcut.TRUE) {
return true;
@@ -98,9 +98,9 @@ public abstract class Pointcuts {
@Override
public boolean matches(Method method, Class<?> targetClass) {
return method.getName().startsWith("set") &&
method.getParameterTypes().length == 1 &&
method.getReturnType() == Void.TYPE;
return (method.getName().startsWith("set") &&
method.getParameterTypes().length == 1 &&
method.getReturnType() == Void.TYPE);
}
private Object readResolve() {
@@ -119,8 +119,8 @@ public abstract class Pointcuts {
@Override
public boolean matches(Method method, Class<?> targetClass) {
return method.getName().startsWith("get") &&
method.getParameterTypes().length == 0;
return (method.getName().startsWith("get") &&
method.getParameterTypes().length == 0);
}
private Object readResolve() {
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,7 +32,7 @@ public abstract class StaticMethodMatcher implements MethodMatcher {
}
@Override
public final boolean matches(Method method, Class<?> targetClass, Object[] args) {
public final boolean matches(Method method, Class<?> targetClass, Object... args) {
// should never be invoked because isRuntime() returns false
throw new UnsupportedOperationException("Illegal MethodMatcher usage");
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,7 +39,7 @@ import org.springframework.aop.TargetSource;
public abstract class AbstractRefreshableTargetSource implements TargetSource, Refreshable {
/** Logger available to subclasses */
protected Log logger = LogFactory.getLog(getClass());
protected final Log logger = LogFactory.getLog(getClass());
protected Object targetObject;
@@ -6,4 +6,5 @@ http\://www.springframework.org/schema/aop/spring-aop-3.2.xsd=org/springframewor
http\://www.springframework.org/schema/aop/spring-aop-4.0.xsd=org/springframework/aop/config/spring-aop-4.0.xsd
http\://www.springframework.org/schema/aop/spring-aop-4.1.xsd=org/springframework/aop/config/spring-aop-4.1.xsd
http\://www.springframework.org/schema/aop/spring-aop-4.2.xsd=org/springframework/aop/config/spring-aop-4.2.xsd
http\://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-4.2.xsd
http\://www.springframework.org/schema/aop/spring-aop-4.3.xsd=org/springframework/aop/config/spring-aop-4.3.xsd
http\://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-4.3.xsd
@@ -0,0 +1,409 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsd:schema xmlns="http://www.springframework.org/schema/aop"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tool="http://www.springframework.org/schema/tool"
targetNamespace="http://www.springframework.org/schema/aop"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:import namespace="http://www.springframework.org/schema/beans" schemaLocation="http://www.springframework.org/schema/beans/spring-beans-4.3.xsd"/>
<xsd:import namespace="http://www.springframework.org/schema/tool" schemaLocation="http://www.springframework.org/schema/tool/spring-tool-4.3.xsd"/>
<xsd:annotation>
<xsd:documentation><![CDATA[
Defines the configuration elements for the Spring Framework's AOP support.
]]></xsd:documentation>
</xsd:annotation>
<xsd:element name="config">
<xsd:annotation>
<xsd:documentation><![CDATA[
A section (compartmentalization) of AOP-specific configuration (including
aspects, pointcuts, etc).
]]></xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="pointcut" type="pointcutType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation><![CDATA[
A named pointcut definition.
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="advisor" type="advisorType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation source="java:org.springframework.aop.Advisor"><![CDATA[
A named advisor definition.
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="aspect" type="aspectType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation><![CDATA[
A named aspect definition.
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="proxy-target-class" type="xsd:boolean" default="false">
<xsd:annotation>
<xsd:documentation><![CDATA[
Are class-based (CGLIB) proxies to be created? By default, standard
Java interface-based proxies are created.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="expose-proxy" type="xsd:boolean" default="false">
<xsd:annotation>
<xsd:documentation><![CDATA[
Indicate that the proxy should be exposed by the AOP framework as a
ThreadLocal for retrieval via the AopContext class. Off by default,
i.e. no guarantees that AopContext access will work.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:element name="aspectj-autoproxy">
<xsd:annotation>
<xsd:documentation source="java:org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator"><![CDATA[
Enables the use of the @AspectJ style of Spring AOP.
See org.springframework.context.annotation.EnableAspectJAutoProxy Javadoc
for information on code-based alternatives to this XML element.
]]></xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="include" type="includeType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation><![CDATA[
Indicates that only @AspectJ beans with names matched by the (regex)
pattern will be considered as defining aspects to use for Spring autoproxying.
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="proxy-target-class" type="xsd:boolean" default="false">
<xsd:annotation>
<xsd:documentation><![CDATA[
Are class-based (CGLIB) proxies to be created? By default, standard
Java interface-based proxies are created.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="expose-proxy" type="xsd:boolean" default="false">
<xsd:annotation>
<xsd:documentation><![CDATA[
Indicate that the proxy should be exposed by the AOP framework as a
ThreadLocal for retrieval via the AopContext class. Off by default,
i.e. no guarantees that AopContext access will work.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:element name="scoped-proxy">
<xsd:complexType>
<xsd:annotation>
<xsd:documentation source="java:org.springframework.aop.scope.ScopedProxyFactoryBean"><![CDATA[
Marks a bean definition as being a scoped proxy.
A bean marked as such will be exposed via a proxy, with the 'real'
bean instance being retrieved from some other source (such as a
HttpSession) as and when required.
]]></xsd:documentation>
</xsd:annotation>
<xsd:attribute name="proxy-target-class" type="xsd:boolean" default="true">
<xsd:annotation>
<xsd:documentation><![CDATA[
Are class-based (CGLIB) proxies to be created? This is the default; in order to
switch to standard Java interface-based proxies, turn this flag to "false".
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="aspectType">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="pointcut" type="pointcutType">
<xsd:annotation>
<xsd:documentation><![CDATA[
A named pointcut definition.
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="declare-parents" type="declareParentsType">
<xsd:annotation>
<xsd:documentation><![CDATA[
Allows this aspect to introduce additional interfaces that the advised
object will transparently implement.
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="before" type="basicAdviceType">
<xsd:annotation>
<xsd:documentation><![CDATA[
A before advice definition.
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="after" type="basicAdviceType">
<xsd:annotation>
<xsd:documentation><![CDATA[
An after advice definition.
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="after-returning" type="afterReturningAdviceType">
<xsd:annotation>
<xsd:documentation><![CDATA[
An after-returning advice definition.
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="after-throwing" type="afterThrowingAdviceType">
<xsd:annotation>
<xsd:documentation><![CDATA[
An after-throwing advice definition.
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="around" type="basicAdviceType">
<xsd:annotation>
<xsd:documentation><![CDATA[
An around advice definition.
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:choice>
<xsd:attribute name="id" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The unique identifier for an aspect.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="ref" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The name of the (backing) bean that encapsulates the aspect.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="order" type="xsd:token">
<xsd:annotation>
<xsd:documentation source="java:org.springframework.core.Ordered"><![CDATA[
Controls the ordering of the execution of this aspect when multiple
advice executes at a specific joinpoint.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<xsd:complexType name="includeType">
<xsd:attribute name="name" type="xsd:string">
<xsd:annotation>
<xsd:documentation source="java:java.util.regex.Pattern"><![CDATA[
The regular expression defining which beans are to be included in the
list of @AspectJ beans; beans with names matched by the pattern will
be included.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<xsd:complexType name="pointcutType">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation>
<tool:exports type="org.springframework.aop.Pointcut"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:attribute name="id" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation><![CDATA[
The unique identifier for a pointcut.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="expression" use="required" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The pointcut expression.
For example : 'execution(* com.xyz.myapp.service.*.*(..))'
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<xsd:complexType name="declareParentsType">
<xsd:attribute name="types-matching" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation source="java:org.springframework.aop.aspectj.TypePatternClassFilter"><![CDATA[
The AspectJ type expression that defines what types (classes) the
introduction is restricted to.
An example would be 'org.springframework.beans.ITestBean+'.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="implement-interface" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation source="java:java.lang.Class"><![CDATA[
The fully qualified name of the interface that will be introduced.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="default-impl" type="xsd:string">
<xsd:annotation>
<xsd:documentation source="java:java.lang.Class"><![CDATA[
The fully qualified name of the class that will be instantiated to serve
as the default implementation of the introduced interface.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="delegate-ref" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
A reference to the bean that will serve
as the default implementation of the introduced interface.
]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<xsd:complexType name="basicAdviceType">
<xsd:attribute name="pointcut" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The associated pointcut expression.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="pointcut-ref" type="pointcutRefType">
<xsd:annotation>
<xsd:documentation><![CDATA[
The name of an associated pointcut definition.
]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.aop.Pointcut"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="method" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation><![CDATA[
The name of the method that defines the logic of the advice.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="arg-names" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The comma-delimited list of advice method argument (parameter) names
that will be matched from pointcut parameters.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<xsd:complexType name="afterReturningAdviceType">
<xsd:complexContent>
<xsd:extension base="basicAdviceType">
<xsd:attribute name="returning" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The name of the method parameter to which the return value must
be passed.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="afterThrowingAdviceType">
<xsd:complexContent>
<xsd:extension base="basicAdviceType">
<xsd:attribute name="throwing" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The name of the method parameter to which the thrown exception must
be passed.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="advisorType">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation>
<tool:exports type="org.springframework.aop.Advisor"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:attribute name="id" type="xsd:string"/>
<xsd:attribute name="advice-ref" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation><![CDATA[
A reference to an advice bean.
]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.aopalliance.aop.Advice"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="pointcut" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
A pointcut expression.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="pointcut-ref" type="pointcutRefType">
<xsd:annotation>
<xsd:documentation><![CDATA[
A reference to a pointcut definition.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="order" type="xsd:token">
<xsd:annotation>
<xsd:documentation source="java:org.springframework.core.Ordered"><![CDATA[
Controls the ordering of the execution of this advice when multiple
advice executes at a specific joinpoint.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
<xsd:simpleType name="pointcutRefType">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.aop.Pointcut"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:union memberTypes="xsd:string"/>
</xsd:simpleType>
</xsd:schema>
@@ -307,7 +307,8 @@ public class AspectJAdviceParameterNameDiscovererTests {
try {
discoverer.getParameterNames(m);
fail("Expecting " + exceptionType.getName() + " with message '" + message + "'");
} catch (RuntimeException expected) {
}
catch (RuntimeException expected) {
assertEquals("Expecting exception of type " + exceptionType.getName(),
exceptionType, expected.getClass());
assertEquals("Exception message does not match expected", message, expected.getMessage());
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,17 +53,15 @@ public final class AspectJExpressionPointcutTests {
private Method setSomeNumber;
private Method isPostProcessed;
@Before
public void setUp() throws NoSuchMethodException {
getAge = TestBean.class.getMethod("getAge", (Class<?>[])null);
setAge = TestBean.class.getMethod("setAge", new Class[]{int.class});
setSomeNumber = TestBean.class.getMethod("setSomeNumber", new Class[]{Number.class});
isPostProcessed = TestBean.class.getMethod("isPostProcessed", (Class[]) null);
getAge = TestBean.class.getMethod("getAge");
setAge = TestBean.class.getMethod("setAge", int.class);
setSomeNumber = TestBean.class.getMethod("setSomeNumber", Number.class);
}
@Test
public void testMatchExplicit() {
String expression = "execution(int org.springframework.tests.sample.beans.TestBean.getAge())";
@@ -111,21 +109,9 @@ public final class AspectJExpressionPointcutTests {
testThisOrTarget("target");
}
public static class OtherIOther implements IOther {
@Override
public void absquatulate() {
// Empty
}
}
/**
* This and target are equivalent. Really instanceof pointcuts.
* @param which this or target
* @throws Exception
* @throws NoSuchMethodException
* @throws SecurityException
*/
private void testThisOrTarget(String which) throws SecurityException, NoSuchMethodException {
String matchesTestBean = which + "(org.springframework.tests.sample.beans.TestBean)";
@@ -138,11 +124,8 @@ public final class AspectJExpressionPointcutTests {
assertTrue(testBeanPc.matches(TestBean.class));
assertTrue(testBeanPc.matches(getAge, TestBean.class));
assertTrue(iOtherPc.matches(OtherIOther.class.getMethod("absquatulate", (Class<?>[])null),
OtherIOther.class));
assertFalse(testBeanPc.matches(OtherIOther.class.getMethod("absquatulate", (Class<?>[])null),
OtherIOther.class));
assertTrue(iOtherPc.matches(OtherIOther.class.getMethod("absquatulate"), OtherIOther.class));
assertFalse(testBeanPc.matches(OtherIOther.class.getMethod("absquatulate"), OtherIOther.class));
}
@Test
@@ -171,8 +154,7 @@ public final class AspectJExpressionPointcutTests {
assertEquals(matchSubpackages, withinBeansPc.matches(
DeepBean.class.getMethod("aMethod", String.class), DeepBean.class));
assertFalse(withinBeansPc.matches(String.class));
assertFalse(withinBeansPc.matches(OtherIOther.class.getMethod("absquatulate", (Class<?>[])null),
OtherIOther.class));
assertFalse(withinBeansPc.matches(OtherIOther.class.getMethod("absquatulate"), OtherIOther.class));
}
@Test
@@ -183,7 +165,7 @@ public final class AspectJExpressionPointcutTests {
fail();
}
catch (IllegalStateException ex) {
assertTrue(ex.getMessage().indexOf("expression") != -1);
assertTrue(ex.getMessage().contains("expression"));
}
}
@@ -195,7 +177,7 @@ public final class AspectJExpressionPointcutTests {
fail();
}
catch (IllegalStateException ex) {
assertTrue(ex.getMessage().indexOf("expression") != -1);
assertTrue(ex.getMessage().contains("expression"));
}
}
@@ -207,7 +189,7 @@ public final class AspectJExpressionPointcutTests {
fail();
}
catch (IllegalStateException ex) {
assertTrue(ex.getMessage().indexOf("expression") != -1);
assertTrue(ex.getMessage().contains("expression"));
}
}
@@ -226,10 +208,10 @@ public final class AspectJExpressionPointcutTests {
//assertDoesNotMatchStringClass(classFilter);
assertTrue("Should match with setSomeNumber with Double input",
methodMatcher.matches(setSomeNumber, TestBean.class, new Object[]{new Double(12)}));
methodMatcher.matches(setSomeNumber, TestBean.class, new Double(12)));
assertFalse("Should not match setSomeNumber with Integer input",
methodMatcher.matches(setSomeNumber, TestBean.class, new Object[]{new Integer(11)}));
assertFalse("Should not match getAge", methodMatcher.matches(getAge, TestBean.class, null));
methodMatcher.matches(setSomeNumber, TestBean.class, new Integer(11)));
assertFalse("Should not match getAge", methodMatcher.matches(getAge, TestBean.class));
assertTrue("Should be a runtime match", methodMatcher.isRuntime());
}
@@ -281,7 +263,6 @@ public final class AspectJExpressionPointcutTests {
}
catch (IllegalArgumentException ex) {
assertTrue(true);
System.out.println(ex.getMessage());
}
}
@@ -326,16 +307,14 @@ public final class AspectJExpressionPointcutTests {
@Test
public void testAndSubstitution() {
Pointcut pc = getPointcut("execution(* *(..)) and args(String)");
PointcutExpression expr =
((AspectJExpressionPointcut) pc).getPointcutExpression();
PointcutExpression expr = ((AspectJExpressionPointcut) pc).getPointcutExpression();
assertEquals("execution(* *(..)) && args(String)",expr.getPointcutExpression());
}
@Test
public void testMultipleAndSubstitutions() {
Pointcut pc = getPointcut("execution(* *(..)) and args(String) and this(Object)");
PointcutExpression expr =
((AspectJExpressionPointcut) pc).getPointcutExpression();
PointcutExpression expr = ((AspectJExpressionPointcut) pc).getPointcutExpression();
assertEquals("execution(* *(..)) && args(String) && this(Object)",expr.getPointcutExpression());
}
@@ -344,6 +323,15 @@ public final class AspectJExpressionPointcutTests {
pointcut.setExpression(expression);
return pointcut;
}
public static class OtherIOther implements IOther {
@Override
public void absquatulate() {
// Empty
}
}
}
@@ -215,7 +215,8 @@ public final class MethodInvocationProceedingJoinPointTests {
itb.setSpouse(new TestBean());
try {
itb.unreliableFileOperation();
} catch (IOException ex) {
}
catch (IOException ex) {
// we don't realy care...
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ import static org.junit.Assert.*;
* @author Rod Johnson
* @author Chris Beams
*/
public final class TigerAspectJExpressionPointcutTests {
public class TigerAspectJExpressionPointcutTests {
// TODO factor into static in AspectJExpressionPointcut
private Method getAge;
@@ -46,7 +46,7 @@ public final class TigerAspectJExpressionPointcutTests {
@Before
public void setUp() throws NoSuchMethodException {
getAge = TestBean.class.getMethod("getAge", (Class[]) null);
getAge = TestBean.class.getMethod("getAge");
// Assumes no overloading
for (Method m : HasGeneric.class.getMethods()) {
methodsOnHasGeneric.put(m.getName(), m);
@@ -54,18 +54,6 @@ public final class TigerAspectJExpressionPointcutTests {
}
public static class HasGeneric {
public void setFriends(List<TestBean> friends) {
}
public void setEnemies(List<TestBean> enemies) {
}
public void setPartners(List<?> partners) {
}
public void setPhoneNumbers(List<String> numbers) {
}
}
@Test
public void testMatchGenericArgument() {
String expression = "execution(* set*(java.util.List<org.springframework.tests.sample.beans.TestBean>) )";
@@ -132,15 +120,12 @@ public final class TigerAspectJExpressionPointcutTests {
public void testMatchAnnotationOnClassWithSubpackageWildcard() throws SecurityException, NoSuchMethodException {
String expression = "within(@(test.annotation..*) *)";
AspectJExpressionPointcut springAnnotatedPc = testMatchAnnotationOnClass(expression);
assertFalse(springAnnotatedPc.matches(TestBean.class.getMethod("setName", String.class),
TestBean.class));
assertTrue(springAnnotatedPc.matches(SpringAnnotated.class.getMethod("foo", (Class[]) null),
SpringAnnotated.class));
assertFalse(springAnnotatedPc.matches(TestBean.class.getMethod("setName", String.class), TestBean.class));
assertTrue(springAnnotatedPc.matches(SpringAnnotated.class.getMethod("foo"), SpringAnnotated.class));
expression = "within(@(test.annotation.transaction..*) *)";
AspectJExpressionPointcut springTxAnnotatedPc = testMatchAnnotationOnClass(expression);
assertFalse(springTxAnnotatedPc.matches(SpringAnnotated.class.getMethod("foo", (Class[]) null),
SpringAnnotated.class));
assertFalse(springTxAnnotatedPc.matches(SpringAnnotated.class.getMethod("foo"), SpringAnnotated.class));
}
@Test
@@ -154,7 +139,7 @@ public final class TigerAspectJExpressionPointcutTests {
ajexp.setExpression(expression);
assertFalse(ajexp.matches(getAge, TestBean.class));
assertTrue(ajexp.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class));
assertTrue(ajexp.matches(HasTransactionalAnnotation.class.getMethod("foo"), HasTransactionalAnnotation.class));
assertTrue(ajexp.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class));
assertTrue(ajexp.matches(BeanB.class.getMethod("setName", String.class), BeanB.class));
assertFalse(ajexp.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
@@ -168,10 +153,10 @@ public final class TigerAspectJExpressionPointcutTests {
ajexp.setExpression(expression);
assertFalse(ajexp.matches(getAge, TestBean.class));
assertFalse(ajexp.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class));
assertFalse(ajexp.matches(HasTransactionalAnnotation.class.getMethod("foo"), HasTransactionalAnnotation.class));
assertFalse(ajexp.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class));
assertFalse(ajexp.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
assertTrue(ajexp.matches(BeanA.class.getMethod("getAge", (Class[]) null), BeanA.class));
assertTrue(ajexp.matches(BeanA.class.getMethod("getAge"), BeanA.class));
assertFalse(ajexp.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
}
@@ -182,10 +167,10 @@ public final class TigerAspectJExpressionPointcutTests {
anySpringMethodAnnotation.setExpression(expression);
assertFalse(anySpringMethodAnnotation.matches(getAge, TestBean.class));
assertFalse(anySpringMethodAnnotation.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class));
assertFalse(anySpringMethodAnnotation.matches(HasTransactionalAnnotation.class.getMethod("foo"), HasTransactionalAnnotation.class));
assertFalse(anySpringMethodAnnotation.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class));
assertFalse(anySpringMethodAnnotation.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
assertTrue(anySpringMethodAnnotation.matches(BeanA.class.getMethod("getAge", (Class[]) null), BeanA.class));
assertTrue(anySpringMethodAnnotation.matches(BeanA.class.getMethod("getAge"), BeanA.class));
assertFalse(anySpringMethodAnnotation.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
}
@@ -196,10 +181,10 @@ public final class TigerAspectJExpressionPointcutTests {
takesSpringAnnotatedArgument2.setExpression(expression);
assertFalse(takesSpringAnnotatedArgument2.matches(getAge, TestBean.class));
assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class));
assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("foo"), HasTransactionalAnnotation.class));
assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class));
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("getAge", (Class[]) null), BeanA.class));
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("getAge"), BeanA.class));
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
assertTrue(takesSpringAnnotatedArgument2.matches(
@@ -213,8 +198,7 @@ public final class TigerAspectJExpressionPointcutTests {
assertFalse(takesSpringAnnotatedArgument2.matches(
ProcessesSpringAnnotatedParameters.class.getMethod("takesNoAnnotatedParameters", TestBean.class, BeanA.class),
ProcessesSpringAnnotatedParameters.class,
new Object[] { new TestBean(), new BeanA()})
ProcessesSpringAnnotatedParameters.class, new TestBean(), new BeanA())
);
}
@@ -225,10 +209,10 @@ public final class TigerAspectJExpressionPointcutTests {
takesSpringAnnotatedArgument2.setExpression(expression);
assertFalse(takesSpringAnnotatedArgument2.matches(getAge, TestBean.class));
assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class));
assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("foo"), HasTransactionalAnnotation.class));
assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class));
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("getAge", (Class[]) null), BeanA.class));
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("getAge"), BeanA.class));
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
assertTrue(takesSpringAnnotatedArgument2.matches(
@@ -240,6 +224,19 @@ public final class TigerAspectJExpressionPointcutTests {
}
public static class HasGeneric {
public void setFriends(List<TestBean> friends) {
}
public void setEnemies(List<TestBean> enemies) {
}
public void setPartners(List<?> partners) {
}
public void setPhoneNumbers(List<String> numbers) {
}
}
public static class ProcessesSpringAnnotatedParameters {
public void takesAnnotatedParameters(TestBean tb, SpringAnnotated sa) {
@@ -1,3 +1,19 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.aop.aspectj;
import java.lang.annotation.Documented;
@@ -97,12 +113,14 @@ public class TrickyAspectJPointcutExpressionTests {
try {
bean.sayHello();
fail("Expected exception");
} catch (TestException e) {
assertEquals(message, e.getMessage());
}
catch (TestException ex) {
assertEquals(message, ex.getMessage());
}
assertEquals(1, logAdvice.getCountThrows());
}
public static class SimpleThrowawayClassLoader extends OverridingClassLoader {
/**
@@ -115,15 +133,16 @@ public class TrickyAspectJPointcutExpressionTests {
}
@SuppressWarnings("serial")
public static class TestException extends RuntimeException {
public TestException(String string) {
super(string);
}
}
@Target({ ElementType.METHOD, ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@@ -131,18 +150,23 @@ public class TrickyAspectJPointcutExpressionTests {
public static @interface Log {
}
public static interface TestService {
public String sayHello();
}
@Log
public static class TestServiceImpl implements TestService {
@Override
public String sayHello() {
throw new TestException("TestServiceImpl");
}
}
public class LogUserAdvice implements MethodBeforeAdvice, ThrowsAdvice {
private int countBefore = 0;
@@ -154,9 +178,9 @@ public class TrickyAspectJPointcutExpressionTests {
countBefore++;
}
public void afterThrowing(Exception e) throws Throwable {
public void afterThrowing(Exception ex) throws Throwable {
countThrows++;
throw e;
throw ex;
}
public int getCountBefore() {
@@ -171,7 +195,6 @@ public class TrickyAspectJPointcutExpressionTests {
countThrows = 0;
countBefore = 0;
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.aop.aspectj.annotation;
import java.io.FileNotFoundException;
@@ -692,6 +693,11 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
return new AspectMetadata(PerTypeWithinAspect.class, "perTypeWithin");
}
@Override
public Object getAspectCreationMutex() {
return this;
}
@Override
public int getOrder() {
return Ordered.LOWEST_PRECEDENCE;
@@ -961,7 +967,7 @@ abstract class AbstractMakeModifiable {
private Method getGetterFromSetter(Method setter) {
String getterName = setter.getName().replaceFirst("set", "get");
try {
return setter.getDeclaringClass().getMethod(getterName, (Class[]) null);
return setter.getDeclaringClass().getMethod(getterName);
}
catch (NoSuchMethodException ex) {
// must be write only
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,18 +31,21 @@ import static org.junit.Assert.*;
* @author Rod Johnson
* @author Chris Beams
*/
public final class AspectJPointcutAdvisorTests {
public class AspectJPointcutAdvisorTests {
private final AspectJAdvisorFactory af = new ReflectiveAspectJAdvisorFactory();
private AspectJAdvisorFactory af = new ReflectiveAspectJAdvisorFactory();
@Test
public void testSingleton() throws SecurityException, NoSuchMethodException {
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);
InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(af, ajexp,
new SingletonMetadataAwareAspectInstanceFactory(new AbstractAspectJAdvisorFactoryTests.ExceptionAspect(null),"someBean"),
TestBean.class.getMethod("getAge", (Class[]) null),1,"someBean");
InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(
ajexp, TestBean.class.getMethod("getAge"), af,
new SingletonMetadataAwareAspectInstanceFactory(new AbstractAspectJAdvisorFactoryTests.ExceptionAspect(null), "someBean"),
1, "someBean");
assertSame(Pointcut.TRUE, ajpa.getAspectMetadata().getPerClausePointcut());
assertFalse(ajpa.isPerInstance());
}
@@ -52,34 +55,35 @@ public final class AspectJPointcutAdvisorTests {
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);
InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(af, ajexp,
new SingletonMetadataAwareAspectInstanceFactory(new PerTargetAspect(),"someBean"), null, 1, "someBean");
InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(
ajexp, TestBean.class.getMethod("getAge"), af,
new SingletonMetadataAwareAspectInstanceFactory(new PerTargetAspect(), "someBean"),
1, "someBean");
assertNotSame(Pointcut.TRUE, ajpa.getAspectMetadata().getPerClausePointcut());
assertTrue(ajpa.getAspectMetadata().getPerClausePointcut() instanceof AspectJExpressionPointcut);
assertTrue(ajpa.isPerInstance());
assertTrue(ajpa.getAspectMetadata().getPerClausePointcut().getClassFilter().matches(TestBean.class));
assertFalse(ajpa.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(
TestBean.class.getMethod("getAge", (Class[]) null),
TestBean.class));
TestBean.class.getMethod("getAge"), TestBean.class));
assertTrue(ajpa.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(
TestBean.class.getMethod("getSpouse", (Class[]) null),
TestBean.class));
TestBean.class.getMethod("getSpouse"), TestBean.class));
}
@Test(expected=AopConfigException.class)
@Test(expected = AopConfigException.class)
public void testPerCflowTarget() {
testIllegalInstantiationModel(AbstractAspectJAdvisorFactoryTests.PerCflowAspect.class);
}
@Test(expected=AopConfigException.class)
@Test(expected = AopConfigException.class)
public void testPerCflowBelowTarget() {
testIllegalInstantiationModel(AbstractAspectJAdvisorFactoryTests.PerCflowBelowAspect.class);
}
private void testIllegalInstantiationModel(Class<?> c) throws AopConfigException {
new AspectMetadata(c,"someBean");
new AspectMetadata(c, "someBean");
}
}
@@ -16,13 +16,13 @@
package org.springframework.aop.aspectj.annotation;
import java.io.Serializable;
import java.util.Arrays;
import org.apache.commons.logging.LogFactory;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.junit.Ignore;
import org.junit.Test;
import test.aop.PerThisAspect;
@@ -80,7 +80,18 @@ public class AspectProxyFactoryTests {
}
@Test
@Ignore // InstantiationModelAwarePointcutAdvisorImpl not serializable yet
@SuppressWarnings("unchecked")
public void testSerializable() throws Exception {
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
proxyFactory.addAspect(LoggingAspectOnVarargs.class);
ITestBean proxy = proxyFactory.getProxy();
assertTrue(proxy.doWithVarargs(MyEnum.A, MyOtherEnum.C));
ITestBean tb = (ITestBean) SerializationTestUtils.serializeAndDeserialize(proxy);
assertTrue(tb.doWithVarargs(MyEnum.A, MyOtherEnum.C));
}
@Test
@SuppressWarnings("unchecked")
public void testWithInstance() throws Exception {
MultiplyReturnValue aspect = new MultiplyReturnValue();
int multiple = 3;
@@ -133,7 +144,8 @@ public class AspectProxyFactoryTests {
}
public static class TestBean implements ITestBean {
@SuppressWarnings("serial")
public static class TestBean implements ITestBean, Serializable {
private int age;
@@ -171,7 +183,8 @@ public class AspectProxyFactoryTests {
@Aspect
public static class LoggingAspectOnVarargs {
@SuppressWarnings("serial")
public static class LoggingAspectOnVarargs implements Serializable {
@Around("execution(* doWithVarargs(*))")
public Object doLog(ProceedingJoinPoint pjp) throws Throwable {
@@ -193,11 +206,9 @@ public class AspectProxyFactoryTests {
}
/**
* @author Rod Johnson
*/
@Aspect
class MultiplyReturnValue {
@SuppressWarnings("serial")
class MultiplyReturnValue implements Serializable {
private int multiple = 2;
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +16,6 @@
package org.springframework.aop.framework;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.List;
@@ -34,7 +32,7 @@ import static org.junit.Assert.*;
* @author Rod Johnson
* @author Chris Beams
*/
public final class AopProxyUtilsTests {
public class AopProxyUtilsTests {
@Test
public void testCompleteProxiedInterfacesWorksWithNull() {
@@ -125,15 +123,10 @@ public final class AopProxyUtilsTests {
assertEquals(Comparable.class, userInterfaces[1]);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testProxiedUserInterfacesWithNoInterface() {
Object proxy = Proxy.newProxyInstance(getClass().getClassLoader(), new Class[0],
new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return null;
}
});
(proxy1, method, args) -> null);
AopProxyUtils.proxiedUserInterfaces(proxy);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,7 +37,7 @@ public final class MethodInvocationTests {
@Test
public void testValidInvocation() throws Throwable {
Method m = Object.class.getMethod("hashCode", (Class[]) null);
Method m = Object.class.getMethod("hashCode");
Object proxy = new Object();
final Object returnValue = new Object();
List<Object> is = new LinkedList<Object>();
@@ -67,7 +67,7 @@ public final class MethodInvocationTests {
};
List<Object> is = new LinkedList<Object>();
Method m = Object.class.getMethod("hashCode", (Class[]) null);
Method m = Object.class.getMethod("hashCode");
Object proxy = new Object();
ReflectiveMethodInvocation invocation =
new ReflectiveMethodInvocation(proxy, target, m, null, null, is);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
package org.springframework.aop.framework;
import java.util.ArrayList;
import java.util.List;
import javax.accessibility.Accessible;
import javax.swing.JFrame;
import javax.swing.RootPaneContainer;
@@ -31,6 +33,8 @@ import org.springframework.aop.support.AopUtils;
import org.springframework.aop.support.DefaultIntroductionAdvisor;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.core.annotation.Order;
import org.springframework.tests.TimeStamped;
import org.springframework.tests.aop.advice.CountingBeforeAdvice;
import org.springframework.tests.aop.interceptor.NopInterceptor;
@@ -49,7 +53,7 @@ import static org.junit.Assert.*;
* @author Chris Beams
* @since 14.05.2003
*/
public final class ProxyFactoryTests {
public class ProxyFactoryTests {
@Test
public void testIndexOfMethods() {
@@ -337,6 +341,34 @@ public final class ProxyFactoryTests {
assertTrue(proxy instanceof Accessible);
}
@Test
public void testInterfaceProxiesCanBeOrderedThroughAnnotations() {
Object proxy1 = new ProxyFactory(new A()).getProxy();
Object proxy2 = new ProxyFactory(new B()).getProxy();
List<Object> list = new ArrayList<Object>(2);
list.add(proxy1);
list.add(proxy2);
AnnotationAwareOrderComparator.sort(list);
assertSame(proxy2, list.get(0));
assertSame(proxy1, list.get(1));
}
@Test
public void testTargetClassProxiesCanBeOrderedThroughAnnotations() {
ProxyFactory pf1 = new ProxyFactory(new A());
pf1.setProxyTargetClass(true);
ProxyFactory pf2 = new ProxyFactory(new B());
pf2.setProxyTargetClass(true);
Object proxy1 = pf1.getProxy();
Object proxy2 = pf2.getProxy();
List<Object> list = new ArrayList<Object>(2);
list.add(proxy1);
list.add(proxy2);
AnnotationAwareOrderComparator.sort(list);
assertSame(proxy2, list.get(0));
assertSame(proxy1, list.get(1));
}
@SuppressWarnings("serial")
private static class TimestampIntroductionInterceptor extends DelegatingIntroductionInterceptor
@@ -361,4 +393,22 @@ public final class ProxyFactoryTests {
}
}
@Order(2)
public static class A implements Runnable {
@Override
public void run() {
}
}
@Order(1)
public static class B implements Runnable{
@Override
public void run() {
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -78,7 +78,7 @@ public final class ThrowsAdviceInterceptorTests {
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
FileNotFoundException ex = new FileNotFoundException();
MethodInvocation mi = mock(MethodInvocation.class);
given(mi.getMethod()).willReturn(Object.class.getMethod("hashCode", (Class[]) null));
given(mi.getMethod()).willReturn(Object.class.getMethod("hashCode"));
given(mi.getThis()).willReturn(new Object());
given(mi.proceed()).willThrow(ex);
try {
@@ -140,12 +140,15 @@ public final class ThrowsAdviceInterceptorTests {
assertEquals(1, th.getCalls("remoteException"));
}
@SuppressWarnings("serial")
static class MyThrowsHandler extends MethodCounter implements ThrowsAdvice {
// Full method signature
public void afterThrowing(Method m, Object[] args, Object target, IOException ex) {
count("ioException");
}
public void afterThrowing(RemoteException ex) throws Throwable {
count("remoteException");
}
@@ -61,7 +61,8 @@ public final class DebugInterceptorTests {
try {
interceptor.invoke(methodInvocation);
fail("Must have propagated the IllegalArgumentException.");
} catch (IllegalArgumentException expected) {
}
catch (IllegalArgumentException expected) {
}
checkCallCountTotal(interceptor);
@@ -60,7 +60,8 @@ public final class SimpleTraceInterceptorTests {
try {
interceptor.invokeUnderTrace(mi, log);
fail("Must have propagated the IllegalArgumentException.");
} catch (IllegalArgumentException expected) {
}
catch (IllegalArgumentException expected) {
}
verify(log).trace(anyString());
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
package org.springframework.aop.scope;
import java.util.Arrays;
import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
@@ -27,19 +29,24 @@ import static org.springframework.tests.TestResourceUtils.*;
/**
* @author Mark Fisher
* @author Juergen Hoeller
* @author Chris Beams
*/
public final class ScopedProxyAutowireTests {
public class ScopedProxyAutowireTests {
private static final Class<?> CLASS = ScopedProxyAutowireTests.class;
private static final Resource SCOPED_AUTOWIRE_FALSE_CONTEXT =
qualifiedResource(ScopedProxyAutowireTests.class, "scopedAutowireFalse.xml");
private static final Resource SCOPED_AUTOWIRE_TRUE_CONTEXT =
qualifiedResource(ScopedProxyAutowireTests.class, "scopedAutowireTrue.xml");
private static final Resource SCOPED_AUTOWIRE_TRUE_CONTEXT = qualifiedResource(CLASS, "scopedAutowireTrue.xml");
private static final Resource SCOPED_AUTOWIRE_FALSE_CONTEXT = qualifiedResource(CLASS, "scopedAutowireFalse.xml");
@Test
public void testScopedProxyInheritsAutowireCandidateFalse() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(SCOPED_AUTOWIRE_FALSE_CONTEXT);
assertTrue(Arrays.asList(bf.getBeanNamesForType(TestBean.class, false, false)).contains("scoped"));
assertTrue(Arrays.asList(bf.getBeanNamesForType(TestBean.class, true, false)).contains("scoped"));
assertFalse(bf.containsSingleton("scoped"));
TestBean autowired = (TestBean) bf.getBean("autowired");
TestBean unscoped = (TestBean) bf.getBean("unscoped");
assertSame(unscoped, autowired.getChild());
@@ -49,6 +56,9 @@ public final class ScopedProxyAutowireTests {
public void testScopedProxyReplacesAutowireCandidateTrue() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(SCOPED_AUTOWIRE_TRUE_CONTEXT);
assertTrue(Arrays.asList(bf.getBeanNamesForType(TestBean.class, true, false)).contains("scoped"));
assertTrue(Arrays.asList(bf.getBeanNamesForType(TestBean.class, false, false)).contains("scoped"));
assertFalse(bf.containsSingleton("scoped"));
TestBean autowired = (TestBean) bf.getBean("autowired");
TestBean scoped = (TestBean) bf.getBean("scoped");
assertSame(scoped, autowired.getChild());
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,8 +54,8 @@ public abstract class AbstractRegexpMethodPointcutTests {
}
protected void noPatternSuppliedTests(AbstractRegexpMethodPointcut rpc) throws Exception {
assertFalse(rpc.matches(Object.class.getMethod("hashCode", (Class[]) null), String.class));
assertFalse(rpc.matches(Object.class.getMethod("wait", (Class[]) null), Object.class));
assertFalse(rpc.matches(Object.class.getMethod("hashCode"), String.class));
assertFalse(rpc.matches(Object.class.getMethod("wait"), Object.class));
assertEquals(0, rpc.getPatterns().length);
}
@@ -69,38 +69,38 @@ public abstract class AbstractRegexpMethodPointcutTests {
protected void exactMatchTests(AbstractRegexpMethodPointcut rpc) throws Exception {
// assumes rpc.setPattern("java.lang.Object.hashCode");
assertTrue(rpc.matches(Object.class.getMethod("hashCode", (Class[]) null), String.class));
assertTrue(rpc.matches(Object.class.getMethod("hashCode", (Class[]) null), Object.class));
assertFalse(rpc.matches(Object.class.getMethod("wait", (Class[]) null), Object.class));
assertTrue(rpc.matches(Object.class.getMethod("hashCode"), String.class));
assertTrue(rpc.matches(Object.class.getMethod("hashCode"), Object.class));
assertFalse(rpc.matches(Object.class.getMethod("wait"), Object.class));
}
@Test
public void testSpecificMatch() throws Exception {
rpc.setPattern("java.lang.String.hashCode");
assertTrue(rpc.matches(Object.class.getMethod("hashCode", (Class[]) null), String.class));
assertFalse(rpc.matches(Object.class.getMethod("hashCode", (Class[]) null), Object.class));
assertTrue(rpc.matches(Object.class.getMethod("hashCode"), String.class));
assertFalse(rpc.matches(Object.class.getMethod("hashCode"), Object.class));
}
@Test
public void testWildcard() throws Exception {
rpc.setPattern(".*Object.hashCode");
assertTrue(rpc.matches(Object.class.getMethod("hashCode", (Class[]) null), Object.class));
assertFalse(rpc.matches(Object.class.getMethod("wait", (Class[]) null), Object.class));
assertTrue(rpc.matches(Object.class.getMethod("hashCode"), Object.class));
assertFalse(rpc.matches(Object.class.getMethod("wait"), Object.class));
}
@Test
public void testWildcardForOneClass() throws Exception {
rpc.setPattern("java.lang.Object.*");
assertTrue(rpc.matches(Object.class.getMethod("hashCode", (Class[]) null), String.class));
assertTrue(rpc.matches(Object.class.getMethod("wait", (Class[]) null), String.class));
assertTrue(rpc.matches(Object.class.getMethod("hashCode"), String.class));
assertTrue(rpc.matches(Object.class.getMethod("wait"), String.class));
}
@Test
public void testMatchesObjectClass() throws Exception {
rpc.setPattern("java.lang.Object.*");
assertTrue(rpc.matches(Exception.class.getMethod("hashCode", (Class[]) null), IOException.class));
assertTrue(rpc.matches(Exception.class.getMethod("hashCode"), IOException.class));
// Doesn't match a method from Throwable
assertFalse(rpc.matches(Exception.class.getMethod("getMessage", (Class[]) null), Exception.class));
assertFalse(rpc.matches(Exception.class.getMethod("getMessage"), Exception.class));
}
@Test
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,7 +32,7 @@ import static org.junit.Assert.*;
* @author Rod Johnson
* @author Chris Beams
*/
public final class ComposablePointcutTests {
public class ComposablePointcutTests {
public static MethodMatcher GETTER_METHOD_MATCHER = new StaticMethodMatcher() {
@Override
@@ -62,11 +62,12 @@ public final class ComposablePointcutTests {
}
};
@Test
public void testMatchAll() throws NoSuchMethodException {
Pointcut pc = new ComposablePointcut();
assertTrue(pc.getClassFilter().matches(Object.class));
assertTrue(pc.getMethodMatcher().matches(Object.class.getMethod("hashCode", (Class[]) null), Exception.class));
assertTrue(pc.getMethodMatcher().matches(Object.class.getMethod("hashCode"), Exception.class));
}
@Test
@@ -93,23 +94,23 @@ public final class ComposablePointcutTests {
public void testUnionMethodMatcher() {
// Matches the getAge() method in any class
ComposablePointcut pc = new ComposablePointcut(ClassFilter.TRUE, GET_AGE_METHOD_MATCHER);
assertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.class, null));
assertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_AGE, TestBean.class, null));
assertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.class, null));
assertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.class));
assertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_AGE, TestBean.class));
assertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.class));
pc.union(GETTER_METHOD_MATCHER);
// Should now match all getter methods
assertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.class, null));
assertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_AGE, TestBean.class, null));
assertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.class, null));
assertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.class));
assertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_AGE, TestBean.class));
assertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.class));
pc.union(ABSQUATULATE_METHOD_MATCHER);
// Should now match absquatulate() as well
assertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.class, null));
assertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_AGE, TestBean.class, null));
assertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.class, null));
assertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.class));
assertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_AGE, TestBean.class));
assertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.class));
// But it doesn't match everything
assertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_SET_AGE, TestBean.class, null));
assertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_SET_AGE, TestBean.class));
}
@Test
@@ -124,9 +125,9 @@ public final class ComposablePointcutTests {
assertTrue(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_GET_NAME, TestBean.class));
pc.intersection(GET_AGE_METHOD_MATCHER);
// Use the Pointcuts matches method
assertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.class, null));
assertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_AGE, TestBean.class, null));
assertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.class, null));
assertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.class));
assertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_AGE, TestBean.class));
assertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.class));
}
@Test
@@ -153,4 +154,5 @@ public final class ComposablePointcutTests {
assertEquals(pc1, pc2);
assertEquals(pc1.hashCode(), pc2.hashCode());
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,7 +32,7 @@ import static org.junit.Assert.*;
* @author Juergen Hoeller
* @author Chris Beams
*/
public final class MethodMatchersTests {
public class MethodMatchersTests {
private final Method EXCEPTION_GETMESSAGE;
@@ -44,10 +44,10 @@ public final class MethodMatchersTests {
public MethodMatchersTests() throws Exception {
EXCEPTION_GETMESSAGE = Exception.class.getMethod("getMessage", (Class[]) null);
ITESTBEAN_GETAGE = ITestBean.class.getMethod("getAge", (Class[]) null);
ITESTBEAN_SETAGE = ITestBean.class.getMethod("setAge", new Class[] { int.class });
IOTHER_ABSQUATULATE = IOther.class.getMethod("absquatulate", (Class[]) null);
EXCEPTION_GETMESSAGE = Exception.class.getMethod("getMessage");
ITESTBEAN_GETAGE = ITestBean.class.getMethod("getAge");
ITESTBEAN_SETAGE = ITestBean.class.getMethod("setAge", int.class);
IOTHER_ABSQUATULATE = IOther.class.getMethod("absquatulate");
}
@@ -82,12 +82,12 @@ public final class MethodMatchersTests {
MethodMatcher intersection = MethodMatchers.intersection(mm1, mm2);
assertTrue("Intersection is a dynamic matcher", intersection.isRuntime());
assertTrue("2Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.class));
assertTrue("3Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.class, new Object[] { new Integer(5) }));
assertTrue("3Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.class, new Integer(5)));
// Knock out dynamic part
intersection = MethodMatchers.intersection(intersection, new TestDynamicMethodMatcherWhichDoesNotMatch());
assertTrue("Intersection is a dynamic matcher", intersection.isRuntime());
assertTrue("2Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.class));
assertFalse("3 - not Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.class, new Object[] { new Integer(5) }));
assertFalse("3 - not Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.class, new Integer(5)));
}
@Test
@@ -125,18 +125,20 @@ public final class MethodMatchersTests {
}
}
private static class TestDynamicMethodMatcherWhichMatches extends DynamicMethodMatcher {
@Override
public boolean matches(Method m, Class<?> targetClass, Object[] args) {
public boolean matches(Method m, Class<?> targetClass, Object... args) {
return true;
}
}
private static class TestDynamicMethodMatcherWhichDoesNotMatch extends DynamicMethodMatcher {
@Override
public boolean matches(Method m, Class<?> targetClass, Object[] args) {
public boolean matches(Method m, Class<?> targetClass, Object... args) {
return false;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ import static org.junit.Assert.*;
* @author Rod Johnson
* @author Chris Beams
*/
public final class PointcutsTests {
public class PointcutsTests {
public static Method TEST_BEAN_SET_AGE;
public static Method TEST_BEAN_GET_AGE;
@@ -39,10 +39,10 @@ public final class PointcutsTests {
static {
try {
TEST_BEAN_SET_AGE = TestBean.class.getMethod("setAge", new Class[] { int.class });
TEST_BEAN_GET_AGE = TestBean.class.getMethod("getAge", (Class[]) null);
TEST_BEAN_GET_NAME = TestBean.class.getMethod("getName", (Class[]) null);
TEST_BEAN_ABSQUATULATE = TestBean.class.getMethod("absquatulate", (Class[]) null);
TEST_BEAN_SET_AGE = TestBean.class.getMethod("setAge", int.class);
TEST_BEAN_GET_AGE = TestBean.class.getMethod("getAge");
TEST_BEAN_GET_NAME = TestBean.class.getMethod("getName");
TEST_BEAN_ABSQUATULATE = TestBean.class.getMethod("absquatulate");
}
catch (Exception ex) {
throw new RuntimeException("Shouldn't happen: error in test suite");
@@ -125,22 +125,22 @@ public final class PointcutsTests {
@Test
public void testTrue() {
assertTrue(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)}));
assertTrue(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_GET_AGE, TestBean.class, null));
assertTrue(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_ABSQUATULATE, TestBean.class, null));
assertTrue(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)}));
assertTrue(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_GET_AGE, TestBean.class, null));
assertTrue(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_ABSQUATULATE, TestBean.class, null));
assertTrue(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_SET_AGE, TestBean.class, new Integer(6)));
assertTrue(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_GET_AGE, TestBean.class));
assertTrue(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_ABSQUATULATE, TestBean.class));
assertTrue(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_SET_AGE, TestBean.class, new Integer(6)));
assertTrue(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_GET_AGE, TestBean.class));
assertTrue(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_ABSQUATULATE, TestBean.class));
}
@Test
public void testMatches() {
assertTrue(Pointcuts.matches(allClassSetterPointcut, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)}));
assertFalse(Pointcuts.matches(allClassSetterPointcut, TEST_BEAN_GET_AGE, TestBean.class, null));
assertFalse(Pointcuts.matches(allClassSetterPointcut, TEST_BEAN_ABSQUATULATE, TestBean.class, null));
assertFalse(Pointcuts.matches(allClassGetterPointcut, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)}));
assertTrue(Pointcuts.matches(allClassGetterPointcut, TEST_BEAN_GET_AGE, TestBean.class, null));
assertFalse(Pointcuts.matches(allClassGetterPointcut, TEST_BEAN_ABSQUATULATE, TestBean.class, null));
assertTrue(Pointcuts.matches(allClassSetterPointcut, TEST_BEAN_SET_AGE, TestBean.class, new Integer(6)));
assertFalse(Pointcuts.matches(allClassSetterPointcut, TEST_BEAN_GET_AGE, TestBean.class));
assertFalse(Pointcuts.matches(allClassSetterPointcut, TEST_BEAN_ABSQUATULATE, TestBean.class));
assertFalse(Pointcuts.matches(allClassGetterPointcut, TEST_BEAN_SET_AGE, TestBean.class, new Integer(6)));
assertTrue(Pointcuts.matches(allClassGetterPointcut, TEST_BEAN_GET_AGE, TestBean.class));
assertFalse(Pointcuts.matches(allClassGetterPointcut, TEST_BEAN_ABSQUATULATE, TestBean.class));
}
/**
@@ -149,29 +149,29 @@ public final class PointcutsTests {
@Test
public void testUnionOfSettersAndGetters() {
Pointcut union = Pointcuts.union(allClassGetterPointcut, allClassSetterPointcut);
assertTrue(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)}));
assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, TestBean.class, null));
assertFalse(Pointcuts.matches(union, TEST_BEAN_ABSQUATULATE, TestBean.class, null));
assertTrue(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, new Integer(6)));
assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, TestBean.class));
assertFalse(Pointcuts.matches(union, TEST_BEAN_ABSQUATULATE, TestBean.class));
}
@Test
public void testUnionOfSpecificGetters() {
Pointcut union = Pointcuts.union(allClassGetAgePointcut, allClassGetNamePointcut);
assertFalse(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)}));
assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, TestBean.class, null));
assertFalse(Pointcuts.matches(allClassGetAgePointcut, TEST_BEAN_GET_NAME, TestBean.class, null));
assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_NAME, TestBean.class, null));
assertFalse(Pointcuts.matches(union, TEST_BEAN_ABSQUATULATE, TestBean.class, null));
assertFalse(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, new Integer(6)));
assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, TestBean.class));
assertFalse(Pointcuts.matches(allClassGetAgePointcut, TEST_BEAN_GET_NAME, TestBean.class));
assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_NAME, TestBean.class));
assertFalse(Pointcuts.matches(union, TEST_BEAN_ABSQUATULATE, TestBean.class));
// Union with all setters
union = Pointcuts.union(union, allClassSetterPointcut);
assertTrue(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)}));
assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, TestBean.class, null));
assertFalse(Pointcuts.matches(allClassGetAgePointcut, TEST_BEAN_GET_NAME, TestBean.class, null));
assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_NAME, TestBean.class, null));
assertFalse(Pointcuts.matches(union, TEST_BEAN_ABSQUATULATE, TestBean.class, null));
assertTrue(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, new Integer(6)));
assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, TestBean.class));
assertFalse(Pointcuts.matches(allClassGetAgePointcut, TEST_BEAN_GET_NAME, TestBean.class));
assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_NAME, TestBean.class));
assertFalse(Pointcuts.matches(union, TEST_BEAN_ABSQUATULATE, TestBean.class));
assertTrue(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)}));
assertTrue(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, new Integer(6)));
}
/**
@@ -180,16 +180,16 @@ public final class PointcutsTests {
*/
@Test
public void testUnionOfAllSettersAndSubclassSetters() {
assertFalse(Pointcuts.matches(myTestBeanSetterPointcut, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)}));
assertTrue(Pointcuts.matches(myTestBeanSetterPointcut, TEST_BEAN_SET_AGE, MyTestBean.class, new Object[] { new Integer(6)}));
assertFalse(Pointcuts.matches(myTestBeanSetterPointcut, TEST_BEAN_GET_AGE, TestBean.class, null));
assertFalse(Pointcuts.matches(myTestBeanSetterPointcut, TEST_BEAN_SET_AGE, TestBean.class, new Integer(6)));
assertTrue(Pointcuts.matches(myTestBeanSetterPointcut, TEST_BEAN_SET_AGE, MyTestBean.class, new Integer(6)));
assertFalse(Pointcuts.matches(myTestBeanSetterPointcut, TEST_BEAN_GET_AGE, TestBean.class));
Pointcut union = Pointcuts.union(myTestBeanSetterPointcut, allClassGetterPointcut);
assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, TestBean.class, null));
assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, MyTestBean.class, null));
assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, TestBean.class));
assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, MyTestBean.class));
// Still doesn't match superclass setter
assertTrue(Pointcuts.matches(union, TEST_BEAN_SET_AGE, MyTestBean.class, new Object[] { new Integer(6)}));
assertFalse(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)}));
assertTrue(Pointcuts.matches(union, TEST_BEAN_SET_AGE, MyTestBean.class, new Integer(6)));
assertFalse(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, new Integer(6)));
}
/**
@@ -198,44 +198,44 @@ public final class PointcutsTests {
*/
@Test
public void testIntersectionOfSpecificGettersAndSubclassGetters() {
assertTrue(Pointcuts.matches(allClassGetAgePointcut, TEST_BEAN_GET_AGE, TestBean.class, null));
assertTrue(Pointcuts.matches(allClassGetAgePointcut, TEST_BEAN_GET_AGE, MyTestBean.class, null));
assertFalse(Pointcuts.matches(myTestBeanGetterPointcut, TEST_BEAN_GET_NAME, TestBean.class, null));
assertFalse(Pointcuts.matches(myTestBeanGetterPointcut, TEST_BEAN_GET_AGE, TestBean.class, null));
assertTrue(Pointcuts.matches(myTestBeanGetterPointcut, TEST_BEAN_GET_NAME, MyTestBean.class, null));
assertTrue(Pointcuts.matches(myTestBeanGetterPointcut, TEST_BEAN_GET_AGE, MyTestBean.class, null));
assertTrue(Pointcuts.matches(allClassGetAgePointcut, TEST_BEAN_GET_AGE, TestBean.class));
assertTrue(Pointcuts.matches(allClassGetAgePointcut, TEST_BEAN_GET_AGE, MyTestBean.class));
assertFalse(Pointcuts.matches(myTestBeanGetterPointcut, TEST_BEAN_GET_NAME, TestBean.class));
assertFalse(Pointcuts.matches(myTestBeanGetterPointcut, TEST_BEAN_GET_AGE, TestBean.class));
assertTrue(Pointcuts.matches(myTestBeanGetterPointcut, TEST_BEAN_GET_NAME, MyTestBean.class));
assertTrue(Pointcuts.matches(myTestBeanGetterPointcut, TEST_BEAN_GET_AGE, MyTestBean.class));
Pointcut intersection = Pointcuts.intersection(allClassGetAgePointcut, myTestBeanGetterPointcut);
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_NAME, TestBean.class, null));
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, TestBean.class, null));
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_NAME, MyTestBean.class, null));
assertTrue(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, MyTestBean.class, null));
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_NAME, TestBean.class));
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, TestBean.class));
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_NAME, MyTestBean.class));
assertTrue(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, MyTestBean.class));
// Matches subclass of MyTestBean
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_NAME, MyTestBeanSubclass.class, null));
assertTrue(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, MyTestBeanSubclass.class, null));
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_NAME, MyTestBeanSubclass.class));
assertTrue(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, MyTestBeanSubclass.class));
// Now intersection with MyTestBeanSubclass getters should eliminate MyTestBean target
intersection = Pointcuts.intersection(intersection, myTestBeanSubclassGetterPointcut);
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_NAME, TestBean.class, null));
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, TestBean.class, null));
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_NAME, MyTestBean.class, null));
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, MyTestBean.class, null));
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_NAME, TestBean.class));
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, TestBean.class));
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_NAME, MyTestBean.class));
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, MyTestBean.class));
// Still matches subclass of MyTestBean
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_NAME, MyTestBeanSubclass.class, null));
assertTrue(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, MyTestBeanSubclass.class, null));
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_NAME, MyTestBeanSubclass.class));
assertTrue(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, MyTestBeanSubclass.class));
// Now union with all TestBean methods
Pointcut union = Pointcuts.union(intersection, allTestBeanMethodsPointcut);
assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_NAME, TestBean.class, null));
assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, TestBean.class, null));
assertFalse(Pointcuts.matches(union, TEST_BEAN_GET_NAME, MyTestBean.class, null));
assertFalse(Pointcuts.matches(union, TEST_BEAN_GET_AGE, MyTestBean.class, null));
assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_NAME, TestBean.class));
assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, TestBean.class));
assertFalse(Pointcuts.matches(union, TEST_BEAN_GET_NAME, MyTestBean.class));
assertFalse(Pointcuts.matches(union, TEST_BEAN_GET_AGE, MyTestBean.class));
// Still matches subclass of MyTestBean
assertFalse(Pointcuts.matches(union, TEST_BEAN_GET_NAME, MyTestBeanSubclass.class, null));
assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, MyTestBeanSubclass.class, null));
assertFalse(Pointcuts.matches(union, TEST_BEAN_GET_NAME, MyTestBeanSubclass.class));
assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, MyTestBeanSubclass.class));
assertTrue(Pointcuts.matches(union, TEST_BEAN_ABSQUATULATE, TestBean.class, null));
assertFalse(Pointcuts.matches(union, TEST_BEAN_ABSQUATULATE, MyTestBean.class, null));
assertTrue(Pointcuts.matches(union, TEST_BEAN_ABSQUATULATE, TestBean.class));
assertFalse(Pointcuts.matches(union, TEST_BEAN_ABSQUATULATE, MyTestBean.class));
}
@@ -245,9 +245,9 @@ public final class PointcutsTests {
@Test
public void testSimpleIntersection() {
Pointcut intersection = Pointcuts.intersection(allClassGetterPointcut, allClassSetterPointcut);
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)}));
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, TestBean.class, null));
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_ABSQUATULATE, TestBean.class, null));
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_SET_AGE, TestBean.class, new Integer(6)));
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, TestBean.class));
assertFalse(Pointcuts.matches(intersection, TEST_BEAN_ABSQUATULATE, TestBean.class));
}
}
@@ -154,7 +154,8 @@ public class ThreadLocalTargetSourceTests {
// try second time
try {
source.getTarget();
} catch(NullPointerException ex) {
}
catch (NullPointerException ex) {
fail("Should not throw NPE");
}
}
@@ -1,6 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,27 +28,21 @@ public class NopInterceptor implements MethodInterceptor {
private int count;
/**
* @see org.aopalliance.intercept.MethodInterceptor#invoke(MethodInvocation)
*/
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
increment();
return invocation.proceed();
}
protected void increment() {
this.count++;
}
public int getCount() {
return this.count;
}
protected void increment() {
++count;
}
@Override
public int hashCode() {
return 0;
}
@Override
public boolean equals(Object other) {
@@ -62,5 +55,9 @@ public class NopInterceptor implements MethodInterceptor {
return this.count == ((NopInterceptor) other).count;
}
@Override
public int hashCode() {
return NopInterceptor.class.hashCode();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,22 +28,10 @@ import org.springframework.util.ObjectUtils;
@SuppressWarnings("serial")
public class SerializablePerson implements Person, Serializable {
private static final long serialVersionUID = 1L;
private String name;
private int age;
@Override
public int getAge() {
return age;
}
@Override
public void setAge(int age) {
this.age = age;
}
@Override
public String getName() {
@@ -55,6 +43,16 @@ public class SerializablePerson implements Person, Serializable {
this.name = name;
}
@Override
public int getAge() {
return age;
}
@Override
public void setAge(int age) {
this.age = age;
}
@Override
public Object echo(Object o) throws Throwable {
if (o instanceof Throwable) {
@@ -63,10 +61,6 @@ public class SerializablePerson implements Person, Serializable {
return o;
}
@Override
public int hashCode() {
return 0;
}
@Override
public boolean equals(Object other) {
@@ -77,4 +71,9 @@ public class SerializablePerson implements Person, Serializable {
return p.age == age && ObjectUtils.nullSafeEquals(name, p.name);
}
@Override
public int hashCode() {
return SerializablePerson.class.hashCode();
}
}
@@ -1,6 +1,6 @@
<config xmlns="http://www.springframework.org/schema/aop"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<pointcut id="testPointcut" expression="execution(* foo(..)) and within(springbank.dao.AccountDao+)"/>
<pointcut id="testPointcut1" expression="execution(* springbank.dao.AccountDao.foo(..))"/>
@@ -9,4 +9,4 @@
<after method="foo" pointcut-ref="testPointcut"/>
</aspect>
</config>
</config>
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="scoped" class="org.springframework.aop.scope.ScopedProxyAutowireTests$TestBean" autowire-candidate="false">
<aop:scoped-proxy/>
</bean>
<bean id="scoped" class="org.springframework.aop.scope.ScopedProxyAutowireTests$TestBean" scope="prototype" autowire-candidate="false">
<aop:scoped-proxy/>
</bean>
<bean id="unscoped" class="org.springframework.aop.scope.ScopedProxyAutowireTests$TestBean" autowire-candidate="true"/>
<bean id="unscoped" class="org.springframework.aop.scope.ScopedProxyAutowireTests$TestBean" autowire-candidate="true"/>
<bean id="autowired" class="org.springframework.aop.scope.ScopedProxyAutowireTests$TestBean" autowire="byType"/>
<bean id="autowired" class="org.springframework.aop.scope.ScopedProxyAutowireTests$TestBean" autowire="byType"/>
</beans>
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="scoped" class="org.springframework.aop.scope.ScopedProxyAutowireTests$TestBean" autowire-candidate="true">
<aop:scoped-proxy/>
</bean>
<bean id="scoped" class="org.springframework.aop.scope.ScopedProxyAutowireTests$TestBean" scope="singleton" autowire-candidate="true">
<aop:scoped-proxy/>
</bean>
<bean id="unscoped" class="org.springframework.aop.scope.ScopedProxyAutowireTests$TestBean" autowire-candidate="false"/>
<bean id="unscoped" class="org.springframework.aop.scope.ScopedProxyAutowireTests$TestBean" autowire-candidate="false"/>
<bean id="autowired" class="org.springframework.aop.scope.ScopedProxyAutowireTests$TestBean" autowire="byType"/>
<bean id="autowired" class="org.springframework.aop.scope.ScopedProxyAutowireTests$TestBean" autowire="byType"/>
</beans>

Some files were not shown because too many files have changed in this diff Show More