Repository navigation
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: bugA general bugA general bug
Milestone
Description
Affects: 6.1.6
If you extend an aspect class and override its method, then this method will be called twice.
Example in kotlin:
import mu.KLogging
import org.aspectj.lang.ProceedingJoinPoint
import org.aspectj.lang.annotation.Around
import org.aspectj.lang.annotation.Aspect
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.stereotype.Component
annotation class CustomAnnotation()
@Aspect
open class CustomAnnotationAspect {
@Around("execution (@CustomAnnotation * *.*(..))")
open fun wrapExecution(pjp: ProceedingJoinPoint): Any? {
logger.info { "start in super class" }
val result = pjp.proceed()
logger.info { "start in super class" }
return result
}
companion object : KLogging()
}
@Aspect
class ExtendedCustomAnnotationAspect : CustomAnnotationAspect() {
// don't matter if same @Around annotation presents or not
override fun wrapExecution(pjp: ProceedingJoinPoint): Any? {
logger.info { "start" }
val result = pjp.proceed()
logger.info { "finish" }
return result
}
companion object : KLogging()
}
@Configuration
class Config {
@Bean
fun customAspect(): ExtendedCustomAnnotationAspect {
return ExtendedCustomAnnotationAspect()
}
}then, when we call method annotated with @CustomAnnotation, we get output in console:
start
start
target method execution
finish
finish
expected output:
start
target method execution
finish
The call of ReflectionUtils.doWithMethods(...) in ReflectiveAspectJAdvisorFactory#getAdvisorMethods collects all user declared methods (methods of superclass and overridden methods), and all of them are used for making an advisors.
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: bugA general bugA general bug

Activity
Select most specific advice method in case of override
Select most specific advice method in case of override
Select most specific advice method in case of override