Commit Graph

472 Commits

Author SHA1 Message Date
Juergen Hoeller
edf664c1cf Defensively handle fast class generation failure for individual methods
Includes rethrowing of last actual defineClass exception encountered.

Closes gh-27490
2021-09-30 18:00:10 +02:00
Juergen Hoeller
e31d66cd2b Polishing (backported from 5.3.x) 2021-09-02 23:18:36 +02:00
Sam Brannen
b7e6169e12 Update copyright date 2021-08-31 09:46:29 +02:00
Inmord
9c204dc475 Polish AbstractAspectJAdvisorFactory
Closes gh-27340
2021-08-31 09:40:28 +02:00
Juergen Hoeller
fe3357d6b9 Polishing (backported) 2021-07-13 19:07:15 +02:00
Juergen Hoeller
bdbd999619 Make proxyTargetClass=true with introduction advice work for JDK proxy targets
Closes gh-27044

(cherry picked from commit c45c46dad7)
2021-07-13 18:34:49 +02:00
Juergen Hoeller
05d767b1cf Always propagate checked exceptions from Kotlin code behind CGLIB proxies
Closes gh-23844
2021-05-11 17:29:40 +02:00
Juergen Hoeller
0fc831e8bd Polishing (backported from master) 2021-03-09 00:05:55 +01:00
Juergen Hoeller
dd3262bfe3 Polishing (backported from master) 2021-02-25 19:08:53 +01:00
Juergen Hoeller
7881329cf7 Polishing 2020-11-05 18:18:38 +01:00
Juergen Hoeller
a8b295c516 Consistent javadoc for ParseState and its entry classes 2020-08-27 14:37:42 +02:00
Juergen Hoeller
7d56c303a4 Use getType with allowFactoryBeanInit=false during advisor retrieval
Closes gh-25546
2020-08-10 14:43:02 +02:00
Sam Brannen
335c3d5db6 Polish contribution
See gh-25445
2020-07-22 17:26:59 +02:00
XenoAmess
ab859fcc96 Refine use of substring operations
Closes gh-25445
2020-07-22 17:26:42 +02:00
Sam Brannen
51a5517a45 Polishing 2020-06-27 14:33:44 +02:00
Сергей Цыпанов
d08ce303f1 Extract Class.getName() from String concatenation
This commit extracts a Class.getName() invocation from String
concatenation in AbstractMonitoringInterceptor to avoid an issue
related to profile pollution.

Closes gh-25324
2020-06-27 14:24:49 +02:00
Juergen Hoeller
c777468056 Polishing 2020-06-08 19:37:58 +02:00
Sam Brannen
0998bd49ef Implement reliable advice invocation order within an @Aspect
The AspectJPrecedenceComparator was designed to mimic the precedence
order enforced by the AspectJ compiler with regard to multiple 'after'
methods defined within the same aspect whose pointcuts match the same
joinpoint. Specifically, if an aspect declares multiple @After,
@AfterReturning, or @AfterThrowing advice methods whose pointcuts match
the same joinpoint, such 'after' advice methods should be invoked in
the reverse order in which they are declared in the source code.

When the AspectJPrecedenceComparator was introduced in Spring Framework
2.0, it achieved its goal of mimicking the AspectJ compiler since the
JDK at that time (i.e., Java 5) ensured that an invocation of
Class#geDeclaredMethods() returned an array of methods that matched the
order of declaration in the source code. However, Java 7 removed this
guarantee. Consequently, in Java 7 or higher,
AspectJPrecedenceComparator no longer works as it is documented or as
it was designed when sorting advice methods in a single @Aspect class.
Note, however, that AspectJPrecedenceComparator continues to work as
documented and designed when sorting advice configured via the
<aop:aspect> XML namespace element.

PR gh-24673 highlights a use case where AspectJPrecedenceComparator
fails to assign the highest precedence to an @After advice method
declared last in the source code. Note that an @After advice method
with a precedence higher than @AfterReturning and @AfterThrowing advice
methods in the same aspect will effectively be invoked last due to the
try-finally implementation in AspectJAfterAdvice.invoke() which invokes
proceed() in the try-block and invokeAdviceMethod() in the
finally-block.

Since Spring cannot reliably determine the source code declaration
order of annotated advice methods without using ASM to analyze the byte
code, this commit introduces reliable invocation order for advice
methods declared within a single @Aspect. Specifically, the
getAdvisors(...) method in ReflectiveAspectJAdvisorFactory now hard
codes the declarationOrderInAspect to `0` instead of using the index of
the current advice method. This is necessary since the index no longer
has any correlation to the method declaration order in the source code.
The result is that all advice methods discovered via reflection will
now be sorted only according to the precedence rules defined in the
ReflectiveAspectJAdvisorFactory.METHOD_COMPARATOR. Specifically, advice
methods within a single @Aspect will be sorted in the following order
(with @After advice methods effectively invoked after @AfterReturning
and @AfterThrowing advice methods): @Around, @Before, @After,
@AfterReturning, @AfterThrowing.

The modified assertions in AspectJAutoProxyAdviceOrderIntegrationTests
demonstrate the concrete effects of this change.

