spring-projects / spring-projects/spring-session
Wrong return type in findById method
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.9k
- Forks
- 1.2k
- Avg merge
- 4h 27m
- Merged PRs (30d)
- 55
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
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.
Assessment
- Tech stack
- java, redis
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100