Skip to content
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

CoroutinesUtils causes ClassCastException & NullPointerException after upgrading to Spring 6.1.5 / Spring Boot 3.2.4 #32552

Closed
sebastianfuss opened this issue Mar 29, 2024 · 4 comments
Labels
status: duplicate A duplicate of another issue

Comments

@sebastianfuss
Copy link

sebastianfuss commented Mar 29, 2024

After upgrading to Spring Boot 3.2.4 we noticed ClassCastException and NullPointerException in org.springframework.core.CoroutinesUtils.lambda$invokeSuspendingFunction

# testSuspendFunctionAsMethodParam
java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.JvmClassMappingKt.getJavaClass, parameter <this>

	at kotlin.jvm.JvmClassMappingKt.getJavaClass(JvmClassMapping.kt)
	at org.springframework.core.CoroutinesUtils.lambda$invokeSuspendingFunction$2(CoroutinesUtils.java:131)
	at kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt$createCoroutineUnintercepted$$inlined$createCoroutineFromSuspendFunction$IntrinsicsKt__IntrinsicsJvmKt$4.invokeSuspend(IntrinsicsJvm.kt:270)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
	at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:280)
	at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
	at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
	at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)

# testOpenMethodInSuperClass
java.lang.ClassCastException: class kotlin.reflect.jvm.internal.KTypeParameterImpl cannot be cast to class kotlin.reflect.KClass (kotlin.reflect.jvm.internal.KTypeParameterImpl and kotlin.reflect.KClass are in unnamed module of loader 'app')
	at org.springframework.core.CoroutinesUtils.lambda$invokeSuspendingFunction$2(CoroutinesUtils.java:130)
	at kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt$createCoroutineUnintercepted$$inlined$createCoroutineFromSuspendFunction$IntrinsicsKt__IntrinsicsJvmKt$4.invokeSuspend(IntrinsicsJvm.kt:270)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
	at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:280)
	at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
	at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
	at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)

Here is a little sample project to reproduce it:
https:/sebastianfuss/spring-coroutine-invocation-test

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 29, 2024
@snicoll
Copy link
Member

snicoll commented Mar 29, 2024

Thanks for the report but Spring Boot 3.4.2 does not exist. Did you mean 3.2.4?

Here is a little test to reproduce it:

Please don't share code in text as it means we'll have to copy paste that in a project to attempt to reproduce what you experienced and that alone isn't enough for us to do so. Please share a small sample we can use to reproduce the issue. You can attach a zip here or push the code to a GitHub repository.

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Mar 29, 2024
@sebastianfuss sebastianfuss changed the title CoroutinesUtils causes ClassCastException & NullPointerException after upgrading to Spring 6.1.5 / Spring Boot 3.4.2 CoroutinesUtils causes ClassCastException & NullPointerException after upgrading to Spring 6.1.5 / Spring Boot 3.2.4 Mar 29, 2024
@sebastianfuss
Copy link
Author

Hi @snicoll Yeah. I fixed the mistake in the spring boot version and linked a little sample project. Hope that helps. Thanks in advance! Have a nice day!

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Mar 29, 2024
@jhoeller
Copy link
Contributor

This looks related to #32510 where that hard KClass cast got revised for 6.1.6 already.
Could you try a recent 6.1.6 snapshot and see whether your scenario works again as well?

@sebastianfuss
Copy link
Author

👍 It's solved with the recent 6.1.6 snapshot. Thanks!

@snicoll snicoll closed this as not planned Won't fix, can't repro, duplicate, stale Mar 29, 2024
@snicoll snicoll added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged or decided on status: feedback-provided Feedback has been provided labels Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

4 participants