spring-framework
spring-framework copied to clipboard
fix: Preserve NULL Parameters in case of AOP Proxy
I have seen a case where NULL argument is passed explicitly in the function call but it is taking default value instead. Below are the function signatures.
@Repository
open class A{
suspend fun test(a: Long? = -1){
println(a)
}
}
@Service
open class B {
@Inject private val a : A
runBlocking {
a.test(null) //prints -1
A().test(null) //prints null
}
}
This is specific to suspending functions and optional parameters only. Upon checking the code, I have below findings.
Below is the change introduced in spring-aop from version 6.0.21 to 6.1.1, Earlier we are directly invoking the method via reflection but now CoroutinesUtils.invokeSuspendingFunction is getting invoked which is filtering the NULL values.
spring-aop change:
As a part of this PR, I have introduced one more method in CoroutinesUtils which preserves the NULL values passed in arguments. This is being invoked via AOP Only and keeping the other flow remains as it is.
Let me know if you need any reproduction steps or additional feedback related to the code changes. I'm happy to contribute wherever I can.