Skip to content

DefaultHashOperations.getTimeToLive converts hash-field TTL values twice for non-second TimeUnits #3427

Closed

Description

@hunseonglee

DefaultHashOperations.getTimeToLive(H key, TimeUnit timeUnit, Collection<HK> hashKeys) calls the unit-aware hTtl(rawKey, timeUnit, rawHashKeys), whose driver implementations (LettuceHashCommands, JedisHashCommands via Converters.secondsToTimeUnit) already convert the server's seconds into timeUnit — but then labels the returned values as seconds:

List<Long> rawValues = execute(connection -> ... .hTtl(rawKey, timeUnit, rawHashKeys));
...
return Expirations.of(timeUnit, orderedKeys, Expirations.Timeouts.of(TimeUnit.SECONDS, rawValues));

so Expirations converts them a second time. Requesting TimeUnit.MINUTES for a field with a 120-second TTL yields an Expiration of 2 seconds (and expiration.value() = 0 minutes) instead of 2 minutes — a 60x error (3600x for hours).

The reactive counterpart (DefaultReactiveHashOperations.getTimeToLive) correctly fetches plain seconds with the unit-less hTtl and lets Expirations do the single conversion.

Expected: the imperative implementation matches the reactive one, fetching seconds and converting once. Reproduced on main with a mock-based unit test. I will submit a PR with a fix and test.

Activity

  1. self-assigned this
    on Sep 7, 2026
  2. added
    type: bug
    and removed
    status: waiting-for-triage
    on Sep 7, 2026
  3. added this to the 4.0.8 (2025.1.8) milestone on Sep 7, 2026
  4. added a commit that references this issue on Sep 7, 2026
    e667dd4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type: bug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions