spring-data-redis icon indicating copy to clipboard operation
spring-data-redis copied to clipboard

Extract duplicate duration validation logic to helper method

Open youngsuk-kim opened this issue 2 weeks ago • 0 comments

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

  • [x] You have read the Spring Data contribution guidelines.
  • [x] You use the code formatters provided here and have them applied to your changes. Don't submit any formatting related changes.
  • [x] 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.)
  • [x] You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed.

youngsuk-kim avatar Dec 03 '25 13:12 youngsuk-kim