Closes gh-25186
2020-06-08 14:18:28 +02:00
Sam Brannen
d6525cfb97 Polishing 2020-06-08 14:17:39 +02:00
Juergen Hoeller
d14140da69 Polishing 2020-06-06 13:21:46 +02:00
Sam Brannen
fbeecf3bf8 Test status quo for invocation order of all advice types
Prior to this commit we did not have tests in place to verify the status
quo for the invocation order of all advice types when declared within
a single aspect, either via the <aop:aspect> XML namespace or AspectJ
auto-proxy support.

This commit introduces such tests that demonstrate where such ordering
is broken or suboptimal.

The only test for which the advice invocation order is correct or at
least as expected is the afterAdviceTypes() test method in
ReflectiveAspectJAdvisorFactoryTests, where an AOP proxy is hand crafted
using ReflectiveAspectJAdvisorFactory without the use of Spring's
AspectJPrecedenceComparator.

See gh-25186
2020-06-05 15:30:57 +02:00
Sam Brannen
04c8de4e50 Polishing 2020-06-05 15:22:41 +02:00
Sam Brannen
63e8609f3b Test status quo for 'after' advice invocation order
See gh-25186
2020-06-04 18:37:24 +02:00
Sam Brannen
70b3de4afe Polish AspectJAdvisorFactory tests 2020-06-04 18:37:16 +02:00
陈其苗
13970ae528 Use autoboxing instead of explicit wrapping in tests
Closes gh-24801
2020-04-01 14:34:20 +02:00
Sam Brannen
e26764d249 Remove duplicate words in documentation and polish Javadoc 2020-03-31 12:17:58 +02:00
Juergen Hoeller
fdc60311ed Avoid unnecessary trace logging in ProxyFactoryBean
Closes gh-24669
2020-03-24 00:07:40 +01:00
Juergen Hoeller
d91fc8c672 No log level check unless String concatenation is following 2020-03-14 00:01:13 +01:00
Juergen Hoeller
33642345a4 Lazily check log level within validation conditions
See gh-24672
2020-03-13 23:14:38 +01:00
Qimiao Chen
988aae4f2e Remove unnecessary variable declaration in ProxyCallbackFilter
Closes gh-24675
2020-03-11 13:51:13 +01:00
Сергей Цыпанов
1fd447f395 Reduce String garbage in CglibAopProxy.doValidateClass()
Closes gh-24672
2020-03-10 17:16:08 +01:00
Qimiao Chen
b92515bdee Add logger.isInfoEnabled check before logger.info
Closes gh-24667
2020-03-10 14:41:20 +01:00
Christoph Dreis
2093e35f27 Avoid unnecessary sorting 2020-03-04 19:10:14 +00:00
ZhangT
6add7b4dec Polishing
Closes gh-24543
2020-02-17 17:33:39 +01:00
Sam Brannen
51fa98a1b2 Apply compiler conventions to test fixtures 2020-02-07 11:04:03 +01:00
Rossen Stoyanchev
f5df422de9 Polishing contribution
See gh-24470
2020-02-03 20:32:36 +00:00
Hyunjin Choi
273812f9c5 Remove unnecessary escapes in regular expressions
See gh-24470
2020-02-03 20:22:40 +00:00
Sam Brannen
e8ef93c508 Polish contribution
See gh-24321
2020-01-09 15:56:25 +01:00
lixiaolong11000
047eefd2e2 Improve exception message in AopContext.currentProxy()
Closes gh-24321
2020-01-09 15:56:09 +01:00
stsypanov
8e5cad2af3 Add fast path for ClassUtils.hasMethod() 2020-01-08 18:52:15 +01:00
Sam Brannen
141dae6437 Polish contribution
See gh-24293
2020-01-07 11:07:03 +01:00
lixiaolong11000
132805133d Improve ExposeInvocationInterceptor exception message
Closes gh-24293
2020-01-07 11:03:11 +01:00
Sam Brannen
8a371c7669 Use Gradle test fixture support for spring-aop
See gh-23550
2020-01-02 16:01:35 +01:00
Sam Brannen
7cd4ddf5fc Rename test fixture package in spring-beans
See gh-23550
2020-01-02 16:01:35 +01:00
Sam Brannen
4260c34b47 Rename test fixture package in spring-core
See gh-23550
2020-01-02 16:01:34 +01:00
Sam Brannen
61d4ee594d Use Gradle test fixture support for spring-beans and spring-context
See gh-23550
2020-01-02 16:01:34 +01:00
Sam Brannen
5718bf424b Use Gradle test fixture support for spring-core
See gh-23550
2020-01-02 16:01:34 +01:00
Pascal Schumacher
e7d489667c Add missing space in AopConfigException message
See gh-24266
2019-12-26 09:52:54 +01:00
Sam Brannen
6fdf5ef6ee Polish contribution
See gh-24205
2019-12-13 17:14:26 +01:00
Сергей Цыпанов
d9cae339d6 Simplify AdvisedSupport.removeAdvisor()
Closes gh-24205
2019-12-13 17:12:18 +01:00