Skip to content

fix: Preserve NULL Parameters in case of AOP Proxy #35014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nisargshah2000
Copy link

@nisargshah2000 nisargshah2000 commented Jun 8, 2025

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:
image

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 8, 2025
@rstoyanchev rstoyanchev added the in: core Issues in core modules (aop, beans, core, context, expression) label Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: waiting-for-triage An issue we've not yet triaged or decided on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants