From 1c6ef3fe38e6dadfed6176ce779847b38d221bd3 Mon Sep 17 00:00:00 2001 From: AlmostFamiliar Date: Tue, 8 Aug 2023 14:39:34 +0200 Subject: [PATCH 1/2] Use Any? in ProceedingJoinPoint Kotlin examples This commit changes Any to Any? in ProceedingJoinPoint Kotlin examples in order to be consistent with Java and avoid a "NullPointerException: pjp.proceed() must not be null" error. See gh-31015 --- .../modules/ROOT/pages/core/aop/ataspectj/advice.adoc | 6 +++--- .../modules/ROOT/pages/core/aop/ataspectj/example.adoc | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/framework-docs/modules/ROOT/pages/core/aop/ataspectj/advice.adoc b/framework-docs/modules/ROOT/pages/core/aop/ataspectj/advice.adoc index 998a69b0ed..a505001c81 100644 --- a/framework-docs/modules/ROOT/pages/core/aop/ataspectj/advice.adoc +++ b/framework-docs/modules/ROOT/pages/core/aop/ataspectj/advice.adoc @@ -176,7 +176,7 @@ Kotlin:: @AfterReturning( pointcut = "execution(* com.xyz.dao.*.*(..))", returning = "retVal") - fun doAccessCheck(retVal: Any) { + fun doAccessCheck(retVal: Any?) { // ... } } @@ -448,7 +448,7 @@ Kotlin:: class AroundExample { @Around("execution(* com.xyz..service.*.*(..))") - fun doBasicProfiling(pjp: ProceedingJoinPoint): Any { + fun doBasicProfiling(pjp: ProceedingJoinPoint): Any? { // start stopwatch val retVal = pjp.proceed() // stop stopwatch @@ -893,7 +893,7 @@ Kotlin:: "com.xyz.CommonPointcuts.inDataAccessLayer() && " + "args(accountHolderNamePattern)") // <1> fun preProcessQueryPattern(pjp: ProceedingJoinPoint, - accountHolderNamePattern: String): Any { + accountHolderNamePattern: String): Any? { val newPattern = preProcess(accountHolderNamePattern) return pjp.proceed(arrayOf(newPattern)) } diff --git a/framework-docs/modules/ROOT/pages/core/aop/ataspectj/example.adoc b/framework-docs/modules/ROOT/pages/core/aop/ataspectj/example.adoc index 03cb9d102e..896086c928 100644 --- a/framework-docs/modules/ROOT/pages/core/aop/ataspectj/example.adoc +++ b/framework-docs/modules/ROOT/pages/core/aop/ataspectj/example.adoc @@ -85,7 +85,7 @@ Kotlin:: } @Around("com.xyz.CommonPointcuts.businessService()") // <1> - fun doConcurrentOperation(pjp: ProceedingJoinPoint): Any { + fun doConcurrentOperation(pjp: ProceedingJoinPoint): Any? { var numAttempts = 0 var lockFailureException: PessimisticLockingFailureException do { @@ -173,7 +173,7 @@ Kotlin:: ---- @Around("execution(* com.xyz..service.*.*(..)) && " + "@annotation(com.xyz.service.Idempotent)") - fun doConcurrentOperation(pjp: ProceedingJoinPoint): Any { + fun doConcurrentOperation(pjp: ProceedingJoinPoint): Any? { // ... } ---- From 0c15be004e3c3caaa2620b87a851096db1703c25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Thu, 10 Aug 2023 19:12:55 +0200 Subject: [PATCH 2/2] Use Any? in ProceedingJoinPoint Kotlin examples This commit changes Any to Any? in ProceedingJoinPoint Kotlin examples in order to be consistent with Java and avoid a "NullPointerException: pjp.proceed() must not be null" error. Closes gh-31015 --- framework-docs/modules/ROOT/pages/core/aop/schema.adoc | 6 +++--- .../modules/ROOT/pages/core/aop/using-aspectj.adoc | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/framework-docs/modules/ROOT/pages/core/aop/schema.adoc b/framework-docs/modules/ROOT/pages/core/aop/schema.adoc index fd19d9ecc6..c51ad3e976 100644 --- a/framework-docs/modules/ROOT/pages/core/aop/schema.adoc +++ b/framework-docs/modules/ROOT/pages/core/aop/schema.adoc @@ -435,7 +435,7 @@ Kotlin:: + [source,kotlin,indent=0,subs="verbatim",role="secondary"] ---- - fun doBasicProfiling(pjp: ProceedingJoinPoint): Any { + fun doBasicProfiling(pjp: ProceedingJoinPoint): Any? { // start stopwatch val retVal = pjp.proceed() // stop stopwatch @@ -554,7 +554,7 @@ Kotlin:: class SimpleProfiler { - fun profile(call: ProceedingJoinPoint, name: String, age: Int): Any { + fun profile(call: ProceedingJoinPoint, name: String, age: Int): Any? { val clock = StopWatch("Profiling for '$name' and '$age'") try { clock.start(call.toShortString()) @@ -890,7 +890,7 @@ Kotlin:: this.order = order } - fun doConcurrentOperation(pjp: ProceedingJoinPoint): Any { + fun doConcurrentOperation(pjp: ProceedingJoinPoint): Any? { var numAttempts = 0 var lockFailureException: PessimisticLockingFailureException do { diff --git a/framework-docs/modules/ROOT/pages/core/aop/using-aspectj.adoc b/framework-docs/modules/ROOT/pages/core/aop/using-aspectj.adoc index 10fdac6dca..f9b6b39887 100644 --- a/framework-docs/modules/ROOT/pages/core/aop/using-aspectj.adoc +++ b/framework-docs/modules/ROOT/pages/core/aop/using-aspectj.adoc @@ -493,7 +493,7 @@ Kotlin:: class ProfilingAspect { @Around("methodsToBeProfiled()") - fun profile(pjp: ProceedingJoinPoint): Any { + fun profile(pjp: ProceedingJoinPoint): Any? { val sw = StopWatch(javaClass.simpleName) try { sw.start(pjp.getSignature().getName())