Wrong return type in findById method

Open Beginner friendly
#1,729 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
java, redis

Research direction

Start at spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisIndexedSessionRepository.java#L428 and inspect the findById(String id) declaration and its current return type. Update the public-facing type to the general Session interface, then verify that the method remains usable for mocking and that existing production behavior is unchanged.

Written by the indexing model from the issue text.

Description

status: waiting-for-triage

https://github.com/spring-projects/spring-session/blob/5f5168814d9bf35bee3b8965ffde7bb1ae91cd93/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisIndexedSessionRepository.java#L428

In my particular case when I had to mock up this class in my tests, it's impossible to mock return type of findById(String id) method because instead of general Session interface from org.springframework.session package, we can see internal non-public implementation called RedisSession. Generally in the production code it's not a big deal - we can assign the value returned to the var of type Session. The problem is when we want to mock this method.

Dominant language
Java
Stars
1.9k
Forks
1.2k
Avg merge
4h 27m
Merged PRs (30d)
55

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from spring-projects/spring-session

All issues in spring-projects/spring-session

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.