GH-3857: Allow redisSessionMapper to return null MapSession - #3885
Open
arimu1 wants to merge 1 commit into
Open
Conversation
…ssion The BiFunction return type for redisSessionMapper was non-null, but getSession/findById already treat a null mapper result as a missing session. Annotate the return type as @nullable so Kotlin callers can supply custom mappers that return null (for example when cleaning up corrupt Redis hashes). Signed-off-by: arimu1 <19286898+arimu1@users.noreply.github.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.
Summary
RedisIndexedSessionRepositoryandRedisSessionRepositoryalready treat anullresult fromredisSessionMapperas a missing/unloadable session, but theBiFunctionreturn type was declared non-null. That breaks Kotlin nullability when registering custom mappers that returnnull(for example after cleaning up a corrupt Redis hash).This change annotates the mapper return type as
@Nullable MapSessionon the field and setter (and alignsRedisSessionMapper'sBiFunctiontype for NullAway), matching existing runtime behavior.Fixes #3857
Changes
redisSessionMapperfield andsetRedisSessionMapperwith@Nullable MapSessionreturn type in:RedisIndexedSessionRepositoryRedisSessionRepositoryRedisSessionMapperwithBiFunction<..., @Nullable MapSession>so the default assignment compiles under NullAway (implementation still never returns null)nullyieldsfindById(...) == nullTest plan
./gradlew :spring-session-data-redis:test --tests RedisIndexedSessionRepositoryTests --tests RedisSessionRepositoryTests(Temurin 21)Signed-off-byon commit