Skip to content

Conversation

@youngsuk-kim
Copy link

This PR addresses issue #3269 by extracting duplicate duration validation logic into a reusable helper method.

Changes

  • Added isPositiveDuration(Duration) helper method to eliminate code duplication
  • Replaced duplicate validation logic at line 215 (in sleepTime method)
  • Replaced duplicate validation logic at line 566 (in isLockingCacheWriter method)
  • Added author information to class header

Motivation

The same validation pattern !duration.isZero() && !duration.isNegative() was duplicated in two locations, violating the DRY (Don't Repeat Yourself) principle. Extracting this into a helper method improves code
maintainability and readability.

Closes gh-3269

Checklist

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don't submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes. (N/A - This is a refactoring change that does not modify behavior. Existing tests validate the functionality.)
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 3, 2025
- Add isPositiveDuration(Duration) helper method
- Replace duplicate validation logic at lines 215 and 566
- Improve code maintainability and readability

Signed-off-by: bread <thayer2392@gmail.com>
Signed-off-by: bread <thayer2392@gmail.com>
@mp911de mp911de added type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: task A general task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove duplicated duration validation logic in DefaultRedisCacheWriter.

4 participants