Fix Kotlin value class handling for suspending AOP methods - #37191
Open
dmitrysulman wants to merge 1 commit into
Open
Fix Kotlin value class handling for suspending AOP methods#37191dmitrysulman wants to merge 1 commit into
dmitrysulman wants to merge 1 commit into
Conversation
dmitrysulman
force-pushed
the
gh-37155
branch
2 times, most recently
from
August 22, 2026 16:43
71bd2a5 to
07c8ed1
Compare
Unbox Kotlin value class results returned from proxied suspending methods before returning them to the caller. Spring AOP interceptor chains expose return values as Object, which causes Kotlin value class results to be boxed. For suspending functions, the direct return path expects the unboxed value class representation. Update both CglibAopProxy and JdkDynamicAopProxy to detect value class return types and unbox boxed results after coroutine adaptation. Add tests for suspending methods returning value classes. See spring-projects#37155 Signed-off-by: Dmitry Sulman <dmitry.sulman@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix handling of Kotlin value-class return values from proxied suspending functions.
When a suspending method completes through the direct path, Kotlin expects the unboxed representation of a value class. Spring AOP could return the boxed value produced by the interceptor chain instead, causing incorrect results and ClassCastExceptions.
This change unboxes applicable value-class results before returning them from JDK and CGLIB proxies and adds tests.
See the the detailed root-cause analysis: #37155 (comment).
Fixes #37155